import { NestableWidget, UID } from "@prismicio/types-internal/lib/customtypes"; import React, { useState } from "react"; import { BiCopy } from "react-icons/bi"; import { BsCode } from "react-icons/bs"; import { MdCheck } from "react-icons/md"; import { Box, Button, Flex, Text, useThemeUI } from "theme-ui"; import Code from "@/legacy/components/CodeBlock"; const buttonIconStyle: React.CSSProperties = { position: "relative", top: "3px", }; export interface Item { key: string; value: NestableWidget | UID; } export type RenderHintBaseFN = (args: { item: Item }) => string; type CodeBlockProps = { code: string | null | undefined; lang?: string; }; const CodeBlock: React.FC = ({ code, lang }) => { const { theme } = useThemeUI(); const [isCopied, setIsCopied] = useState(false); const copy = (): void => { // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions code && void navigator.clipboard.writeText(code).then(() => { setIsCopied(true); setTimeout(() => { setIsCopied(false); }, 1200); }); }; // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions return code ? ( {code} ) : null; }; export default CodeBlock;