From 29346a682a4a55788e5a588fb8902e2166f24c0d Mon Sep 17 00:00:00 2001 From: pkong-ds Date: Tue, 28 May 2024 07:31:55 +0800 Subject: [PATCH] Use tippy for tooltips --- public/scripts/upload.js | 9 +++++++ src/layouts/BaseLayout.astro | 7 +++++ src/pages/model/[model]/color/[color].astro | 5 ++-- src/styles/upload.css | 30 --------------------- 4 files changed, 18 insertions(+), 33 deletions(-) diff --git a/public/scripts/upload.js b/public/scripts/upload.js index 652d3e9..53ca0ab 100644 --- a/public/scripts/upload.js +++ b/public/scripts/upload.js @@ -365,6 +365,13 @@ function updateFileListItem(itemNode, imageUpload) { } } +function handleColorPickersTooltip() { + tippy("[data-tippy-content]", { + placement: "bottom-end", + theme: "light-border", + }); +} + function main() { const htmlNode = document.querySelector("html"); const uploadSection = document.querySelector("#above-file-uploaded"); @@ -378,6 +385,8 @@ function main() { ".generating-modal-dialog__cancel-btn", ); + handleColorPickersTooltip(); + const fileListViewModel = new FileListViewModel(MAX_FILE_SIZE_BYTE); const viewModel = new RootViewModel(MAX_MOCKUP_WAIT_SEC, fileListViewModel); diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index b612d9e..9cdab63 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -39,6 +39,10 @@ const social_icon = "/Images/mockuphone-logo.png"; rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" /> + @@ -56,6 +60,9 @@ const social_icon = "/Images/mockuphone-logo.png"; defer data-domain="mockuphone.com" src="https://plausible.io/js/plausible.js"> + + diff --git a/src/pages/model/[model]/color/[color].astro b/src/pages/model/[model]/color/[color].astro index 9365c57..15b7dbd 100644 --- a/src/pages/model/[model]/color/[color].astro +++ b/src/pages/model/[model]/color/[color].astro @@ -159,9 +159,8 @@ if (deviceDetail == null) { ? "color-picker-item--selected" : "" }`} - > -
{d.color.name}
- + data-tippy-content={d.color.name} + /> )) } diff --git a/src/styles/upload.css b/src/styles/upload.css index 3feca95..05ec497 100644 --- a/src/styles/upload.css +++ b/src/styles/upload.css @@ -397,12 +397,10 @@ main { overflow-y: hidden; -ms-overflow-style: none; scrollbar-width: none; - padding-inline-start: 0; justify-content: center; } .color-picker-item { - position: relative; width: 30px; height: 30px; border: 3px white solid; @@ -436,34 +434,6 @@ main { margin-left: 18px; } -.color-picker-item .color-picker-item__tooltip { - visibility: hidden; - opacity: 0; - transition: opacity 0.3s; - - background-color: white; - - padding: 4px 8px; - border-radius: 4px; - border: 1px #e7e7e7 solid; - - color: black; - font-size: 12px; - font-weight: 400; - line-height: 18.5px; - text-align: center; - text-wrap: nowrap; - - position: absolute; - z-index: 1; - top: 45px; - left: 30px; -} -.color-picker-item:hover .color-picker-item__tooltip { - visibility: visible; - opacity: 1; -} - .generate-btn { margin: 20px 0 0 0; padding: 8px 50px;