Skip to content

Commit e20eac6

Browse files
committed
feat: add copy to clipboard icon
1 parent b953c60 commit e20eac6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

components/output-text.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1+
import { Clipboard } from 'lucide-react'
12
import { SkeletonCard } from './skeleton-card'
3+
import { Button } from './ui/button'
24

35
export default function OutputText({ text, isFetching }: { text: string | null, isFetching: boolean }) {
46
const sanitizedText = text?.replace(/<p.*?>|<\/p>/g, '')
57
if (isFetching) {
68
return <SkeletonCard />
9+
} else if (!sanitizedText) {
10+
return null
711
}
812
return (
913
<>
10-
<p className='leading-loose'>
11-
{sanitizedText}
12-
</p>
14+
<div className='relative flex flex-col gap-2'>
15+
<Button variant="outline" size="icon" className='self-end h-5 w-5'>
16+
<Clipboard />
17+
</Button>
18+
<p className='leading-loose'>{sanitizedText}</p>
19+
</div>
1320
</>
1421
)
1522
}

components/skeleton-card.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export function SkeletonCard() {
55
const isMobile = useIsMobile()
66
return (
77
<div className='flex flex-col gap-3'>
8+
<Skeleton className='h-5 w-5 self-end' />
89
<Skeleton className='h-4 w-[100%]' />
910
<Skeleton className='h-4 w-[100%]' />
1011
<Skeleton className='h-4 w-[100%]' />

0 commit comments

Comments
 (0)