mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-12 07:56:40 +00:00
add license system and ui
This commit is contained in:
@@ -4,20 +4,26 @@ import { useState, useRef } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Copy, Check } from "lucide-react";
|
||||
|
||||
type CopyTextBoxProps = {
|
||||
text?: string;
|
||||
displayText?: string;
|
||||
wrapText?: boolean;
|
||||
outline?: boolean;
|
||||
};
|
||||
|
||||
export default function CopyTextBox({
|
||||
text = "",
|
||||
displayText,
|
||||
wrapText = false,
|
||||
outline = true
|
||||
}) {
|
||||
}: CopyTextBoxProps) {
|
||||
const [isCopied, setIsCopied] = useState(false);
|
||||
const textRef = useRef<HTMLPreElement>(null);
|
||||
|
||||
const copyToClipboard = async () => {
|
||||
if (textRef.current) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(
|
||||
textRef.current.textContent || ""
|
||||
);
|
||||
await navigator.clipboard.writeText(text);
|
||||
setIsCopied(true);
|
||||
setTimeout(() => setIsCopied(false), 2000);
|
||||
} catch (err) {
|
||||
@@ -38,7 +44,7 @@ export default function CopyTextBox({
|
||||
: "overflow-x-auto"
|
||||
}`}
|
||||
>
|
||||
<code className="block w-full">{text}</code>
|
||||
<code className="block w-full">{displayText || text}</code>
|
||||
</pre>
|
||||
<Button
|
||||
variant="ghost"
|
||||
|
||||
Reference in New Issue
Block a user