From ca533f1c149d2b5dac48b2496942f8c5423c027f Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sun, 5 Dec 2021 17:17:33 -0500 Subject: [PATCH 1/4] refactor: change fixHeaderPadding to updatePanelOffset Save css variable to html element instead of updating padding-top via js. Fixes #538 --- less/style.less | 4 ++++ less/topic.less | 8 +++++++- public/persona.js | 15 +++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/less/style.less b/less/style.less index 7caf276..a0b9ca0 100644 --- a/less/style.less +++ b/less/style.less @@ -18,6 +18,10 @@ body { min-height: 100%; } +#panel { + padding-top: var(--panel-offset); +} + @media (max-width: @screen-xs-max) { .slideout-panel { min-height: 100vh; diff --git a/less/topic.less b/less/topic.less index bf61f38..19a5d1e 100644 --- a/less/topic.less +++ b/less/topic.less @@ -41,7 +41,7 @@ } .topic-header { position: sticky; - top: @navbar-height; + top: calc(var(--panel-offset) + @navbar-height); background-color: @body-bg; z-index: @zindex-navbar; margin-left: -15px; @@ -50,6 +50,12 @@ padding-right: 15px; } + @media (max-width: @screen-md-max) { + .topic-header { + top: calc(var(--panel-offset) + @navbar-height - 70px); + } + } + .topic-info { border-bottom: 1px solid @post-border-color; margin-bottom: 10px; diff --git a/public/persona.js b/public/persona.js index 172c01a..20d0bba 100644 --- a/public/persona.js +++ b/public/persona.js @@ -7,10 +7,10 @@ $(document).ready(function () { setupEditedByIcon(); setupQuickReply(); configureNavbarHiding(); - fixHeaderPadding(); + updatePanelOffset(); $(window).on('resize', utils.debounce(configureNavbarHiding, 200)); - $(window).on('resize', fixHeaderPadding); + $(window).on('resize', updatePanelOffset); $(window).on('action:app.loggedIn', function () { setupMobileMenu(); @@ -21,25 +21,24 @@ $(document).ready(function () { setupMobileMenu(); }); - function fixHeaderPadding() { + function updatePanelOffset() { var env = utils.findBootstrapEnvironment(); const headerEl = document.getElementById('header-menu'); - const panelEl = document.getElementById('panel'); - if (!headerEl || !panelEl) { + if (!headerEl) { return; } const headerRect = headerEl.getBoundingClientRect(); const headerStyle = window.getComputedStyle(headerEl); - let paddingTop = headerRect.y + headerRect.height + (parseInt(headerStyle.marginTop, 10) || 0) + (parseInt(headerStyle.marginBottom, 10) || 0); + let offset = headerRect.y + headerRect.height + (parseInt(headerStyle.marginTop, 10) || 0) + (parseInt(headerStyle.marginBottom, 10) || 0); // body element itself introduces a hardcoded 70px padding on desktop resolution if (env === 'lg') { - paddingTop -= 70; + offset -= 70; } - panelEl.style.paddingTop = `${paddingTop}px`; + document.documentElement.style.setProperty('--panel-offset', `${offset}px`); } var lastBSEnv = ''; From b53cada70e3444874341eb5ba3fbc160729d0b69 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sun, 5 Dec 2021 17:17:37 -0500 Subject: [PATCH 2/4] 11.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac5cc71..512142d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodebb-theme-persona", - "version": "11.3.2", + "version": "11.3.3", "nbbpm": { "compatibility": "^1.18.0" }, From 05fff2d37b0461f108c32ce49d0f453211cfbde5 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 6 Dec 2021 12:13:09 -0500 Subject: [PATCH 3/4] fix: do not shrink timeline badge, hide timestamp on mobile for topic events --- less/mixins.less | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/less/mixins.less b/less/mixins.less index 0c73cca..710e04f 100644 --- a/less/mixins.less +++ b/less/mixins.less @@ -100,6 +100,10 @@ &+.timeline-event:before { display: none; } + + .timeline-text.timeago { + display: none; + } } } @@ -145,6 +149,8 @@ display: flex; align-items: center; justify-content: center; + flex-shrink: 0; + width: 32px; height: 32px; padding: 0; From 89df4b64416fa13283de93ff424b2c5e063b2019 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 6 Dec 2021 12:13:13 -0500 Subject: [PATCH 4/4] 11.3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 512142d..b580f1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodebb-theme-persona", - "version": "11.3.3", + "version": "11.3.4", "nbbpm": { "compatibility": "^1.18.0" },