diff --git a/app/components/Attribute.tsx b/app/components/Attribute.tsx index 10d8c1e..356c343 100644 --- a/app/components/Attribute.tsx +++ b/app/components/Attribute.tsx @@ -1,86 +1,83 @@ -import { Check, Copy, Info } from 'lucide-react'; -import cn from '~/utils/cn'; -import toast from '~/utils/toast'; -import Tooltip from './Tooltip'; +import { Check, Copy, Info } from "lucide-react"; + +import cn from "~/utils/cn"; +import toast from "~/utils/toast"; + +import Tooltip from "./Tooltip"; export interface AttributeProps { - name: string; - value: string; - tooltip?: string; - isCopyable?: boolean; + name: string; + value: string; + tooltip?: string; + isCopyable?: boolean; } -export default function Attribute({ - name, - value, - tooltip, - isCopyable, -}: AttributeProps) { - return ( -
-
- {name} - {tooltip ? ( - - - {tooltip} - - ) : undefined} -
-
- {isCopyable ? ( - - ) : ( -
- {value} -
- )} -
-
- ); + setTimeout(() => { + for (const svg of svgs) { + svg.toggleAttribute("data-copied", false); + } + }, 1000); + }} + > +
+ {value} +
+ {isCopyable ? ( +
+ + +
+ ) : undefined} + + ) : ( +
+ {value} +
+ )} + + + ); } diff --git a/app/components/Button.tsx b/app/components/Button.tsx index 0e8b150..7d51b37 100644 --- a/app/components/Button.tsx +++ b/app/components/Button.tsx @@ -1,43 +1,45 @@ -import React, { useRef } from 'react'; -import { type AriaButtonOptions, useButton } from 'react-aria'; -import cn from '~/utils/cn'; +import React, { useRef } from "react"; +import { type AriaButtonOptions, useButton } from "react-aria"; -export interface ButtonProps extends AriaButtonOptions<'button'> { - variant?: 'heavy' | 'light' | 'danger'; - className?: string; - children?: React.ReactNode; - ref?: React.RefObject; +import cn from "~/utils/cn"; + +export interface ButtonProps extends AriaButtonOptions<"button"> { + variant?: "heavy" | "light" | "danger"; + className?: string; + children?: React.ReactNode; + ref?: React.RefObject; } -export default function Button({ variant = 'light', ...props }: ButtonProps) { - // In case the button is used as a trigger ref - const ref = props.ref ?? useRef(null); - const { buttonProps } = useButton(props, ref); +export default function Button({ variant = "light", ...props }: ButtonProps) { + // In case the button is used as a trigger ref + const ref = props.ref ?? useRef(null); + const { buttonProps } = useButton(props, ref); - return ( - - ); + return ( + + ); } diff --git a/app/components/Card.tsx b/app/components/Card.tsx index b219d48..0d2e32f 100644 --- a/app/components/Card.tsx +++ b/app/components/Card.tsx @@ -1,28 +1,29 @@ -import React from 'react'; -import Text from '~/components/Text'; -import Title from '~/components/Title'; -import cn from '~/utils/cn'; +import React from "react"; + +import Text from "~/components/Text"; +import Title from "~/components/Title"; +import cn from "~/utils/cn"; interface Props extends React.HTMLProps { - variant?: 'raised' | 'flat'; + variant?: "raised" | "flat"; } -function Card({ variant = 'raised', ...props }: Props) { - return ( -
- {props.children} -
- ); +function Card({ variant = "raised", ...props }: Props) { + return ( +
+ {props.children} +
+ ); } export default Object.assign(Card, { Title, Text }); diff --git a/app/components/Chip.tsx b/app/components/Chip.tsx index f39283c..9289e72 100644 --- a/app/components/Chip.tsx +++ b/app/components/Chip.tsx @@ -1,32 +1,28 @@ -import React from 'react'; -import cn from '~/utils/cn'; +import React from "react"; + +import cn from "~/utils/cn"; export interface ChipProps { - text: string; - className?: string; - leftIcon?: React.ReactNode; - rightIcon?: React.ReactNode; + text: string; + className?: string; + leftIcon?: React.ReactNode; + rightIcon?: React.ReactNode; } -export default function Chip({ - text, - className, - leftIcon, - rightIcon, -}: ChipProps) { - return ( - - {leftIcon} - {text} - {rightIcon} - - ); +export default function Chip({ text, className, leftIcon, rightIcon }: ChipProps) { + return ( + + {leftIcon} + {text} + {rightIcon} + + ); } diff --git a/app/components/Code.tsx b/app/components/Code.tsx index ac7b53b..e713597 100644 --- a/app/components/Code.tsx +++ b/app/components/Code.tsx @@ -1,50 +1,51 @@ -import { Check, Copy } from 'lucide-react'; -import { HTMLProps } from 'react'; -import cn from '~/utils/cn'; -import toast from '~/utils/toast'; +import { Check, Copy } from "lucide-react"; +import { HTMLProps } from "react"; + +import cn from "~/utils/cn"; +import toast from "~/utils/toast"; export interface CodeProps extends HTMLProps { - isCopyable?: boolean; - children: string | string[] | number; + isCopyable?: boolean; + children: string | string[] | number; } export default function Code({ isCopyable, children, className }: CodeProps) { - return ( - - {children} - {isCopyable && ( - - )} - - ); + setTimeout(() => { + for (const svg of svgs) { + svg.toggleAttribute("data-copied", false); + } + }, 1000); + }} + type="button" + > + + + + )} + + ); } diff --git a/app/components/Dialog.tsx b/app/components/Dialog.tsx index 9eb4e78..158e8a0 100644 --- a/app/components/Dialog.tsx +++ b/app/components/Dialog.tsx @@ -1,194 +1,182 @@ -import React, { cloneElement, useEffect, useRef } from 'react'; +import React, { cloneElement, useEffect, useRef } from "react"; import { - type AriaDialogProps, - type AriaModalOverlayProps, - Overlay, - useDialog, - useModalOverlay, - useOverlayTrigger, -} from 'react-aria'; -import { Form, type HTMLFormMethod } from 'react-router'; + type AriaDialogProps, + type AriaModalOverlayProps, + Overlay, + useDialog, + useModalOverlay, + useOverlayTrigger, +} from "react-aria"; +import { Form, type HTMLFormMethod } from "react-router"; import { - type OverlayTriggerProps, - type OverlayTriggerState, - useOverlayTriggerState, -} from 'react-stately'; -import Button, { ButtonProps } from '~/components/Button'; -import Card from '~/components/Card'; -import IconButton, { IconButtonProps } from '~/components/IconButton'; -import Text from '~/components/Text'; -import Title from '~/components/Title'; -import cn from '~/utils/cn'; -import { useLiveData } from '~/utils/live-data'; + type OverlayTriggerProps, + type OverlayTriggerState, + useOverlayTriggerState, +} from "react-stately"; + +import Button, { ButtonProps } from "~/components/Button"; +import Card from "~/components/Card"; +import IconButton, { IconButtonProps } from "~/components/IconButton"; +import Text from "~/components/Text"; +import Title from "~/components/Title"; +import cn from "~/utils/cn"; +import { useLiveData } from "~/utils/live-data"; export interface DialogProps extends OverlayTriggerProps { - children: - | [ - React.ReactElement | React.ReactElement, - React.ReactElement, - ] - | React.ReactElement; + children: + | [ + React.ReactElement | React.ReactElement, + React.ReactElement, + ] + | React.ReactElement; } function Dialog(props: DialogProps) { - const { pause, resume } = useLiveData(); - const state = useOverlayTriggerState(props); - const { triggerProps, overlayProps } = useOverlayTrigger( - { - type: 'dialog', - }, - state, - ); + const { pause, resume } = useLiveData(); + const state = useOverlayTriggerState(props); + const { triggerProps, overlayProps } = useOverlayTrigger( + { + type: "dialog", + }, + state, + ); - useEffect(() => { - if (state.isOpen) { - pause(); - } else { - resume(); - } - }, [state.isOpen]); + useEffect(() => { + if (state.isOpen) { + pause(); + } else { + resume(); + } + }, [state.isOpen]); - if (Array.isArray(props.children)) { - const [button, panel] = props.children; - return ( - <> - {cloneElement(button, triggerProps)} - {state.isOpen && ( - - {cloneElement(panel, { - ...overlayProps, - close: () => state.close(), - })} - - )} - - ); - } + if (Array.isArray(props.children)) { + const [button, panel] = props.children; + return ( + <> + {cloneElement(button, triggerProps)} + {state.isOpen && ( + + {cloneElement(panel, { + ...overlayProps, + close: () => state.close(), + })} + + )} + + ); + } - return ( - - {cloneElement(props.children, { - ...overlayProps, - close: () => state.close(), - })} - - ); + return ( + + {cloneElement(props.children, { + ...overlayProps, + close: () => state.close(), + })} + + ); } export interface DialogPanelProps extends AriaDialogProps { - children: React.ReactNode; - variant?: 'normal' | 'destructive' | 'unactionable'; - onSubmit?: React.FormEventHandler; - method?: HTMLFormMethod; - isDisabled?: boolean; + children: React.ReactNode; + variant?: "normal" | "destructive" | "unactionable"; + onSubmit?: React.FormEventHandler; + method?: HTMLFormMethod; + isDisabled?: boolean; - // Anonymous (passed by parent) - close?: () => void; + // Anonymous (passed by parent) + close?: () => void; } function Panel(props: DialogPanelProps) { - const { - children, - onSubmit, - isDisabled, - close, - variant, - method = 'POST', - } = props; - const ref = useRef(null); - const { dialogProps } = useDialog( - { - ...props, - role: 'alertdialog', - }, - ref, - ); + const { children, onSubmit, isDisabled, close, variant, method = "POST" } = props; + const ref = useRef(null); + const { dialogProps } = useDialog( + { + ...props, + role: "alertdialog", + }, + ref, + ); - return ( -
{ - if (onSubmit) { - onSubmit(event); - } + return ( + { + if (onSubmit) { + onSubmit(event); + } - close?.(); - }} - ref={ref} - > - - {children} -
- {variant === 'unactionable' ? ( - - ) : ( - <> - - - - )} -
-
-
- ); + close?.(); + }} + ref={ref} + > + + {children} +
+ {variant === "unactionable" ? ( + + ) : ( + <> + + + + )} +
+
+ + ); } interface DModalProps extends AriaModalOverlayProps { - children: React.ReactNode; - state: OverlayTriggerState; + children: React.ReactNode; + state: OverlayTriggerState; } function DModal(props: DModalProps) { - const { children, state } = props; - const ref = useRef(null); - const { modalProps, underlayProps } = useModalOverlay(props, state, ref); + const { children, state } = props; + const ref = useRef(null); + const { modalProps, underlayProps } = useModalOverlay(props, state, ref); - if (!state.isOpen) { - return null; - } + if (!state.isOpen) { + return null; + } - return ( - -