mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-30 22:49:27 +02:00
add license system and ui
This commit is contained in:
parent
80d76befc9
commit
4819f410e6
46 changed files with 2159 additions and 94 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue