Skip to content

Commit 4e80068

Browse files
committed
docs: improve copy-text-morph example + docs + add size properties
1 parent e604b90 commit 4e80068

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

apps/website/src/components/code-block/blocks/copy-text-morph.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { copyToClipboard } from "@/utils/copy";
2020

2121
interface CopyTextAnimatedProps extends ComponentProps<"button"> {
2222
content: string;
23-
iconSize?: number;
23+
size?: "xs" | "sm";
2424
}
2525

2626
export type TextMorphProps = {
@@ -94,6 +94,7 @@ export function TextMorph({
9494

9595
const CopyTextMorph = ({
9696
content,
97+
size = "sm",
9798
className,
9899
...props
99100
}: CopyTextAnimatedProps) => {
@@ -119,9 +120,11 @@ const CopyTextMorph = ({
119120
className={cn(
120121
"cursor-pointer",
121122
"transition-colors duration-200 ease-in-out",
122-
"text-xs text-neutral-700 dark:text-neutral-300 hover:text-neutral-950 dark:hover:text-neutral-50",
123+
"text-neutral-700 hover:text-neutral-950 dark:text-neutral-300 dark:hover:text-neutral-50",
123124
"rounded-md bg-neutral-300/60 px-1.5 py-1 dark:bg-neutral-700/60",
124125
"border border-transparent hover:border-neutral-400/60 dark:hover:border-neutral-600/60",
126+
size === "xs" && "text-xs",
127+
size === "sm" && "text-sm",
125128
isCopied && "text-neutral-950 dark:text-neutral-50",
126129
className,
127130
)}
Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
1-
import {
2-
CodeBlock,
3-
CodeBlockContent,
4-
CodeBlockGroup,
5-
CodeBlockHeader,
6-
CodeBlockIcon,
7-
} from "@/components/code-block/code-block";
8-
import { CodeblockShiki } from "@/components/code-block/client/shiki";
91
import { CopyTextMorph } from "@/components/code-block/blocks/copy-text-morph";
102

113
const code = `export default function Page() {
124
return <h1>Hello</h1>
135
}`;
146

157
const CopyMorphExample = () => {
16-
return (
17-
<CodeBlock>
18-
<CodeBlockHeader>
19-
<CodeBlockGroup>
20-
<CodeBlockIcon language="tsx" />
21-
<span>Copy with Text Morph</span>
22-
</CodeBlockGroup>
23-
<CopyTextMorph content={code} />
24-
</CodeBlockHeader>
25-
<CodeBlockContent>
26-
<CodeblockShiki language="tsx" code={code} />
27-
</CodeBlockContent>
28-
</CodeBlock>
29-
);
8+
return <CopyTextMorph content={code} />;
309
};
3110

3211
export default CopyMorphExample;

apps/website/src/docs/react/blocks/copy-text-morph.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: Copy with Text Morph
33
description: Copy Button with animated text using Motion-Primitives.
4-
category: [React, Motion, Shiki, Blocks]
4+
category: [React, Motion, Client, Blocks]
55
---
66

77
<ComponentPreview component="block-copy-text-morph" />
88

99
## Introduction
1010

11-
In this block, we'll create a copy button that not only copies text to the clipboard but also provides animated feedback using [Motion-Primitives](https://motion-primitives.com/) created by [ibelick](https://github.com/ibelick).
11+
In this block, we'll create a copy button with animated text using [Motion-Primitives](https://motion-primitives.com/) by [Julien Thibeaut](https://github.com/ibelick). The button will morph between "Copy" and "Copied" when clicked, providing visual feedback to the user.
1212

1313
## Installation
1414

@@ -74,3 +74,7 @@ const Example = () => {
7474
};
7575
export default Example;
7676
```
77+
78+
## Props
79+
80+
<ShowProps component="block-copy-text-morph" />

0 commit comments

Comments
 (0)