Skip to content

Commit

Permalink
cleanup debug modal
Browse files Browse the repository at this point in the history
  • Loading branch information
hzrd149 committed Nov 19, 2024
1 parent dbd724a commit bf6d243
Show file tree
Hide file tree
Showing 16 changed files with 413 additions and 196 deletions.
82 changes: 41 additions & 41 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import PostSettings from "./views/settings/post";
import AccountSettings from "./views/settings/accounts";
import ArticlesHomeView from "./views/articles";
import ArticleView from "./views/articles/article";
import WalletView from "./views/wallet";
const TracksView = lazy(() => import("./views/tracks"));
const UserTracksTab = lazy(() => import("./views/user/tracks"));
const UserVideosTab = lazy(() => import("./views/user/videos"));
Expand Down Expand Up @@ -336,6 +337,19 @@ const router = createHashRouter([
{ path: "", element: <NotificationsView /> },
],
},
{
path: "wallet",
children: [
{
path: "",
element: (
<RequireCurrentAccount>
<WalletView />
</RequireCurrentAccount>
),
},
],
},
{
path: "videos",
children: [
Expand Down
31 changes: 29 additions & 2 deletions src/components/copy-icon-button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import { IconButton, IconButtonProps, useToast } from "@chakra-ui/react";
import { Button, ButtonProps, IconButton, IconButtonProps, useToast } from "@chakra-ui/react";

import { CheckIcon, CopyToClipboardIcon } from "./icons";

Expand All @@ -8,7 +8,7 @@ type CopyIconButtonProps = Omit<IconButtonProps, "icon" | "value"> & {
icon?: IconButtonProps["icon"];
};

export const CopyIconButton = ({ value, icon, ...props }: CopyIconButtonProps) => {
export function CopyIconButton({ value, icon, ...props }: CopyIconButtonProps) {
const toast = useToast();
const [copied, setCopied] = useState(false);

Expand All @@ -27,4 +27,31 @@ export const CopyIconButton = ({ value, icon, ...props }: CopyIconButtonProps) =
{...props}
/>
);
}

type CopyButtonProps = Omit<ButtonProps, "icon" | "value"> & {
value: string | undefined | (() => string);
icon?: IconButtonProps["icon"];
};
export function CopyButton({ value, icon, children, ...props }: CopyButtonProps) {
const toast = useToast();
const [copied, setCopied] = useState(false);

return (
<Button
leftIcon={copied ? <CheckIcon boxSize="1.5em" /> : icon || <CopyToClipboardIcon boxSize="1.2em" />}
onClick={() => {
const v: string | undefined = typeof value === "function" ? value() : value;

if (v && navigator.clipboard && !copied) {
navigator.clipboard.writeText(v);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} else toast({ description: v, isClosable: true, duration: null });
}}
{...props}
>
{copied ? "Copied" : children}
</Button>
);
}
Loading

0 comments on commit bf6d243

Please sign in to comment.