|
1 | 1 | import type { VariantProps } from "class-variance-authority"; |
| 2 | + |
2 | 3 | import { Check, Copy } from "lucide-react"; |
3 | | -import { |
4 | | - type HTMLProps, |
5 | | - type ReactNode, |
6 | | - useCallback, |
7 | | - useEffect, |
8 | | - useState, |
9 | | -} from "react"; |
| 4 | +import { type HTMLProps, type ReactNode, useCallback, useEffect, useState } from "react"; |
10 | 5 | import CopyToClipboard from "react-copy-to-clipboard"; |
11 | 6 | import { useTranslation } from "react-i18next"; |
12 | 7 | import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter"; |
13 | 8 | import java from "react-syntax-highlighter/dist/esm/languages/prism/java"; |
14 | 9 | import materialDark from "react-syntax-highlighter/dist/esm/styles/prism/material-dark"; |
15 | 10 | import { toast } from "sonner"; |
| 11 | + |
16 | 12 | import { Button, type buttonVariants } from "@/components/ui/button"; |
17 | 13 | import { cn } from "@/lib/utils"; |
18 | 14 |
|
@@ -68,25 +64,21 @@ export default function CodeViewer({ |
68 | 64 | showLineNumbers = true, |
69 | 65 | wrapLongLines = true, |
70 | 66 | }: Readonly<CodeViewerProps>) { |
71 | | - const lineProps: lineTagPropsFunction | HTMLProps<HTMLElement> | undefined = |
72 | | - wrapLongLines |
73 | | - ? { style: { overflowWrap: "break-word", whiteSpace: "pre-wrap" } } |
74 | | - : undefined; |
| 67 | + const lineProps: lineTagPropsFunction | HTMLProps<HTMLElement> | undefined = wrapLongLines |
| 68 | + ? { style: { overflowWrap: "break-word", whiteSpace: "pre-wrap" } } |
| 69 | + : undefined; |
75 | 70 | return ( |
76 | 71 | <div className="rounded-lg border"> |
77 | 72 | <div |
78 | | - className={cn( |
79 | | - "flex items-center border-b p-2 justify-end", |
80 | | - header && "justify-between", |
81 | | - )} |
| 73 | + className={cn("flex items-center justify-end border-b p-2", header && "justify-between")} |
82 | 74 | > |
83 | 75 | {header} |
84 | 76 | <div className="flex items-center gap-2"> |
85 | 77 | {button} |
86 | 78 | <CopyButton value={code} variant="ghost" size="sm" /> |
87 | 79 | </div> |
88 | 80 | </div> |
89 | | - <div className="relative overflow-hidden text-xs wrap-all"> |
| 81 | + <div className="wrap-all relative overflow-hidden text-xs"> |
90 | 82 | <SyntaxHighlighter |
91 | 83 | language={language} |
92 | 84 | style={materialDark} |
|
0 commit comments