import { BiCopy } from 'react-icons/bi'; import LoaderButton from './primitives/LoaderButton'; import clsx from 'clsx/lite'; import { toastSuccess } from '@/toast'; import { ComponentProps } from 'react'; import { useAppText } from '@/i18n/state/client'; export default function CopyButton({ label, text, subtle, iconSize = 15, className, ...props }: { label: string text?: string, subtle?: boolean iconSize?: number className?: string } & ComponentProps) { const appText = useAppText(); return ( } className={clsx( subtle && 'text-gray-300 dark:text-gray-700', className, )} onClick={text ? () => { navigator.clipboard.writeText(text); toastSuccess(appText.misc.copyPhrase(label)); } : undefined} styleAs="link" disabled={!text} /> ); }