diff --git a/src/components/Common/CodeBlock.tsx b/src/components/Common/CodeBlock.tsx index ea112f2..d48a699 100644 --- a/src/components/Common/CodeBlock.tsx +++ b/src/components/Common/CodeBlock.tsx @@ -1,6 +1,6 @@ -import { Tooltip } from "antd" -import { CheckIcon, ClipboardIcon } from "lucide-react" -import { FC, useState } from "react" +import { Tooltip, Modal } from "antd" +import { CheckIcon, ClipboardIcon, EyeIcon, Maximize2Icon } from "lucide-react" +import { FC, useState } from "react" import { useTranslation } from "react-i18next" import { Prism as SyntaxHighlighter } from "react-syntax-highlighter" import { coldarkDark } from "react-syntax-highlighter/dist/cjs/styles/prism" @@ -10,26 +10,47 @@ interface Props { value: string } -export const CodeBlock: FC =({ language, value }) => { +export const CodeBlock: FC = ({ language, value }) => { const [isBtnPressed, setIsBtnPressed] = useState(false) + const [previewVisible, setPreviewVisible] = useState(false) const { t } = useTranslation("common") + + const handleCopy = () => { + navigator.clipboard.writeText(value) + setIsBtnPressed(true) + setTimeout(() => { + setIsBtnPressed(false) + }, 4000) + } + + const handlePreview = () => { + setPreviewVisible(true) + } + + const handlePreviewClose = () => { + setPreviewVisible(false) + } + return ( <> -
+
{language}
+ {language.toLowerCase() === "html" && ( + + + + )}
+ {previewVisible && ( + +
+