mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-06-28 18:17:37 +00:00
* Update ScriptAccordion and ScriptItem components for improved styling * Add README.md for Proxmox VE Helper-Scripts Frontend * Remove testing dependencies and related test files from the frontend project * Update analytics URL in siteConfig to point to community-scripts.org * Refactor ESLint configuration to have one source of truth and run "npm lint" to apply new changes * Update lint script in package.json to remove npm * Add 'next' option to ESLint configuration for improved compatibility * Update package dependencies and versions in package.json and package-lock.json * Refactor theme provider import and enhance calendar component for dynamic icon rendering * rename sidebar, alerts and buttons * rename description and interfaces files * rename more files * change folder name * Refactor tooltip logic to improve updateable condition handling * Enhance CommandMenu to prevent duplicate scripts across categories * Remove test step from frontend CI/CD workflow
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
"use client";
|
|
import { CheckIcon, ClipboardIcon } from "lucide-react";
|
|
import { useEffect, useState } from "react";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
import { Card } from "./card";
|
|
|
|
export default function CodeCopyButton({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const [hasCopied, setHasCopied] = useState(false);
|
|
const isMobile = window.innerWidth <= 640;
|
|
|
|
useEffect(() => {
|
|
if (hasCopied) {
|
|
setTimeout(() => {
|
|
setHasCopied(false);
|
|
}, 2000);
|
|
}
|
|
}, [hasCopied]);
|
|
|
|
const handleCopy = (type: string, value: any) => {
|
|
navigator.clipboard.writeText(value);
|
|
|
|
setHasCopied(true);
|
|
|
|
// toast.success(`copied ${type} to clipboard`, {
|
|
// icon: <ClipboardCheck className="h-4 w-4" />,
|
|
// });
|
|
};
|
|
|
|
return (
|
|
<div className="mt-4 flex">
|
|
<Card className="flex items-center overflow-x-auto bg-primary-foreground pl-4">
|
|
<div className="overflow-x-auto whitespace-pre-wrap text-nowrap break-all pr-4 text-sm">
|
|
{!isMobile && children ? children : "Copy Config File Path"}
|
|
</div>
|
|
<div
|
|
className={cn(" right-0 cursor-pointer bg-muted px-3 py-4")}
|
|
onClick={() => handleCopy("install command", children)}
|
|
>
|
|
{hasCopied
|
|
? (
|
|
<CheckIcon className="h-4 w-4" />
|
|
)
|
|
: (
|
|
<ClipboardIcon className="h-4 w-4" />
|
|
)}
|
|
<span className="sr-only">Copy</span>
|
|
</div>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|