From 3cd28d21360099f806879b054fdea90115f86ee2 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Wed, 20 Nov 2024 18:01:20 -0500 Subject: [PATCH] feat: make the code snippets copyable --- app/components/Code.tsx | 47 ++++++++++++++++--- .../_data.machines._index/dialogs/new.tsx | 4 +- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/app/components/Code.tsx b/app/components/Code.tsx index 0d8fb60..d16d7a3 100644 --- a/app/components/Code.tsx +++ b/app/components/Code.tsx @@ -1,12 +1,45 @@ -import clsx from 'clsx' -import { type HTMLProps } from 'react' +import { useState, HTMLProps } from 'react' +import { CopyIcon, CheckIcon } from '@primer/octicons-react' -type Properties = HTMLProps +import { cn } from '~/utils/cn' +import { toast } from '~/components/Toaster' + +interface Props extends HTMLProps { + isCopyable?: boolean +} + +export default function Code(props: Props) { + const [isCopied, setIsCopied] = useState(false) -export default function Code(properties: Properties) { return ( - - {properties.children} - + <> + + {props.children} + + {props.isCopyable && ( + + )} + ) } diff --git a/app/routes/_data.machines._index/dialogs/new.tsx b/app/routes/_data.machines._index/dialogs/new.tsx index 429beba..635ad1b 100644 --- a/app/routes/_data.machines._index/dialogs/new.tsx +++ b/app/routes/_data.machines._index/dialogs/new.tsx @@ -50,10 +50,8 @@ export default function New(data: NewProps) { The machine key is given when you run {' '} - + tailscale up --login-server= - - {data.server} {' '}