From f8a893e6deb838ba199d2ad182cb575ea23365e8 Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Tue, 13 May 2025 19:43:00 +0200 Subject: [PATCH] fix: Small fixes for toast notifications, b=(no-bug), c=common --- src/zen/common/ZenCommonUtils.mjs | 5 ++++- src/zen/common/ZenUIManager.mjs | 7 +++++++ src/zen/common/styles/zen-popup.css | 21 ++++++++++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/zen/common/ZenCommonUtils.mjs b/src/zen/common/ZenCommonUtils.mjs index d11b27558..cd7ac1946 100644 --- a/src/zen/common/ZenCommonUtils.mjs +++ b/src/zen/common/ZenCommonUtils.mjs @@ -73,7 +73,10 @@ var gZenCommonActions = { transferable.setTransferData('text/plain', str); Services.clipboard.setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard); let button; - if (Services.zen.canShare()) { + if ( + Services.zen.canShare() && + (currentUrl.startsWith('http://') || currentUrl.startsWith('https://')) + ) { button = { id: 'zen-copy-current-url-button', command: (event) => { diff --git a/src/zen/common/ZenUIManager.mjs b/src/zen/common/ZenUIManager.mjs index a216bbe9a..544d476e1 100644 --- a/src/zen/common/ZenUIManager.mjs +++ b/src/zen/common/ZenUIManager.mjs @@ -419,6 +419,12 @@ var gZenUIManager = { // Check if this message ID already exists for (const child of this._toastContainer.children) { if (child._messageId === messageId) { + if (options.button && child.querySelector('button')) { + const button = child.querySelector('button'); + const clone = button.cloneNode(true); + button.replaceWith(clone); + clone.addEventListener('command', options.button.command); + } return [child, true]; } } @@ -441,6 +447,7 @@ var gZenUIManager = { button.classList.add('primary'); button.addEventListener('command', options.button.command); wrapper.appendChild(button); + wrapper.setAttribute('button', true); } wrapper.classList.add('zen-toast'); wrapper._messageId = messageId; diff --git a/src/zen/common/styles/zen-popup.css b/src/zen/common/styles/zen-popup.css index 40c101d9d..e6c59279c 100644 --- a/src/zen/common/styles/zen-popup.css +++ b/src/zen/common/styles/zen-popup.css @@ -363,13 +363,17 @@ menuitem { translate: 100%; } + --zen-toast-padding: 10px; + --zen-toast-max-height: 52px; + @media (-moz-platform: windows) { + --zen-toast-padding: 6px; + --zen-toast-max-height: 46px; + } + gap: 10px; z-index: 1000; - padding: 10px; - @media (-moz-platform: windows) { - padding: 6px; - } - border-radius: 12px; + padding: var(--zen-toast-padding); + border-radius: 14px; background: linear-gradient( 170deg, var(--zen-primary-color) -40%, @@ -385,6 +389,9 @@ menuitem { font-size: small; position: absolute; transform-origin: top center; + max-height: var(--zen-toast-max-height); + min-height: var(--zen-toast-max-height); + font-size: 14px; & .description { opacity: 0.6; @@ -402,6 +409,10 @@ menuitem { min-width: unset !important; margin: 0px !important; border-radius: 8px !important; + + :root[zen-right-side='true'] & { + order: -1; + } } } }