From 255f8f8fbdb22146f4817e93864f5159f68a973c Mon Sep 17 00:00:00 2001 From: "mr. M" Date: Fri, 27 Dec 2024 16:41:22 +0100 Subject: [PATCH] Adjust max-height in animations and refactor share dialog validation logic in Zen Rices component --- .../content/zen-styles/zen-animations.css | 2 +- src/browser/base/zen-components/ZenRices.mjs | 23 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/browser/base/content/zen-styles/zen-animations.css b/src/browser/base/content/zen-styles/zen-animations.css index 0d546d921..8779f41c7 100644 --- a/src/browser/base/content/zen-styles/zen-animations.css +++ b/src/browser/base/content/zen-styles/zen-animations.css @@ -367,7 +367,7 @@ 99% { transform: translateX(-100%); opacity: 0; - max-height: 50px; + max-height: 15px; position: relative; } diff --git a/src/browser/base/zen-components/ZenRices.mjs b/src/browser/base/zen-components/ZenRices.mjs index 50e81d58c..814172cec 100644 --- a/src/browser/base/zen-components/ZenRices.mjs +++ b/src/browser/base/zen-components/ZenRices.mjs @@ -141,10 +141,10 @@ - + @@ -194,7 +194,7 @@ const options = document.getElementById("zen-rice-share-options"); options.setAttribute("zen-collapsed", options.getAttribute("zen-collapsed") === "true" ? "false" : "true"); } - this.validateShareDialog(document.getElementById("zen-rice-share-name")); + this.validateShareDialog(); } openShareDialog() { @@ -206,8 +206,10 @@ const dialog = this.shareDialog; dialog.removeAttribute("hidden"); + document.getElementById("zen-rice-share-name").focus(); + // Initialize the dialog with the current values - this.validateShareDialog(document.getElementById("zen-rice-share-name")); + this.validateShareDialog(); } resetShareDialog() { @@ -255,9 +257,12 @@ return Object.values(allowedRice).some(v => v); } - validateShareDialog(input) { + validateShareDialog() { const saveButton = document.getElementById("zen-rice-share-save"); - saveButton.disabled = !this.canShareRice() || input.value.trim().length < 3 || input.value.trim().length > 30; + const authorInput = document.getElementById("zen-rice-share-author"); + const input = document.getElementById("zen-rice-share-name"); + saveButton.disabled = !this.canShareRice() || input.value.trim().length < 3 || input.value.trim().length > 30 + || authorInput.value.trim().length < 3 || authorInput.value.trim().length > 15; } async submit() { @@ -310,7 +315,6 @@ console.error(json); return null; } - return json; } @@ -321,13 +325,14 @@ } showSuccessDialog(riceInfo) { - const { id } = riceInfo; + const { slug, token } = riceInfo; + // 'token' is like some sort of password to edit the rice, do NOT expose it setTimeout(() => { const successBox = document.getElementById("zen-rice-share-success"); document.getElementById("zen-rice-share-second-form").setAttribute("fade-out", "true"); successBox.removeAttribute("hidden"); const link = document.getElementById("zen-rice-share-success-link"); - link.value = `${ZEN_RICE_API}${id}`; + link.value = `${ZEN_RICE_API}/${slug}`; }, 2000); } }