Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeyens committed Oct 19, 2024
1 parent 7390521 commit 8d934e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
4 changes: 0 additions & 4 deletions apps/www/src/components/code-block-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export function CodeBlockWrapper({
}: CodeBlockProps) {
const [isOpened, setIsOpened] = React.useState(open);

React.useEffect(() => {
setIsOpened(open);
}, [open]);

return (
<Collapsible open={isOpened} onOpenChange={setIsOpened}>
<div className={cn('relative overflow-hidden', className)} {...props}>
Expand Down
7 changes: 3 additions & 4 deletions apps/www/src/components/component-source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function ComponentSource({
}: ComponentSourceProps) {
const displaySrc = title ?? props.src?.split('/').pop() ?? name + '.tsx';
const { copyToClipboard } = useCopyToClipboard();
const [open, setOpen] = React.useState(false);

return (
<div className="mb-6 mt-4">
Expand All @@ -36,8 +35,9 @@ export function ComponentSource({
variant="ghost"
className="mb-1 w-fit select-auto px-4 py-1 text-sm font-medium text-foreground"
onClick={() => {
copyToClipboard(displaySrc);
setOpen((prev) => !prev);
copyToClipboard(displaySrc, {
tooltip: 'Copied to clipboard',
});
}}
>
{displaySrc}
Expand All @@ -46,7 +46,6 @@ export function ComponentSource({

<CodeBlockWrapper
className={cn('overflow-hidden rounded-md', className)}
open={open}
expandButtonTitle="Expand"
{...props}
>
Expand Down

0 comments on commit 8d934e5

Please sign in to comment.