From 706074e271eb4fd3f3219874cbf057070a0c5037 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Thu, 13 Feb 2025 21:38:18 +0800 Subject: [PATCH 1/3] add more tooltip --- frontend/src/components/elevator/miner.tsx | 16 ++++++---- frontend/src/components/pool/bulb.tsx | 4 +-- .../src/components/pool/committed-line.tsx | 1 + .../src/components/pool/committing-line.tsx | 9 ++++-- frontend/src/components/pool/header.tsx | 5 ++- frontend/src/components/pool/pending-line.tsx | 32 ++++++++++++++++--- .../src/components/pool/proposal-line.tsx | 9 ++++-- frontend/src/components/tooltip.tsx | 2 +- 8 files changed, 58 insertions(+), 20 deletions(-) diff --git a/frontend/src/components/elevator/miner.tsx b/frontend/src/components/elevator/miner.tsx index c178b04..e90cc64 100644 --- a/frontend/src/components/elevator/miner.tsx +++ b/frontend/src/components/elevator/miner.tsx @@ -49,7 +49,7 @@ const ElevatorMiner: FunctionComponent = ({ chainTheme === ChainTheme.mainnet ? "/assets/svg/elevator/mainnet/ape-jump.svg" : "/assets/svg/elevator/testnet/ape-jump.svg"; - const jumpClass = doorClosing ? "w-2/3 animate-jump" : ""; + const jumpClass = doorClosing ? "px-[30px] animate-jump" : ""; const minerStandSvg = chainTheme === ChainTheme.mainnet @@ -99,7 +99,7 @@ const ElevatorMiner: FunctionComponent = ({
-
+
= ({ />
- Miner Wheel +
+ Miner Wheel +
diff --git a/frontend/src/components/pool/bulb.tsx b/frontend/src/components/pool/bulb.tsx index 4c9c5bc..00eb082 100644 --- a/frontend/src/components/pool/bulb.tsx +++ b/frontend/src/components/pool/bulb.tsx @@ -7,10 +7,10 @@ export interface BulbProps { } export const Bulb: FunctionalComponent = ({ - bulbColor = "bg-white", + bulbColor = "bg-functionality-error", isOn = false, }) => { - const bulbStyle = `rounded-full border-2 border-black w-7 h-7 flex items-center justify-center transition-colors duration-300 ${isOn ? bulbColor : "bg-white"}`; + const bulbStyle = `rounded-full border-2 border-black w-7 h-7 flex items-center justify-center transition-colors duration-300 ${isOn ? bulbColor : "bg-functional-error"}`; return (
diff --git a/frontend/src/components/pool/committed-line.tsx b/frontend/src/components/pool/committed-line.tsx index 92f6ed2..a0729b4 100644 --- a/frontend/src/components/pool/committed-line.tsx +++ b/frontend/src/components/pool/committed-line.tsx @@ -142,6 +142,7 @@ export const CommittedLine: FunctionalComponent = ({
+ {/* Transaction Box Tooltip 层 */} {tooltipContent && tooltipPosition && (
= ({ className={`relative flex justify-start items-center pt-[100px] border-b-8 border-l-8 ${borderColor}`} >
- + + +
@@ -233,7 +236,9 @@ export const CommittingLine: FunctionalComponent = ({ )}
- + + +
diff --git a/frontend/src/components/pool/header.tsx b/frontend/src/components/pool/header.tsx index 61ad896..d1b1e38 100644 --- a/frontend/src/components/pool/header.tsx +++ b/frontend/src/components/pool/header.tsx @@ -1,6 +1,7 @@ import { useAtomValue } from "jotai"; import { FunctionalComponent } from "preact"; import { ChainTheme, chainThemeAtom } from "../../states/atoms"; +import Tooltip from "../tooltip"; export interface PoolHeaderProps { totalTxs: number; @@ -29,7 +30,9 @@ export const PoolHeader: FunctionalComponent = ({ "absolute bottom-6 w-fit left-1/2 -translate-x-1/2 flex justify-center bg-surface-DEFAULT-inverse px-8 py-4 gap-2" } > -
Mempool Size (KB)
+ +
Mempool Size (KB)
+
{txSizeInKB}
Total Transactions
{totalTxs}
diff --git a/frontend/src/components/pool/pending-line.tsx b/frontend/src/components/pool/pending-line.tsx index 854b2e5..141e940 100644 --- a/frontend/src/components/pool/pending-line.tsx +++ b/frontend/src/components/pool/pending-line.tsx @@ -13,6 +13,8 @@ import { useAtomValue } from "jotai"; import { ChainTheme, chainThemeAtom } from "../../states/atoms"; import { SignBoard } from "./signboard"; import Bulb from "./bulb"; +import Tooltip from "../tooltip"; +import { useChainService } from "../../context/chain"; export interface PendingLineProps { title: string; @@ -24,6 +26,7 @@ export const PendingLine: FunctionalComponent = ({ txs, }) => { const chainTheme = useAtomValue(chainThemeAtom); + const { chainService } = useChainService(); const [tooltipContent, setTooltipContent] = useState( null, @@ -242,13 +245,30 @@ export const PendingLine: FunctionalComponent = ({
- - - + + + + + + + + +
- + + +
@@ -267,7 +287,9 @@ export const PendingLine: FunctionalComponent = ({ )}
- + + +
diff --git a/frontend/src/components/pool/proposal-line.tsx b/frontend/src/components/pool/proposal-line.tsx index a5ef139..f062034 100644 --- a/frontend/src/components/pool/proposal-line.tsx +++ b/frontend/src/components/pool/proposal-line.tsx @@ -12,6 +12,7 @@ import { useAtomValue } from "jotai"; import { ChainTheme, chainThemeAtom } from "../../states/atoms"; import { bodyToScreenPosition, createTooltipContent } from "../../util/scene"; import { SignBoard } from "./signboard"; +import Tooltip from "../tooltip"; export interface ProposalLineProps { title: string; @@ -212,7 +213,9 @@ export const ProposalLine: FunctionalComponent = ({ className={`relative w-full flex justify-end border-b-8 border-r-8 pt-[100px] ${borderColor}`} >
- + + +
@@ -232,7 +235,9 @@ export const ProposalLine: FunctionalComponent = ({
- + + +
); diff --git a/frontend/src/components/tooltip.tsx b/frontend/src/components/tooltip.tsx index 7059cc5..d6fcddb 100644 --- a/frontend/src/components/tooltip.tsx +++ b/frontend/src/components/tooltip.tsx @@ -16,7 +16,7 @@ const Tooltip = ({ text, children }: TooltipProps) => { > {children} {isVisible && ( -
+
{text}
)} From 6c461525846064cf42a460b7e74966563305c601 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Thu, 13 Feb 2025 21:59:51 +0800 Subject: [PATCH 2/3] add some more tooltip --- frontend/src/components/elevator/car.tsx | 1 + .../src/components/elevator/elevator-ui.tsx | 16 +++++--- frontend/src/components/elevator/miner.tsx | 4 +- .../components/elevator/out-of-service.tsx | 35 +++++++++++------ frontend/src/components/tooltip.tsx | 38 ++++++++++++++++--- frontend/src/service/ws.ts | 2 +- 6 files changed, 71 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/elevator/car.tsx b/frontend/src/components/elevator/car.tsx index 576d702..0487c0b 100644 --- a/frontend/src/components/elevator/car.tsx +++ b/frontend/src/components/elevator/car.tsx @@ -18,6 +18,7 @@ import { ChainTheme, chainThemeAtom } from "../../states/atoms"; import ElevatorCapacity from "./capacity"; import { JSX } from "preact/jsx-runtime"; import { bodyToScreenPosition, createTooltipContent } from "../../util/scene"; +import Tooltip from "../tooltip"; export interface ElevatorCarProp { transactions: Transaction[]; diff --git a/frontend/src/components/elevator/elevator-ui.tsx b/frontend/src/components/elevator/elevator-ui.tsx index e9816b3..fcfe606 100644 --- a/frontend/src/components/elevator/elevator-ui.tsx +++ b/frontend/src/components/elevator/elevator-ui.tsx @@ -9,6 +9,7 @@ import { chainThemeAtom, ChainTheme } from "../../states/atoms"; import { useState } from "preact/hooks"; import { compactToDifficulty, difficultyToEH } from "../../util/difficulty"; import { calcBlockOccupation, calcTotalTxSize } from "../../util/type"; +import Tooltip from "../tooltip"; export interface ElevatorUIProp { block: TipBlockResponse; @@ -60,11 +61,16 @@ export const ElevatorUI: FunctionalComponent = ({ doorClosing={isDoorClosing} />
- + + +
diff --git a/frontend/src/components/elevator/miner.tsx b/frontend/src/components/elevator/miner.tsx index e90cc64..c63e0d7 100644 --- a/frontend/src/components/elevator/miner.tsx +++ b/frontend/src/components/elevator/miner.tsx @@ -98,7 +98,7 @@ const ElevatorMiner: FunctionComponent = ({
- +
= ({
- +
-
-
-
- Status -
-
- Connection {connectStatus} + +
+
+
+ Status +
+
+ {connectStatus} +
-
+
{/* elevator car */}
{ +const Tooltip = ({ text, children, pos = "top" }: TooltipProps) => { const [isVisible, setIsVisible] = useState(false); + let tooltipClasses = + "absolute z-50 bg-surface-DEFAULT-03 text-text-primary text-sm p-2 rounded-md shadow-lg border-2 border-black"; + let wrapperClasses = "relative"; + + switch (pos) { + case "top": + tooltipClasses += + " bottom-full mb-2 left-1/2 transform -translate-x-1/2"; + break; + case "bottom": + tooltipClasses += + " top-full mt-2 left-1/2 transform -translate-x-1/2"; + break; + case "left": + tooltipClasses += + " right-full mr-2 top-1/2 transform -translate-y-1/2"; + wrapperClasses += " inline-block"; // Important: Set inline-block on the wrapper for left/right positioning + break; + case "right": + tooltipClasses += + " left-full ml-2 top-1/2 transform -translate-y-1/2"; + wrapperClasses += " inline-block"; // Important: Set inline-block on the wrapper for left/right positioning + break; + default: + tooltipClasses += + " top-full mt-2 left-1/2 transform -translate-x-1/2"; // Default to bottom + break; + } + return (
setIsVisible(true)} onMouseLeave={() => setIsVisible(false)} > {children} {isVisible && ( -
- {text} -
+
{text}
)}
); diff --git a/frontend/src/service/ws.ts b/frontend/src/service/ws.ts index 99e4424..a469b6a 100644 --- a/frontend/src/service/ws.ts +++ b/frontend/src/service/ws.ts @@ -9,7 +9,7 @@ export type WebSocketMessageHandler = (message: WebSocketMessage) => void; export enum WebSocketConnectionState { CONNECTING = "CONNECTING", - OPEN = "OPEN", + OPEN = "CONNECTED", CLOSING = "CLOSING", CLOSED = "CLOSED", UNKNOWN = "UNKNOWN", From 4b92d57dac703003d18280becb572c20ee3bf5d9 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Thu, 13 Feb 2025 22:08:16 +0800 Subject: [PATCH 3/3] fix some detaikls --- .../src/components/elevator/block-modal.tsx | 2 +- frontend/src/components/replay/header.tsx | 41 +++++++++++++++---- frontend/src/layouts/navbar.tsx | 2 +- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/elevator/block-modal.tsx b/frontend/src/components/elevator/block-modal.tsx index cd5adb2..94943e4 100644 --- a/frontend/src/components/elevator/block-modal.tsx +++ b/frontend/src/components/elevator/block-modal.tsx @@ -256,7 +256,7 @@ const BlockModal: preact.FunctionComponent = ({ }} className={`${buttonColor} ${buttonHover} text-white font-bold py-2 px-4 rounded-lg focus:outline-none focus:shadow-outline`} > - Share this Block + Replay the Block = ({ chainTheme === ChainTheme.mainnet ? "text-brand-mainnet" : "text-brand-testnet"; + const [copyNotification, setCopyNotification] = useState( + null, + ); + + const handleCopyClick = () => { + const link = `${window.location.origin}/replay/${blockHash}`; + navigator.clipboard + .writeText(link) + .then(() => { + setCopyNotification("Link copied!"); + setTimeout(() => { + setCopyNotification(null); + }, 2000); // Clear notification after 2 seconds + }) + .catch((err) => { + console.error("Failed to copy: ", err); + setCopyNotification("Failed to copy link."); //Optional, error message. + setTimeout(() => { + setCopyNotification(null); + }, 2000); + }); + }; + return (
= ({ >

Elevator Block Replay

- - Copy the Share Link - + Share this block with your friends! + + {copyNotification && ( +
+ {copyNotification} +
+ )}
diff --git a/frontend/src/layouts/navbar.tsx b/frontend/src/layouts/navbar.tsx index 71126fd..f782f7e 100644 --- a/frontend/src/layouts/navbar.tsx +++ b/frontend/src/layouts/navbar.tsx @@ -24,7 +24,7 @@ const Navbar: FunctionalComponent = () => { { label: "Github", selected: false, - url: "https://github.com/cryptape", + url: "https://github.com/cryptape/ckb-tx-elevator", newTab: true, icon: "/assets/icons/github.svg", },