A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
feat: basic empty state view
Christian Fei925da3108cfd
diff --git a/client/components/empty-state.js b/client/components/empty-state.jsnew file mode 100644index 0000000..517635f--- /dev/null+++ b/client/components/empty-state.js@@ -0,0 +1,26 @@++class EmptyState extends HTMLElement {+ constructor () {+ super()+ }+ connectedCallback () {+ this.render()+ this.registerEvents()+ }+ disconnectedCallback () {+ this.deregisterEvents()+ }+ registerEvents () {+ }+ deregisterEvents () {+ }+ render () {+ /* html for empty app state */+ this.innerHTML = /*html*/`+ <h1>Nothing to show...</h1>+ <p>Add your YouTube subscriptions in the <a href="/settings">Settings</a></p>+ <div class="big-sad-emoji"></div>+ `+ }+}+customElements.define('empty-state', EmptyState)diff --git a/client/index.html b/client/index.htmlindex 9705597..e8c0abb 100644--- a/client/index.html+++ b/client/index.html@@ -29,12 +29,13 @@<template id="main-template"><channels-list></channels-list><div id="filter-results-status"></div>- <div class="flex space-around p-1">+ <div id="filters-container" class="flex space-around p-1"><button id="show-downloaded-videos">Downloaded videos</button><button id="show-summarized-videos">Summarized videos</button><button id="show-ignored-videos">Ignored videos</button></div><div class="main-videos-container"></div>+ <empty-state style="display:none"></empty-state></template>@@ -66,6 +67,7 @@<h1>404 Not Found</h1></template>+ <script type="module" src="/components/empty-state.js"></script><script type="module" src="/components/channels-list.js"></script><script type="module" src="/components/search-videos.js"></script><script type="module" src="/components/add-channel-form.js"></script>diff --git a/client/main.css b/client/main.cssindex 775f7eb..56bf0dc 100644--- a/client/main.css+++ b/client/main.css@@ -354,4 +354,26 @@ details {}.show-ignored-videos [data-ignored="true"] {display: block;+}+++++++empty-state {+ position: relative;+ max-width: 30em;+ margin: 2em auto;+}+.big-sad-emoji {+ display: block;+}+.big-sad-emoji::after {+ display: block;+ font-size: 10em;+ margin-top: 20px;+ margin-bottom: 20px;+ animation: fadeIn 1s ease-in-out;+ content: ':(';}\ No newline at end of filediff --git a/client/main.js b/client/main.jsindex cef3a7a..b544b4a 100644--- a/client/main.js+++ b/client/main.js@@ -19,6 +19,19 @@ const routes = {'/': { template: document.getElementById('main-template'), title: 'My YT', async initialize() {console.log('initialize /')+ let $videosContainer = document.querySelector('.main-videos-container')+ if (!$videosContainer) return+ let videos = await fetch('/videos').then(res => res.json())+ console.log('videos.length', videos.length)+ if (videos.length === 0) {+ document.querySelector('empty-state').style.display = 'block'+ document.querySelector('channels-list').style.display = 'none'+ document.querySelector('#filters-container').style.display = 'none'+ } else {+ document.querySelector('empty-state').style.display = 'none'+ document.querySelector('channels-list').style.display = 'block'+ document.querySelector('#filters-container').style.display = 'block'+ }const $showDownloadedVideos = document.getElementById('show-downloaded-videos')handleClick($showDownloadedVideos, (event) => {@@ -37,9 +50,6 @@ const routes = {})- let $videosContainer = document.querySelector('.main-videos-container')- if (!$videosContainer) return- let videos = await fetch('/videos').then(res => res.json())$videosContainer.innerHTML = ''const ignoredTerms = window.store.get(window.store.ignoreTermsKey)diff --git a/lib/server.js b/lib/server.jsindex 573eebb..0b5ec2d 100644--- a/lib/server.js+++ b/lib/server.js@@ -58,6 +58,8 @@ export function createServer ({repo, connections = []}) {return fileHandler('client/components/search-videos.js', 'application/javascript')(req, res)if (url.pathname === '/components/channels-list.js')return fileHandler('client/components/channels-list.js', 'application/javascript')(req, res)+ if (url.pathname === '/components/empty-state.js')+ return fileHandler('client/components/empty-state.js', 'application/javascript')(req, res)if (url.pathname === '/lib/store.js')return fileHandler('client/lib/store.js', 'application/javascript')(req, res)