Skip to content

Commit 4d00d00

Browse files
committed
Docs: Improved docs with copy code component
1 parent 0f7be7f commit 4d00d00

File tree

4 files changed

+20
-32
lines changed

4 files changed

+20
-32
lines changed

docs/app/docs/contributing/contributing-to-rad-ui/page.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Code from "@radui/ui/Code"
55
import Button from "@radui/ui/Button"
66

77
import StarButton from "./StarButton"
8+
import CodeWithCopy from "@/components/CodeWithCopy"
89

910

1011

@@ -61,31 +62,31 @@ const ContributingToRadUI = () => {
6162
</Text>
6263
<div className='space-y-4 mt-5'>
6364
<Text>
64-
For Fixes : <Code>git commit -m "Fix: {SAMPLE_COMMIT_MESSAGE}"</Code>
65+
For Fixes : <CodeWithCopy code={`git commit -m "Fix: ${SAMPLE_COMMIT_MESSAGE}`} />
6566
</Text>
6667
<Text>
67-
For Features : <Code>git commit -m "Feature: {SAMPLE_COMMIT_MESSAGE}"</Code>
68+
For Features : <CodeWithCopy code={`git commit -m "Feature: ${SAMPLE_COMMIT_MESSAGE}`} />
6869
</Text>
6970
<Text>
70-
For Documentation : <Code>git commit -m "Docs: {SAMPLE_COMMIT_MESSAGE}"</Code>
71+
For Documentation : <CodeWithCopy code={`git commit -m "Docs: ${SAMPLE_COMMIT_MESSAGE}"`} />
7172
</Text>
7273
<Text>
73-
For Refactoring : <Code>git commit -m "Refactor: {SAMPLE_COMMIT_MESSAGE}"</Code>
74+
For Refactoring : <CodeWithCopy code={`git commit -m "Refactor: ${SAMPLE_COMMIT_MESSAGE}"`} />
7475
</Text>
7576
<Text>
76-
For Chore : <Code>git commit -m "Chore: {SAMPLE_COMMIT_MESSAGE}"</Code>
77+
For Chore : <CodeWithCopy code={`git commit -m "Chore: ${SAMPLE_COMMIT_MESSAGE}"`} />
7778
</Text>
7879
<Text>
79-
For Style : <Code>git commit -m "Style: {SAMPLE_COMMIT_MESSAGE}"</Code>
80+
For Style : <CodeWithCopy code={`git commit -m "Style: ${SAMPLE_COMMIT_MESSAGE}"`} />
8081
</Text>
8182
<Text>
82-
For Performance : <Code>git commit -m "Performance: {SAMPLE_COMMIT_MESSAGE}"</Code>
83+
For Performance : <CodeWithCopy code={`git commit -m "Performance: ${SAMPLE_COMMIT_MESSAGE}"`} />
8384
</Text>
8485
<Text>
85-
For Test : <Code>git commit -m "Test: {SAMPLE_COMMIT_MESSAGE}"</Code>
86+
For Test : <CodeWithCopy code={`git commit -m "Test: ${SAMPLE_COMMIT_MESSAGE}"`} />
8687
</Text>
8788
<Text>
88-
For CI : <Code>git commit -m "CI: {SAMPLE_COMMIT_MESSAGE}"</Code>
89+
For CI : <CodeWithCopy code={`git commit -m "CI: ${SAMPLE_COMMIT_MESSAGE}"`} />
8990
</Text>
9091
</div>
9192
</Documentation.Section>

docs/app/docs/contributing/setting-up-dev-environment/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Link from "@radui/ui/Link"
33
import Code from "@radui/ui/Code"
44
import Em from "@radui/ui/Em"
55
import Strong from "@radui/ui/Strong"
6-
6+
import CodeWithCopy from "@/components/CodeWithCopy"
77

88
const PAGE_NAME = 'BEFORE_YOU_START'
99

@@ -24,7 +24,7 @@ const SettingUpDevEnvironment = () => {
2424
<Strong className="text-gray-1000">Clone the repository:</Strong> Clone your forked repository to your local machine.
2525
</li>
2626
<li>
27-
<Strong className="text-gray-1000">Install dependencies:</Strong> Run <Code>npm install</Code> in the root directory. We use npm to maintain consistency in our dependencies.
27+
<Strong className="text-gray-1000">Install dependencies:</Strong> Run <CodeWithCopy code={"npm install"} /> in the root directory. We use npm to maintain consistency in our dependencies.
2828
</li>
2929
</ul>
3030
</Documentation.Section>
@@ -56,7 +56,7 @@ const SettingUpDevEnvironment = () => {
5656
We use Storybook for component development and testing. You can explore our existing components and work-in-progress features in the WIP section. Storybook is essential for developing and testing new components.
5757
</Text>
5858
<Text className="mb-4 text-gray-1000 font-light">
59-
To start Storybook, run <Code>npm run sb</Code> in the root directory.
59+
To start Storybook, run <CodeWithCopy code={"npm run sb"} /> in the root directory.
6060
</Text>
6161
</Documentation.Section>
6262

@@ -65,10 +65,10 @@ const SettingUpDevEnvironment = () => {
6565
To work on the documentation website, you'll need to run the development server. This is necessary for updating existing documentation, adding new pages, or modifying components.
6666
</Text>
6767
<Text className="mb-4 text-gray-1000 font-light">
68-
First, navigate to the docs directory: <Code>cd docs</Code>
68+
First, navigate to the docs directory: <CodeWithCopy code={"cd docs"} />
6969
</Text>
7070
<Text className="mb-4 text-gray-1000 font-light">
71-
Then start the Next.js development server: <Code>npm run dev</Code>
71+
Then start the Next.js development server: <CodeWithCopy code={"npm run dev"} />
7272
</Text>
7373
</Documentation.Section>
7474
</Documentation>

docs/app/docs/first-steps/installation/page.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Heading from "@radui/ui/Heading"
55
import Link from "@radui/ui/Link"
66
import Code from "@radui/ui/Code"
77
import Copy from "@/components/Copy"
8-
8+
import CodeWithCopy from "@/components/CodeWithCopy"
99

1010
const PAGE_NAME = 'INSTALLATION'
1111
import SEO from "../../docsIndex"
@@ -24,23 +24,10 @@ const Introduction = () => {
2424
</Text>
2525

2626
<Text className="my-2 font-medium">Using Yarn</Text>
27-
<Code>
28-
<span className="flex items-center">
29-
<span className="mr-2">
30-
yarn add @radui/ui
31-
</span>
32-
<Copy content="yarn add @radui/ui" />
33-
</span>
34-
</Code>
27+
<CodeWithCopy code={`yarn add @radui/ui`} />
28+
3529
<Text className="mt-4 mb-1 font-medium">Using npm</Text>
36-
<Code>
37-
<span className="flex items-center">
38-
<span className="mr-2">
39-
npm install @radui/ui --save
40-
</span>
41-
<Copy content="npm install @radui/ui --save" />
42-
</span>
43-
</Code>
30+
<CodeWithCopy code={`npm install @radui/ui --save`} />
4431
</Documentation.Section>
4532
</Documentation>
4633

docs/components/CodeWithCopy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Tooltip from "@radui/ui/Tooltip";
55
const CodeWithCopy = ({ code }) => {
66
const copyContent = code
77
.replace(/\n{2,}/g, "\n") // Replace multiple newlines with single newline
8-
.trim();
8+
.trim(); // Remove leading/trailing whitespace
99

1010
return (
1111
<Code>

0 commit comments

Comments
 (0)