From 61a07068d52b11d4bbaa710d6abd0776e717fed0 Mon Sep 17 00:00:00 2001 From: Khairul Hidayat Date: Sat, 17 Aug 2024 01:00:17 +0700 Subject: [PATCH] feat: add copy button to code component --- src/components/ui/code.tsx | 22 ++++++++++++++----- .../components/connect-node-dialog.tsx | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/components/ui/code.tsx b/src/components/ui/code.tsx index b9ee210..c242f4a 100644 --- a/src/components/ui/code.tsx +++ b/src/components/ui/code.tsx @@ -1,17 +1,29 @@ -import { cn } from "@/lib/utils"; +import { cn, copyToClipboard } from "@/lib/utils"; import React from "react"; +import Button from "./button"; +import { Copy } from "lucide-react"; -type Props = React.ComponentPropsWithoutRef<"code">; +type Props = Omit, "children"> & { + children?: string; +}; -const Code = ({ className, ...props }: Props) => { +const Code = ({ className, children, ...props }: Props) => { return ( + > + {children} +