MCPcopy Create free account
hub / github.com/ChrisAbdo/MotionVariants / AllVariants

Function AllVariants

components/usage/all-variants.tsx:17–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15import { useToast } from "@/components/ui/use-toast";
16
17export default function AllVariants() {
18 const { toast } = useToast();
19
20 const [copied, setCopied] = React.useState(false);
21
22 React.useEffect(() => {
23 if (copied) {
24 const timeout = setTimeout(() => {
25 setCopied(false);
26 }, 2000);
27 return () => clearTimeout(timeout);
28 }
29 }, [copied]);
30
31 return (
32 <Accordion type="single" collapsible className="w-full">
33 <AccordionItem value="item-1">
34 <AccordionTrigger>Variant Definitions</AccordionTrigger>
35 <AccordionContent>
36 <ScrollArea className="h-96 bg-primary-foreground rounded-md p-4">
37 {/* button that is absolute in the top right corner of the scrollarea */}
38 <Button
39 size="icon"
40 variant="outline"
41 className="group/button absolute right-4 top-1.5 overflow-hidden text-2xs font-medium backdrop-blur transition"
42 onClick={() => {
43 setCopied(true);
44 window.navigator.clipboard.writeText(DEFINITIONS_VARIANTS);
45 toast({
46 title: "Copied variant definitions to clipboard",
47 description: "Just paste it in your code!",
48 });
49 }}
50 >
51 {/* <ClipboardIcon className="w-4 h-4" /> */}
52 {copied ? (
53 <CheckIcon className="w-4 h-4" />
54 ) : (
55 <ClipboardIcon className="w-4 h-4" />
56 )}
57 </Button>
58 <pre>
59 <code className="grid gap-1 text-sm text-black dark:text-white [&_span]:h-4">
60 {DEFINITIONS_VARIANTS}
61 </code>
62 </pre>
63 </ScrollArea>
64 </AccordionContent>
65 </AccordionItem>
66 </Accordion>
67 );
68}

Callers

nothing calls this directly

Calls 2

useToastFunction · 0.90
toastFunction · 0.85

Tested by

no test coverage detected