From 2c0a7d1fd9d510ca83f99d59a8e3f31526f28650 Mon Sep 17 00:00:00 2001 From: Yao Xiao <108576690+Charlie-XIAO@users.noreply.github.com> Date: Thu, 13 Feb 2025 03:08:14 -0500 Subject: [PATCH] refactor: about tab (#420) * refactor: about tab * minor * minor --- .../components/About/ExternalCopyLink.tsx | 54 ------------ src/manager/components/About/index.tsx | 87 +++++++++++-------- src/manager/components/ExternalCopyLink.tsx | 43 +++++++++ src/manager/components/Widgets/Config.tsx | 1 - src/manager/components/Widgets/Settings.tsx | 1 - 5 files changed, 94 insertions(+), 92 deletions(-) delete mode 100644 src/manager/components/About/ExternalCopyLink.tsx create mode 100644 src/manager/components/ExternalCopyLink.tsx diff --git a/src/manager/components/About/ExternalCopyLink.tsx b/src/manager/components/About/ExternalCopyLink.tsx deleted file mode 100644 index 6e855ddd..00000000 --- a/src/manager/components/About/ExternalCopyLink.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import { - Flex, - FlexProps, - IconButton, - Link, - LinkProps, - Tooltip, -} from "@radix-ui/themes"; -import { RxCopy } from "react-icons/rx"; -import { writeText } from "@tauri-apps/plugin-clipboard-manager"; -import { toast } from "sonner"; -import { PropsWithChildren } from "react"; - -interface ExternalCopyLinkProps { - /** The external target of the link. */ - href: LinkProps["href"]; - /** The gap size between the link text and the copy button. */ - gap?: FlexProps["gap"]; -} - -/** - * The external link component with a copy button. - * - * The link will be opened in a new tab when clicked. The copy button will copy the link - * address to the clipboard. Wrap the link text within this component. - */ -const ExternalCopyLink = ({ - href, - gap = "3", - children, -}: PropsWithChildren) => { - return ( - - - {children} - - - - writeText( - "https://csci-shu-410-se-project.github.io/Deskulpt/", - ).then(() => toast.success("Copied to clipboard.")) - } - > - - - - - ); -}; - -export default ExternalCopyLink; diff --git a/src/manager/components/About/index.tsx b/src/manager/components/About/index.tsx index b4d71681..a266bce6 100644 --- a/src/manager/components/About/index.tsx +++ b/src/manager/components/About/index.tsx @@ -1,12 +1,13 @@ -import { Avatar, DataList, Flex, Heading, Text } from "@radix-ui/themes"; -import ExternalCopyLink from "./ExternalCopyLink"; +import { Avatar, Box, Flex, Heading, Table } from "@radix-ui/themes"; +import ExternalCopyLink from "../ExternalCopyLink"; import Logo from "/deskulpt.svg"; import { memo } from "react"; +import { FaGithub } from "react-icons/fa"; const AboutTab = memo(() => { return ( - - + + { }} /> - - - Deskulpt - A cross-platform desktop customization tool - - - - Version - {__VERSION__} - - - Authors - The Deskulpt Development Team - - - Repository - - - CSCI-SHU-410-SE-Project/Deskulpt - - - - - Documentation - - - Website - - - - - + + + Deskulpt + + + A cross-platform desktop customization tool + + + + + Version + {__VERSION__} + + + Authors + The Deskulpt Development Team + + + Repository + + + + CSCI-SHU-410-SE-Project/Deskulpt + + + + + + Homepage + + + csci-shu-410-se-project.github.io/Deskulpt + + + + + + ); }); diff --git a/src/manager/components/ExternalCopyLink.tsx b/src/manager/components/ExternalCopyLink.tsx new file mode 100644 index 00000000..1715c51d --- /dev/null +++ b/src/manager/components/ExternalCopyLink.tsx @@ -0,0 +1,43 @@ +import { Flex, FlexProps, IconButton, Link, LinkProps } from "@radix-ui/themes"; +import { RxCopy } from "react-icons/rx"; +import { writeText } from "@tauri-apps/plugin-clipboard-manager"; +import { toast } from "sonner"; +import { useCallback } from "react"; + +interface ExternalCopyLinkProps extends LinkProps { + gap?: FlexProps["gap"]; +} + +const ExternalCopyLink = ({ + gap = "2", + children, + ...linkProps +}: ExternalCopyLinkProps) => { + const handleCopy = useCallback(() => { + if (linkProps.href !== undefined) { + writeText(linkProps.href).then(() => + toast.success("Copied to clipboard."), + ); + } + }, [linkProps.href]); + + return ( + + + {children} + + {linkProps.href !== undefined && ( + + + + )} + + ); +}; + +export default ExternalCopyLink; diff --git a/src/manager/components/Widgets/Config.tsx b/src/manager/components/Widgets/Config.tsx index 711b6ccd..b4b4b2d5 100644 --- a/src/manager/components/Widgets/Config.tsx +++ b/src/manager/components/Widgets/Config.tsx @@ -17,7 +17,6 @@ const Config = memo(({ id }: ConfigProps) => { {config.type === WidgetConfigType.VALID ? ( { return (