Skip to content

Commit ac3105f

Browse files
committed
docs: add styles page
1 parent f47c699 commit ac3105f

16 files changed

+348
-136
lines changed

content/docs/installation.mdx

+15-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ description: How to install dependencies and structure your app.
99

1010
<Step>Create a project</Step>
1111

12+
Start by creating a new Next.js project using `create-next-app`:
13+
1214
```bash
1315
npx create-next-app@latest my-app --typescript --tailwind --eslint
1416
```
@@ -100,6 +102,8 @@ export default config;
100102

101103
<Step>Update `globals.css`</Step>
102104

105+
Add the following code to the `globals.css` file:
106+
103107
```css
104108
@tailwind base;
105109
@tailwind components;
@@ -170,6 +174,8 @@ npm i clsx class-variance-authority tailwind-merge
170174

171175
<Step>Add `utils/classes.ts`</Step>
172176

177+
Add utilities for classnames:
178+
173179
```ts
174180
import { type ClassValue, clsx } from "clsx";
175181
import { twMerge } from "tailwind-merge";
@@ -183,6 +189,8 @@ export { cva, type VariantProps } from "class-variance-authority";
183189

184190
<Step>You're done.</Step>
185191

192+
You can now start adding components of your choice
193+
186194
</Steps>
187195

188196
## Vite
@@ -191,12 +199,16 @@ export { cva, type VariantProps } from "class-variance-authority";
191199

192200
<Step>Create project</Step>
193201

202+
Start by creating a new Vite project using the following command:
203+
194204
```bash
195205
npm create vite@latest
196206
```
197207

198208
<Step>Add Tailwind and its configuration</Step>
199209

210+
Install `tailwindcss` and its peer dependencies, then generate your `tailwind.config.js` and `postcss.config.js` files:
211+
200212
```bash
201213
npm install -D tailwindcss postcss autoprefixer
202214
```
@@ -207,6 +219,8 @@ npx tailwindcss init -p
207219

208220
<Step>Edit tsconfig.json file</Step>
209221

222+
Add the following code to the `tsconfig.json` file so your app can resolve paths without error
223+
210224
```json
211225
{
212226
"compilerOptions": {
@@ -222,7 +236,7 @@ npx tailwindcss init -p
222236

223237
<Step>Update vite.config.ts</Step>
224238

225-
Add the following code to the vite.config.ts so your app can resolve paths without error
239+
Add the following code to the `vite.config.ts`:
226240

227241
```bash
228242
npm i -D @types/node

content/docs/styles.mdx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Styles
3+
---
4+
5+
## Playground
6+
7+
Click the customize button on top left to change the styles of the components.
8+
9+
<ComponentPreview name="demos/components/core/all-components" centered={false} />

scripts/build-docs-config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ const docsConfig: DocsConfig = {
2626
title: "Installation",
2727
href: "/docs/installation",
2828
},
29+
{
30+
title: "Styles",
31+
href: "/docs/styles",
32+
},
2933
{
3034
title: "Changelog",
3135
href: "/docs/changelog",

src/autogenerated/previews.ts

+74-63
Large diffs are not rendered by default.

src/components/component-preview.tsx

+34-32
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,21 @@ import { Preview } from "./preview";
1212

1313
type PreviewsKeys = keyof typeof previews;
1414

15+
export interface ComponentPreviewProps {
16+
name: PreviewsKeys;
17+
centered?: boolean;
18+
className?: string;
19+
containerClassName?: string;
20+
aspect?: "default" | "page";
21+
}
22+
1523
export const ComponentPreview = ({
1624
name,
1725
centered = true,
1826
className,
27+
containerClassName,
1928
aspect = "default",
20-
}: {
21-
name: PreviewsKeys;
22-
centered?: boolean;
23-
className?: string;
24-
aspect?: "default" | "page";
25-
}) => {
29+
}: ComponentPreviewProps) => {
2630
const component = React.useMemo(() => {
2731
const Component = previews[name]?.component;
2832

@@ -47,31 +51,29 @@ export const ComponentPreview = ({
4751
}, [name]);
4852

4953
return (
50-
<div>
51-
<Tabs defaultValue="preview">
52-
<TabsList className="grid w-[200px] grid-cols-2 lg:w-[400px]">
53-
<TabsTrigger value="preview">Preview</TabsTrigger>
54-
<TabsTrigger value="code">Code</TabsTrigger>
55-
</TabsList>
56-
<TabsContent value="preview" className="rounded-md border">
57-
<Preview aspect={aspect} centered={centered} className={className}>
58-
{component}
59-
</Preview>
60-
</TabsContent>
61-
<TabsContent value="code" className="rounded border">
62-
<Code
63-
subProps={code.map((file) => ({
64-
title: code.length > 1 ? file.title : undefined,
65-
code: file.code,
66-
lang: "tsx",
67-
}))}
68-
style={{ marginTop: 0, marginBottom: 0 }}
69-
theme="github-dark-dimmed"
70-
codeClassName="text-xs min-h-[318px]"
71-
extensions={[tabs]}
72-
/>
73-
</TabsContent>
74-
</Tabs>
75-
</div>
54+
<Tabs defaultValue="preview" className={containerClassName}>
55+
<TabsList className="grid w-[200px] grid-cols-2 lg:w-[400px]">
56+
<TabsTrigger value="preview">Preview</TabsTrigger>
57+
<TabsTrigger value="code">Code</TabsTrigger>
58+
</TabsList>
59+
<TabsContent value="preview" className="rounded-md border">
60+
<Preview aspect={aspect} centered={centered} className={className}>
61+
{component}
62+
</Preview>
63+
</TabsContent>
64+
<TabsContent value="code" className="rounded border">
65+
<Code
66+
subProps={code.map((file) => ({
67+
title: code.length > 1 ? file.title : undefined,
68+
code: file.code,
69+
lang: "tsx",
70+
}))}
71+
style={{ marginTop: 0, marginBottom: 0 }}
72+
theme="github-dark-dimmed"
73+
codeClassName="text-xs min-h-[318px]"
74+
extensions={[tabs]}
75+
/>
76+
</TabsContent>
77+
</Tabs>
7678
);
7779
};

src/components/marketing/brands.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import { UseHooksLogo } from "@/assets/images/brands/usehooks";
99

1010
export const Brands = ({ className }: { className?: string }) => {
1111
return (
12-
<div className={cn("flex flex-wrap items-center justify-center gap-8 ", className)}>
12+
<div
13+
className={cn(
14+
"flex flex-wrap items-center justify-center gap-4 sm:gap-8 ",
15+
className
16+
)}
17+
>
1318
<TailwindLogo className="h-4 fill-muted-foreground md:h-6" />
1419
<ReactIcon className="h-4 fill-muted-foreground md:h-6" />
1520
<NextjsLogo className="h-4 fill-muted-foreground md:h-6" />

src/components/mdx/mdx-components.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import NavLink from "next/link";
33
import { Code } from "bright";
44
import { CodeTabs } from "@/components/code-highlighter/code-tabs";
55
import { preWrapper } from "@/components/code-highlighter/pre-wrapper-extension";
6+
import {
7+
ComponentPreview,
8+
type ComponentPreviewProps,
9+
} from "@/components/component-preview";
10+
import { ComponentSource } from "@/components/component-source";
611
import { DocsList, type DocsListProps } from "@/components/docs/docs-list";
12+
import { IconsExplorer } from "@/components/icons-explorer";
713
import { cn } from "@/lib/utils/classes";
8-
import { ComponentPreview } from "../component-preview";
9-
import { ComponentSource } from "../component-source";
10-
import { IconsExplorer } from "../icons-explorer";
1114

1215
export const Link = ({
1316
className,
@@ -176,7 +179,9 @@ export const components = {
176179
ComponentSource: ({ name, ...rest }: { name: string }) => (
177180
<ComponentSource name={name} className="my-2" {...rest} />
178181
),
179-
ComponentPreview,
182+
ComponentPreview: (props: ComponentPreviewProps) => (
183+
<ComponentPreview containerClassName="[&:not(:first-child)]:mt-4" {...props} />
184+
),
180185
IconsExplorer,
181186
CodeTabs,
182187
DocsList: (props: DocsListProps) => <DocsList {...props} className="mt-4" />,

src/components/preview.tsx

+17-12
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,30 @@ export const Preview = ({
2222
<div className="absolute left-4 top-4 z-50 flex items-center space-x-2">
2323
<CustomizeTheme />
2424
</div>
25-
<ScrollArea
26-
viewportProps={{
27-
className: cn({
28-
"min-h-[350px] max-h-[800px]": aspect === "default",
29-
}),
30-
}}
31-
>
32-
<ThemeWrapper fallback={<Skeleton className="h-[350px]" />}>
25+
<ThemeWrapper fallback={<Skeleton className="h-[350px]" />}>
26+
<ScrollArea
27+
viewportProps={{
28+
className: cn("bg-background", {
29+
"min-h-[350px] max-h-[800px]": aspect === "default",
30+
}),
31+
}}
32+
>
3333
<div
3434
className={cn("min-h-[350px] w-full", {
35-
"flex items-center justify-center bg-background px-8 py-8": centered,
35+
"flex items-center justify-center px-8 py-8": centered,
3636
})}
3737
>
38-
<div className={cn("flex w-full items-center justify-center", className)}>
38+
<div
39+
className={cn(
40+
"flex w-full items-center justify-center" && centered,
41+
className
42+
)}
43+
>
3944
{children}
4045
</div>
4146
</div>
42-
</ThemeWrapper>
43-
</ScrollArea>
47+
</ScrollArea>
48+
</ThemeWrapper>
4449
</div>
4550
);
4651
};

src/config/docs-config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const docsConfig: DocsConfig = {
1010
items: [
1111
{ title: "Introduction", href: "/docs" },
1212
{ title: "Installation", href: "/docs/installation" },
13+
{ title: "Styles", href: "/docs/styles" },
1314
{ title: "Changelog", href: "/docs/changelog" },
1415
],
1516
},

0 commit comments

Comments
 (0)