import { memo, useCallback } from 'react'; import { PiCopySimpleBold, PiCheckBold } from 'react-icons/pi'; import { Flex } from '@/shared/ui/Flex'; import { Text } from '@/shared/ui/Text'; import { useToggleState } from '@/shared/hooks'; import { Box, FlexItem } from '@/shared/ui'; import { cn } from '@/shared/libs'; interface CodeLineProps { value: string; isStorySection?: boolean; } export const CodeLine = memo(({ value, isStorySection }: CodeLineProps) => { const [copied, toggleCopied] = useToggleState(); const onCopy = useCallback(async () => { try { await navigator.clipboard.writeText(value); } catch { const ta = document.createElement('textarea'); ta.value = value; document.body.appendChild(ta); ta.select(); document.execCommand('copy'); document.body.removeChild(ta); } toggleCopied(); window.setTimeout(() => toggleCopied(), 1200); }, [value, toggleCopied]); return ( {value} ); });