Skip to content

Commit 7d3e4ef

Browse files
committed
πŸ‘Œ IMPROVE: InlineCopy overflow
1 parent ad84d4d commit 7d3e4ef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

β€Žapps/baseai.dev/src/components/mdx/InlineCodeCopy.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from '@heroicons/react/24/solid';
77
import { Button } from '../ui/button';
88
import { useCopyToClipboard } from '@/hooks/use-copy-to-clipboard';
9+
import cn from 'mxcn';
910

1011
export function InlineCopy({
1112
content,
@@ -15,6 +16,7 @@ export function InlineCopy({
1516
children: React.ReactNode;
1617
}) {
1718
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });
19+
const totalChars = content.length;
1820

1921
const onCopy = () => {
2022
navigator.clipboard.writeText(content);
@@ -24,7 +26,7 @@ export function InlineCopy({
2426

2527
return (
2628
<span className="inline-flex items-center gap-1 whitespace-nowrap">
27-
<code className='w-[90%] sm:w-full overflow-scroll'>{content}</code>
29+
<code className={cn(totalChars > 25 && 'w-[50%] sm:w-full overflow-scroll')}>{content}</code>
2830
<Button
2931
variant="ghost"
3032
className="h-4 w-4 p-0 focus:ring-0"

0 commit comments

Comments
Β (0)