From 1f24f1f2f2b85ee352a4dae5f0745ac4effe2f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Tue, 9 Jun 2026 17:03:01 +0200 Subject: [PATCH] Sync shows/disappears --- static/css/markdown.css | 76 +++++++++++++++++++++-------------- static/css/notes2.css | 12 +++++- static/js/marked_position.mjs | 2 +- static/js/sync.mjs | 21 +++++----- 4 files changed, 67 insertions(+), 44 deletions(-) diff --git a/static/css/markdown.css b/static/css/markdown.css index bd68c7b..85cde2c 100644 --- a/static/css/markdown.css +++ b/static/css/markdown.css @@ -4,53 +4,69 @@ .heading-container { display: grid; grid-template-columns: min-content 1fr; - grid-gap: 16px; + grid-gap: 12px; white-space: nowrap; align-items: center; - margin-top: 32px; - margin-bottom: 8px; + margin-bottom: 16px; &:first-child { - margin-top: 32px; + margin-top: 32px !important; + .line { + display: none !important; + } } .line { border-bottom: 1px solid var(--line-color); } - } - h1 { - border-bottom: 1px solid #ccc; + &[data-heading="1"] { + margin-top: 64px; + } - display: inline-block; - font-size: 1.25em; + &[data-heading="2"], + &[data-heading="3"] { + margin-top: 16px; - border-radius: 8px; - color: #fff; - background-color: var(--color1); - padding: 4px 12px; + .line { + display: none; + } + } - margin-top: 0px; - margin-bottom: 0px; + h1 { + border-bottom: 1px solid #ccc; - } + display: inline-block; + font-size: 1.25em; - h2 { - font-size: 1.25em; - margin-top: 0px; - margin-bottom: 0px; - color: var(--color1); - } + clip-path: polygon(0 0, 100% 0, calc(100% - 16px) 100%, 0 100%); - h2+.line, - h3+.line { - border-bottom: none !important; - } + color: #fff; + background-color: var(--color1); + padding: 4px 24px 4px 16px; + + margin-top: 0px; + margin-bottom: 0px; + + } + + h2 { + font-size: 1.25em; + margin-top: 16px; + margin-bottom: 0px; + color: var(--color1); + } + + h3 { + margin: 0; + + &:before { + font-size: 1.0em; + content: "> "; + color: var(--color1); + } + } - h3:before { - font-size: 1.0em; - content: "> "; - color: var(--color1); } a { diff --git a/static/css/notes2.css b/static/css/notes2.css index f55e1a1..76c660b 100644 --- a/static/css/notes2.css +++ b/static/css/notes2.css @@ -307,7 +307,8 @@ button { } n2-syncprogress { - position: absolute; + display: grid; + position: fixed; top: 8px; right: 8px; padding: 8px 16px; @@ -316,8 +317,15 @@ n2-syncprogress { font-weight: bold; background-color: var(--color1); color: #fff; + box-shadow: rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px; + + opacity: 0; + transition: opacity 250ms; + + &.show { + opacity: 1; + } - display: grid; grid-template-columns: min-content repeat(3, min-content); grid-gap: 8px 8px; white-space: nowrap; diff --git a/static/js/marked_position.mjs b/static/js/marked_position.mjs index 175f490..311e806 100644 --- a/static/js/marked_position.mjs +++ b/static/js/marked_position.mjs @@ -115,7 +115,7 @@ export class MarkedPosition { heading(token) { const content = this.parser.parseInline(token.tokens) return ` -
+
${content}\n
\n
diff --git a/static/js/sync.mjs b/static/js/sync.mjs index 4db4473..f0c9296 100644 --- a/static/js/sync.mjs +++ b/static/js/sync.mjs @@ -19,7 +19,6 @@ export class Sync { let nodeCountDownload = await this.getNodeCount(oldMax) let nodeCountUpload = await nodeStore.sendQueue.count() - console.log(nodeCountUpload) _mbus.dispatch('SYNC_DOWNLOAD_COUNT', { count: nodeCountDownload }) _mbus.dispatch('SYNC_UPLOAD_COUNT', { count: nodeCountUpload }) @@ -81,11 +80,11 @@ export class Sync { handled++ if (handled % 100 === 0) - _mbus.dispatch('SYNC_HANDLED', { handled }) + _mbus.dispatch('SYNC_DOWNLOADED', { handled }) } } while (res.Continue) - _mbus.dispatch('SYNC_HANDLED', { handled }) + _mbus.dispatch('SYNC_DOWNLOADED', { handled }) nodeStore.setAppState('latest_sync_node', currMax) } catch (e) { @@ -178,11 +177,12 @@ export class N2SyncProgress extends CustomHTMLElement { super() this.reset() + _mbus.subscribe('SYNC_DOWNLOAD_COUNT', event => this.progressHandler(event)) _mbus.subscribe('SYNC_UPLOAD_COUNT', event => this.progressHandler(event)) - _mbus.subscribe('SYNC_HANDLED', event => this.progressHandler(event)) - _mbus.subscribe('SYNC_DONE', event => this.progressHandler(event)) + _mbus.subscribe('SYNC_DOWNLOADED', event => this.progressHandler(event)) _mbus.subscribe('SYNC_UPLOADED', event => this.progressHandler(event)) + _mbus.subscribe('SYNC_DONE', event => this.progressHandler(event)) }//}}} reset() {//{{{ this.state = { @@ -205,11 +205,14 @@ export class N2SyncProgress extends CustomHTMLElement { this.setSyncState(true) break - case 'SYNC_HANDLED': - console.log('SYNC_HANDLED', eventData.handled) + case 'SYNC_DOWNLOADED': this.state.nodesSynced = eventData.handled break + case 'SYNC_UPLOADED': + this.state.nodesUploaded += eventData.count + break + case 'SYNC_DONE': // Hides the progress bar. this.setSyncState(false) @@ -221,10 +224,6 @@ export class N2SyncProgress extends CustomHTMLElement { // Reload the tree nodes to reflect the new/updated nodes. window._app.tree.reset() break - - case 'SYNC_UPLOADED': - this.state.nodesUploaded += eventData.count - break } this.render() }//}}}