Skip to content

Commit 1d9dd41

Browse files
committed
feat: add script to generate preview imports
1 parent f01aa57 commit 1d9dd41

32 files changed

+452
-22
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@
4343

4444
## About The Project
4545

46-
in 2024, shadcn/ui popularized the copy paste method instead of installing multiple dependencies that you can not control only via props.
46+
in 2024, shadcn/ui popularized the copy paste method instead of installing multiple dependencies that you can not control only via props.
4747
rCopy wants to extend this not only for core components but for any kind of components, hooks, icons, pages and more.
4848

4949
If you want to join this journey, <a href="https://discord.gg/DXpj5V2fU8">join our discord community</a>
5050

51-
52-
5351
### Built with
5452

5553
- Next.js (v14 with app dir) and React

content/hooks/use-continuous-retry.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
title: useContinuousRetry
33
description: Automates retries of a callback function until it succeeds with useContinuousRetry
44
---
5+
6+
<ComponentPreview name="hooks/use-continuous-retry" />
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

content/hooks/use-debounce.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function UseDebounceDemo() {
1111
const debouncedValue = useDebounce<string>(searchInput, 1000);
1212

1313
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
14-
setIsLoading(false)
14+
setIsLoading(false);
1515
setSearchInput(e.target.value);
1616
};
1717

@@ -30,7 +30,7 @@ export default function UseDebounceDemo() {
3030
return (
3131
<div className="relative w-52">
3232
{isLoading ? (
33-
<div className="absolute left-2 h-full flex items-center">
33+
<div className="absolute left-2 flex h-full items-center">
3434
<Loader2Icon
3535
size={18}
3636
className="pointer-events-none animate-spin text-muted-foreground"

content/hooks/use-fetch.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
title: useFetch
33
description: Fetch data with accurate states, caching, and no stale responses using useFetch.
44
---
5+
6+
<ComponentPreview name="hooks/use-fetch" />

content/hooks/use-fetch.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

content/hooks/use-intersection-observer.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
title: useIntersectionObserver
33
description: Track and manage the visibility of your DOM elements within the viewport with useIntersectionObserver.
44
---
5+
6+
<ComponentPreview name="hooks/use-intersection-observer" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

content/hooks/use-local-storage.mdx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
22
title: useLocalStorage
33
description: Store, retrieve, and synchronize data from the browser’s localStorage API with useLocalStorage
4-
---
4+
---
5+
6+
<ComponentPreview name="hooks/use-local-storage" />

content/hooks/use-local-storage.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

content/hooks/use-media-query.mdx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
22
title: useMediaQuery
33
description: Subscribe and respond to media query changes with useMediaQuery.
4-
---
4+
---
5+
6+
<ComponentPreview name="hooks/use-media-query" />

content/hooks/use-media-query.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

content/hooks/use-network-state.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
title: useNetworkState
33
description: Monitor and adapt to network conditions seamlessly with useNetworkState.
44
---
5+
6+
<ComponentPreview name="hooks/use-network-state" />

content/hooks/use-network-state.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

content/hooks/use-orientation.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
title: useOrientation
33
description: Manage and respond to changes in device orientation with useOrientation.
44
---
5+
6+
<ComponentPreview name="hooks/use-orientation" />

content/hooks/use-orientation.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
22
title: usePreferredLanguage
33
description: Adapt to user language preferences dynamically with usePreferredLanguage.
4-
---
4+
---
5+
6+
<ComponentPreview name="hooks/use-preferred-language" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

content/hooks/use-previous.mdx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
22
title: usePrevious
33
description: Track the previous value of a variable with usePrevious.
4-
---
4+
---
5+
6+
<ComponentPreview name="hooks/use-previous" />

content/hooks/use-previous.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

content/hooks/use-session-storage.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
title: useSessionStorage
33
description: Store, retrieve, and synchronize data from the browser’s session storage with useSessionStorage.
44
---
5+
6+
<ComponentPreview name="hooks/use-sesssion-storage" />

content/hooks/use-session-storage.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

content/hooks/use-visibility-change.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
title: useVisibilityChange
33
description: Track document visibility and respond to changes with useVisibilityChange.
44
---
5+
6+
<ComponentPreview name="hooks/use-visibility-change" />
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

content/hooks/use-window-size.mdx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
22
title: useWindowSize
33
description: Track the dimensions of the browser window with useWindowSize.
4-
---
4+
---
5+
6+
<ComponentPreview name="hooks/use-window-size" />

content/hooks/use-window-size.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Demo() {
2+
return <div>demo</div>;
3+
}

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"build": "next build",
8+
"build:preview-imports": "tsx ./scripts/build-preview-imports.ts",
89
"start": "next start",
910
"dev": "next dev",
1011
"typecheck": "tsc --noEmit",
@@ -60,6 +61,7 @@
6061
"superjson": "^2.2.1",
6162
"tailwind-merge": "^2.2.0",
6263
"tailwindcss-animate": "^1.0.7",
64+
"tsx": "^4.7.1",
6365
"use-debounce": "^10.0.0",
6466
"vfile": "^6.0.1",
6567
"vfile-matter": "^5.0.0",
@@ -83,6 +85,7 @@
8385
"prettier": "^3.1.0",
8486
"prettier-plugin-tailwindcss": "^0.5.7",
8587
"prisma": "^5.6.0",
88+
"rimraf": "^5.0.5",
8689
"tailwindcss": "^3.3.5",
8790
"typescript": "^5.1.6"
8891
},

0 commit comments

Comments
 (0)