From 828599506690406dfc5232bc29cff18bd4fad20d Mon Sep 17 00:00:00 2001 From: babalicious-io Date: Fri, 13 Dec 2024 10:07:59 +0100 Subject: [PATCH] input field - responsiveness deploy tool - styling/tooltips fee calculator - className fix/tooltips/responsive slider+toggle deploy - tooltip timeout mint - minor styling transfer - minor styling/className update stamping tool - responsiveness tooltip fix stamp tool - tooltip fix stamp tool - tooltip styling stamp tool - tooltip lock stamp tool - image/uploadField responsiveness - CHECK CODE FUNCTIONALITY stamp tool - consoleLog cleanup image container styling wallet receive modal - tooltip update wallet send modal - input field responsiveness wallet receive modal - responsiveness transfer modal - squared input field squared fix receive - class update tooltips update receive - tooltip change --- components/shared/fee/FeeCalculatorBase.tsx | 118 ++-- islands/Wallet/details/WalletReceiveModal.tsx | 68 ++- islands/Wallet/details/WalletSendModal.tsx | 8 +- .../Wallet/details/WalletTransferModal.tsx | 8 +- islands/stamping/InputField.tsx | 2 +- islands/stamping/SelectField.tsx | 2 +- islands/stamping/src20/SRC20InputField.tsx | 2 +- .../stamping/src20/deploy/DeployContent.tsx | 122 +++- islands/stamping/src20/mint/MintContent.tsx | 12 +- .../src20/transfer/TransferContent.tsx | 7 +- islands/stamping/stamp/OlgaContent.tsx | 537 ++++++++++++++---- 11 files changed, 687 insertions(+), 199 deletions(-) diff --git a/components/shared/fee/FeeCalculatorBase.tsx b/components/shared/fee/FeeCalculatorBase.tsx index 84a9b8ccd..357aa261b 100644 --- a/components/shared/fee/FeeCalculatorBase.tsx +++ b/components/shared/fee/FeeCalculatorBase.tsx @@ -1,4 +1,4 @@ -import { useState } from "preact/hooks"; +import { useEffect, useRef, useState } from "preact/hooks"; import { useFeePolling } from "$client/hooks/useFeePolling.ts"; import { logger } from "$lib/utils/logger.ts"; import { @@ -45,6 +45,9 @@ export function FeeCalculatorBase({ const { fees } = useFeePolling(); const [visible, setVisible] = useState(false); const [coinType, setCoinType] = useState("BTC"); + const [tooltipPosition, setTooltipPosition] = useState({ x: 0, y: 0 }); + const [isTooltipVisible, setIsTooltipVisible] = useState(false); + const tooltipTimeoutRef = useRef(null); const handleCoinToggle = () => { logger.debug("stamps", { @@ -57,6 +60,32 @@ export function FeeCalculatorBase({ setCoinType(coinType === "BTC" ? "USDT" : "BTC"); }; + const handleMouseMove = (e: MouseEvent) => { + setTooltipPosition({ + x: e.clientX, + y: e.clientY, + }); + }; + + const handleMouseEnter = () => { + setIsTooltipVisible(true); + + if (tooltipTimeoutRef.current) { + window.clearTimeout(tooltipTimeoutRef.current); + } + + tooltipTimeoutRef.current = window.setTimeout(() => { + setIsTooltipVisible(false); + }, 1500); + }; + + const handleMouseLeave = () => { + if (tooltipTimeoutRef.current) { + window.clearTimeout(tooltipTimeoutRef.current); + } + setIsTooltipVisible(false); + }; + // Fee selector component const renderFeeSelector = () => (
@@ -70,7 +99,11 @@ export function FeeCalculatorBase({ {fees.recommendedFee} SAT/vB

)} -
+
handleChangeFee(parseInt((e.target as HTMLInputElement).value, 10))} - className="accent-stamp-purple-dark w-full h-[6px] rounded-lg appearance-none cursor-pointer bg-stamp-grey [&::-webkit-slider-thumb]:w-[22px] [&::-webkit-slider-thumb]:h-[22px] [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:bg-stamp-purple-dark [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer [&::-moz-range-thumb]:w-[22px] [&::-moz-range-thumb]:h-[22px] [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:bg-stamp-purple-dark [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:cursor-pointer" + onMouseMove={handleMouseMove} + className="accent-stamp-purple-dark w-full h-1 mobileLg:h-1.5 rounded-lg appearance-none cursor-pointer bg-stamp-grey [&::-webkit-slider-thumb]:w-[18px] [&::-webkit-slider-thumb]:h-[18px] [&::-webkit-slider-thumb]:mobileLg:w-[22px] [&::-webkit-slider-thumb]:mobileLg:h-[22px] [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:bg-stamp-purple-dark [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer [&::-moz-range-thumb]:w-[18px] [&::-moz-range-thumb]:h-[18px] [&::-moz-range-thumb]:mobileLg:w-[22px] [&::-moz-range-thumb]:mobileLg:h-[22px] [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:bg-stamp-purple-dark [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:cursor-pointer" /> +
+ SELECT FEE +
); // Estimate details component const renderDetails = () => { - const detailsTitleClassName = "text-stamp-grey-darker font-light"; - const detailsTextClassName = + const detailsTitle = "text-stamp-grey-darker font-light"; + const detailsText = "text-xs mobileLg:text-sm font-medium text-stamp-grey-light"; return (
{/* File Type - Only show for stamp type */} {type === "stamp" && fileType && ( -

- FILE{" "} - {fileType.toUpperCase()} +

+ FILE {fileType.toUpperCase()}

)} {/* Editions - Only show for stamp type */} {type === "stamp" && issuance && ( -

- EDITIONS {issuance} +

+ EDITIONS {issuance}

)} {/* File Size */} {fileSize && ( -

- SIZE {fileSize}{" "} +

+ SIZE {fileSize}{" "} BYTES

)} {/* Sats Per Byte */} -

- SATS PER BYTE {fee} +

+ SATS PER BYTE {fee}

{/* Miner Fee */} {feeDetails?.minerFee && ( -

- MINER FEE{" "} - {coinType === "BTC" +

+ MINER FEE {coinType === "BTC" ? formatSatoshisToBTC(feeDetails.minerFee, { includeSymbol: false, }) @@ -136,8 +178,8 @@ export function FeeCalculatorBase({ {/* Service Fee */} {serviceFee && serviceFee > 0 && ( -

- +

+ {isModal ? "SERVICE FEE" : "MINTING FEE"} {" "} {coinType === "BTC" @@ -159,9 +201,8 @@ export function FeeCalculatorBase({ {/* Dust Value */} {feeDetails?.dustValue && feeDetails.dustValue > 0 && ( -

- DUST{" "} - {coinType === "BTC" +

+ DUST {coinType === "BTC" ? formatSatoshisToBTC(feeDetails.dustValue, { includeSymbol: false, }) @@ -172,9 +213,8 @@ export function FeeCalculatorBase({ {/* Total */} {feeDetails?.totalValue && ( -

- TOTAL{" "} - {coinType === "BTC" +

+ TOTAL {coinType === "BTC" ? formatSatoshisToBTC(feeDetails.totalValue, { includeSymbol: false, }) @@ -186,11 +226,21 @@ export function FeeCalculatorBase({ ); }; - const buttonPurpleOutlineClassName = + const tooltipFloat = + "fixed text-stamp-grey-light text-[10px] mobileLg:text-xs mb-1 bg-black px-2 py-1 rounded-sm whitespace-nowrap pointer-events-none z-50"; + const buttonPurpleOutline = "inline-flex items-center justify-center border-2 border-stamp-purple rounded-md text-sm mobileLg:text-base font-extrabold text-stamp-purple tracking-[0.05em] h-[42px] mobileLg:h-[48px] px-4 mobileLg:px-5 hover:border-stamp-purple-highlight hover:text-stamp-purple-highlight transition-colors"; - const buttonPurpleFlatClassName = + const buttonPurpleFlat = "inline-flex items-center justify-center bg-stamp-purple border-2 border-stamp-purple rounded-md text-sm mobileLg:text-base font-extrabold text-black tracking-[0.05em] h-[42px] mobileLg:h-[48px] px-4 mobileLg:px-5 hover:border-stamp-purple-highlight hover:bg-stamp-purple-highlight transition-colors"; + useEffect(() => { + return () => { + if (tooltipTimeoutRef.current) { + window.clearTimeout(tooltipTimeoutRef.current); + } + }; + }, []); + return (

@@ -202,11 +252,11 @@ export function FeeCalculatorBase({ }`} >
-
+
-
+
{showCopied ? "COPIED" : "COPY"}
diff --git a/islands/Wallet/details/WalletSendModal.tsx b/islands/Wallet/details/WalletSendModal.tsx index 44815735f..a17c432bc 100644 --- a/islands/Wallet/details/WalletSendModal.tsx +++ b/islands/Wallet/details/WalletSendModal.tsx @@ -113,10 +113,8 @@ function WalletSendModal({ fee: initialFee, handleChangeFee, onClose }: Props) { } }; - const inputField1colClassName = - "h-12 px-3 rounded-md bg-stamp-grey text-stamp-grey-darkest placeholder:text-stamp-grey-darkest placeholder:uppercase placeholder:font-light text-sm mobileLg:text-base font-medium w-full outline-none focus:bg-stamp-grey-light"; - const inputField2colClassName = - "flex flex-col mobileMd:flex-row gap-3 mobileMd:gap-6 w-full"; + const inputField = + "h-[42px] mobileLg:h-12 px-3 rounded-md bg-stamp-grey text-stamp-grey-darkest placeholder:text-stamp-grey-darkest placeholder:uppercase placeholder:font-light text-sm mobileLg:text-base font-medium w-full outline-none focus:bg-stamp-grey-light"; return ( @@ -219,7 +217,7 @@ function WalletSendModal({ fee: initialFee, handleChangeFee, onClose }: Props) { recipientAddress: (e.target as HTMLInputElement).value, })} placeholder="Recipient address" - class={inputField1colClassName} + class={inputField} />
diff --git a/islands/Wallet/details/WalletTransferModal.tsx b/islands/Wallet/details/WalletTransferModal.tsx index dd673a94e..cd80b2632 100644 --- a/islands/Wallet/details/WalletTransferModal.tsx +++ b/islands/Wallet/details/WalletTransferModal.tsx @@ -138,12 +138,12 @@ function WalletTransferModal({ }, [selectedStamp]); const inputField = - "h-12 px-3 rounded-md bg-stamp-grey text-stamp-grey-darkest placeholder:text-stamp-grey-darkest placeholder:uppercase placeholder:font-light text-sm mobileLg:text-base font-medium w-full outline-none focus:bg-stamp-grey-light"; + "h-[42px] mobileLg:h-12 px-3 rounded-md bg-stamp-grey text-stamp-grey-darkest placeholder:text-stamp-grey-darkest placeholder:uppercase placeholder:font-light text-sm mobileLg:text-base font-medium w-full outline-none focus:bg-stamp-grey-light"; return (
-
+
{selectedStamp ? ( )} @@ -193,7 +193,7 @@ function WalletTransferModal({ max={maxQuantity} value={quantity} onChange={handleQuantityChange} - className={`${inputField} !w-12 text-center`} + className={`${inputField} !w-[42px] mobileLg:!w-12 text-center`} />
diff --git a/islands/stamping/InputField.tsx b/islands/stamping/InputField.tsx index 3f62fa8d7..c87f6afe7 100644 --- a/islands/stamping/InputField.tsx +++ b/islands/stamping/InputField.tsx @@ -34,7 +34,7 @@ export function InputField({
{options.length ? options.map((item) => ( diff --git a/islands/stamping/src20/SRC20InputField.tsx b/islands/stamping/src20/SRC20InputField.tsx index 8592032f8..dd5489042 100644 --- a/islands/stamping/src20/SRC20InputField.tsx +++ b/islands/stamping/src20/SRC20InputField.tsx @@ -29,7 +29,7 @@ export function SRC20InputField({
(null); const [tosAgreed, setTosAgreed] = useState(false); + const [tooltipPosition, setTooltipPosition] = useState({ x: 0, y: 0 }); + const [isUploadTooltipVisible, setIsUploadTooltipVisible] = useState(false); + const [isToggleTooltipVisible, setIsToggleTooltipVisible] = useState(false); + const [allowTooltip, setAllowTooltip] = useState(true); + const uploadTooltipTimeoutRef = useRef(null); + const toggleTooltipTimeoutRef = useRef(null); const { wallet, isConnected } = walletContext; @@ -122,17 +128,20 @@ export function DeployContent( const handleShowAdvancedOptions = () => { const switchToggle = document.querySelector("#switch-toggle-advanced"); if (!switchToggle) return; + setAllowTooltip(false); + setIsToggleTooltipVisible(false); + if (showAdvancedOptions !== true) { switchToggle.classList.add("translate-x-full"); setTimeout(() => { switchToggle.innerHTML = - `
`; + `
`; }, 150); } else { switchToggle.classList.remove("translate-x-full"); setTimeout(() => { switchToggle.innerHTML = - `
`; + `
`; }, 150); } setShowAdvancedOptions(!showAdvancedOptions); @@ -142,25 +151,91 @@ export function DeployContent( const advancedToggle = document.getElementById("switch-toggle-advanced"); if (advancedToggle) { advancedToggle.innerHTML = - `
`; + `
`; } }, []); + const handleMouseMove = (e: MouseEvent) => { + setTooltipPosition({ + x: e.clientX, + y: e.clientY, + }); + }; + + const handleUploadMouseEnter = () => { + setIsUploadTooltipVisible(true); + + if (uploadTooltipTimeoutRef.current) { + window.clearTimeout(uploadTooltipTimeoutRef.current); + } + + uploadTooltipTimeoutRef.current = window.setTimeout(() => { + setIsUploadTooltipVisible(false); + }, 1500); + }; + + const handleUploadMouseLeave = () => { + if (uploadTooltipTimeoutRef.current) { + window.clearTimeout(uploadTooltipTimeoutRef.current); + } + setIsUploadTooltipVisible(false); + }; + + const handleToggleMouseEnter = () => { + if (allowTooltip) { + setIsToggleTooltipVisible(true); + + if (toggleTooltipTimeoutRef.current) { + window.clearTimeout(toggleTooltipTimeoutRef.current); + } + + toggleTooltipTimeoutRef.current = window.setTimeout(() => { + setIsToggleTooltipVisible(false); + }, 1500); + } + }; + + const handleToggleMouseLeave = () => { + if (toggleTooltipTimeoutRef.current) { + window.clearTimeout(toggleTooltipTimeoutRef.current); + } + setIsToggleTooltipVisible(false); + setAllowTooltip(true); + }; + + useEffect(() => { + return () => { + if (uploadTooltipTimeoutRef.current) { + window.clearTimeout(uploadTooltipTimeoutRef.current); + } + if (toggleTooltipTimeoutRef.current) { + window.clearTimeout(toggleTooltipTimeoutRef.current); + } + }; + }, []); + const bodyTools = "flex flex-col w-full items-center gap-3 mobileMd:gap-6"; const titlePurpleLDCenter = - "inline-block text-3xl mobileMd:text-4xl mobileLg:text-5xl desktop:text-6xl font-black purple-gradient3 w-full text-center"; + "inline-block w-full mobileMd:-mb-3 mobileLg:mb-0 text-3xl mobileMd:text-4xl mobileLg:text-5xl desktop:text-6xl font-black purple-gradient3 text-center"; const feeSelectorContainer = "p-3 mobileMd:p-6 dark-gradient z-[10] w-full"; + const tooltipButton = + "absolute left-1/2 -translate-x-1/2 bg-[#000000BF] px-2 py-1 rounded-sm mb-1 bottom-full text-[10px] mobileLg:text-xs text-stamp-grey-light whitespace-nowrap"; + const tooltipImage = + "fixed bg-[#000000BF] px-2 py-1 mb-1 rounded-sm text-[10px] mobileLg:text-xs text-stamp-grey-light whitespace-nowrap pointer-events-none z-50"; return (

DEPLOY

-
+
+
+ UPLOAD COVER IMAGE +
)}
@@ -210,7 +297,7 @@ export function DeployContent(
{ const newValue = (e.target as HTMLInputElement).value @@ -225,13 +312,22 @@ export function DeployContent( isUppercase />
@@ -240,7 +336,7 @@ export function DeployContent( type="text" inputMode="numeric" pattern="[0-9]*" - placeholder="Limit pr. mint" + placeholder="Limit per mint" value={formState.lim} onChange={(e) => handleInputChange(e, "lim")} onBlur={() => handleInputBlur("lim")} @@ -270,7 +366,7 @@ export function DeployContent(