diff options
Diffstat (limited to 'static/pages/main')
| -rw-r--r-- | static/pages/main/index.css | 69 | ||||
| -rw-r--r-- | static/pages/main/index.js | 97 |
2 files changed, 166 insertions, 0 deletions
diff --git a/static/pages/main/index.css b/static/pages/main/index.css new file mode 100644 index 0000000..421e689 --- /dev/null +++ b/static/pages/main/index.css @@ -0,0 +1,69 @@ + +:host { + display: grid; + height: 100%; + width: 100%; + background: var(--page-background); +} + +#bar { + position: fixed; + bottom: 5px; + left: 5px; + right: 5px; + background: #fff9; + box-shadow: #223223aa 1px 1px 4px; + display: grid; + grid-template-columns: 1fr 1fr 1fr 1fr 1fr ; + height: 50px; + backdrop-filter: blur(10px); + border-radius: var(--border-radius); + transition: bottom 0.1s ease; +} + +#bar.hidden { + bottom: -200px; +} + +.menu-button { + color: var(--fg-disabled); + width: 18px; + height: 18px; + border-radius: 100%; + margin: auto; + cursor: pointer; + user-select: none; + align-content: center; + text-align: center; +} + +.menu-button.add { + width: 60px; + height: 60px; + margin-top: -20px; + background: var(--primary); + transition: width 0.1s ease, height 0.1s ease, margin 0.1s ease; + color: var(--card-background); + font-weight: bold; + font-size: 2em; +} + +.menu-button.add .icon { + width: 30px; + height: 30px; + display: grid; + margin: auto; +} + +.menu-button.add .icon .bi-house-fill { + width: 20px; + height: 20px; + margin: auto; +} + +.menu-button .icon { + width: 100%; + height: 100%; + display: grid; + margin: auto; +} diff --git a/static/pages/main/index.js b/static/pages/main/index.js new file mode 100644 index 0000000..9bf0aae --- /dev/null +++ b/static/pages/main/index.js @@ -0,0 +1,97 @@ +import * as sfw from 'sfw'; +const { Div, Input } = sfw.element.native; + +import icons from '/icons/index.js'; + +const css = await sfw.css(import.meta.url, './index.css'); + +export default class MainView extends sfw.element.Container { + #active_kind + #active_button + #active_view + #bar + + static Kind = Object.freeze({ + 'upload': 0, + 'home': 1, + }); + + constructor() { + super({ css }); + + this.onsearch = () => {} + this.onmonth = () => {} + this.onupload = () => {} + this.onshuffle = () => {} + this.onhome = () => {} + + this.body.append( + this.#active_view = Div.new({ id: 'main' }), + + this.#bar = Div.new({ + id: 'bar', + children: [ + Div.new({ + className: 'menu-button', + children: [ icons.search ], + onclick: (e) => { + e.stopPropagation(); + this.onsearch(); + } + }), + + Div.new({ + className: 'menu-button', + children: [ icons.calendar ], + onclick: () => this.onmonth(), + }), + + this.#active_button = Div.new({ + className: 'menu-button add', + children: [ icons.add ], + onclick: () => this.onupload() + }), + + Div.new({ + className: 'menu-button', + children: [ icons.shuffle ], + onclick: () => this.onshuffle(), + }), + + Div.new({ + className: 'menu-button', + children: [ icons.settings ], + onclick: () => this.onsettings(), + }), + ], + }), + ); + } + + hide() { + this.#bar.classList.add('hidden'); + } + + show() { + this.#bar.classList.remove('hidden'); + } + + set active_view(element) { + this.#active_view.innerHTML = ''; + this.#active_view.append(element); + } + + set active_kind(kind) { + if (kind == MainView.Kind.home) { + this.#active_button.innerHTML = ''; + this.#active_button.append(icons.home); + this.#active_button.onclick = () => this.onhome(); + } else if (kind == MainView.Kind.upload) { + this.#active_button.innerHTML = ''; + this.#active_button.append(icons.add); + this.#active_button.onclick = () => this.onupload(); + } else { + console.error(`invalid kind ${kind}`); + } + } +} |