From 9a06d63ee9459402ec8a19bd9c22f81d692cf2e5 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 5 Sep 2020 13:40:29 +0300 Subject: Add navbar and switch to sass. Fixes #2 --- web/index.js | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'web/index.js') diff --git a/web/index.js b/web/index.js index 86aac06..bc478af 100644 --- a/web/index.js +++ b/web/index.js @@ -24,6 +24,7 @@ class App extends Component { error: null, } this.observer = null + this.packListRef = null } observeIntersection = intersections => { @@ -67,7 +68,7 @@ class App extends Component { } componentDidUpdate() { - for (const elem of document.getElementsByClassName("sticker")) { + for (const elem of this.packListRef.getElementsByClassName("sticker")) { this.observer.observe(elem) } } @@ -78,29 +79,41 @@ class App extends Component { render() { if (this.state.loading) { - return html`
<${Spinner} size=${80} green />
` + return html`
<${Spinner} size=${80} green />
` } else if (this.state.error) { - return html`
+ return html`

Failed to load packs

${this.state.error}

-
` + ` } else if (this.state.packs.length === 0) { - return html`

No packs found :(

` + return html`

No packs found :(

` } - return html`
- ${this.state.packs.map(pack => html`<${Pack} id=${pack.id} ...${pack}/>`)} -
` + return html`
+ +
this.packListRef = elem}> + ${this.state.packs.map(pack => html`<${Pack} id=${pack.id} pack=${pack}/>`)} +
+
` } } -const Pack = ({ title, stickers }) => html`
-

${title}

+const NavBarItem = ({ pack }) => html` +
+ ${pack.stickers[0].body} +
+
` + +const Pack = ({ pack }) => html`
+

${pack.title}

- ${stickers.map(sticker => html` + ${pack.stickers.map(sticker => html` <${Sticker} key=${sticker["net.maunium.telegram.sticker"].id} content=${sticker}/> `)}
-
` +` const Sticker = ({ content }) => html`
sendSticker(content)}> ${content.body} -- cgit v1.2.3