Skip to content

Commit f96da94

Browse files
committed
add docs for typography component
1 parent 118dfe1 commit f96da94

File tree

5 files changed

+95
-16
lines changed

5 files changed

+95
-16
lines changed

config/components.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export const componentConfig = {
1818
name: "card",
1919
filePath: "packages/ui/Cards/Card.tsx",
2020
},
21+
typography: {
22+
name: "typography",
23+
filePath: "packages/ui/Typography/Typography.tsx",
24+
},
2125
},
2226
examples: {
2327
"accordion-style-default": {
@@ -103,6 +107,11 @@ export const componentConfig = {
103107
() => import("@/preview/components/textarea-style-default")
104108
),
105109
},
110+
"typography-examples": {
111+
name: "typography-examples",
112+
filePath: "preview/components/typography-examples.tsx",
113+
preview: lazy(() => import("@/preview/components/typography-examples")),
114+
},
106115
"typography-headings": {
107116
name: "typography-headings",
108117
filePath: "preview/components/typography-headings.tsx",
Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,62 @@
11
---
22
title: Typography
33
description: Show your texts in different styles. 💅
4-
lastUpdated: 7 Oct, 2024
4+
lastUpdated: 22 Oct, 2024
55
---
66

77
## Headings
8-
<hr/>
9-
<br/>
8+
9+
The `Typography` component is a versatile React component that provides various heading styles. It leverages class-variance-authority for managing variants and allows for the customization of heading elements.
10+
11+
<hr />
12+
<br />
1013

1114
<ComponentShowcase name="typography-headings" />
15+
<br />
16+
17+
#### Props
18+
19+
`className`: Additional CSS classes to customize the component's styling.
20+
21+
<br />
22+
23+
`component`: Specifies which heading element to render (default is `"h1"`).
24+
25+
<br />
26+
27+
`variant`: Determines the typography style. Default is `"h1"`. Variants include:
28+
29+
- `"h1", "h2", "h3", "h4", "h5", "h6"`
1230

13-
<br/>
14-
<br/>
15-
<br/>
31+
<br />
32+
<br />
33+
34+
## Installation
35+
36+
#### 1. Install dependencies:
37+
38+
```bash
39+
npm install class-variance-authority
40+
```
41+
42+
#### 2. Copy the code 👇 into your project:
43+
44+
<ComponentSource name="typography" />
45+
46+
<br />
47+
<br />
48+
## Examples
49+
50+
<ComponentShowcase name="typography-examples" />
51+
52+
<br />
53+
<br />
54+
<br />
1655

1756
## Paragraph
18-
<hr/>
19-
<br/>
57+
58+
<hr />
59+
<br />
2060

2161
<ComponentShowcase name="typography-p" />
62+
```

packages/ui/Typography/Typography.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { cn } from "@/lib/utils";
2-
import { type VariantProps, cva } from "class-variance-authority";
31
import type { HTMLAttributes } from "react";
2+
import { type VariantProps, cva } from "class-variance-authority";
3+
import { cn } from "@/lib/utils";
44

55
const typographyVariants = cva("font-head", {
66
variants: {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Typography } from "@/packages/ui";
2+
3+
export default function TypographyExamples() {
4+
return (
5+
<div className="space-y-4">
6+
<Typography variant="h3">
7+
Creating an `h1` Element with `h3` Styles.
8+
</Typography>
9+
<Typography variant="h5" component="h4">
10+
Creating an `h4` Element with `h5` Styles.
11+
</Typography>
12+
<Typography component="h6" variant="h6">
13+
Creating an `h6` Element with `h6` Styles.
14+
</Typography>
15+
</div>
16+
);
17+
}
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
import { Typography } from "@/packages/ui";
2+
13
export default function TypographyHeadings() {
24
return (
35
<div className="space-y-4">
4-
<h1 className="font-head text-5xl lg:text-6xl font-bold">This is H1</h1>
5-
<h2 className="font-head text-4xl font-semibold">This is H2</h2>
6-
<h3 className="font-head text-2xl font-semibold">This is H3</h3>
7-
<h4 className="font-head text-xl font-medium">This is H4</h4>
8-
<h5 className="font-head text-lg font-medium">This is H5</h5>
9-
<h6 className="font-head font-medium">This is H6</h6>
6+
<Typography>This is H1</Typography>
7+
<Typography variant="h2" component="h2">
8+
This is H2
9+
</Typography>
10+
<Typography variant="h3" component="h3">
11+
This is H3
12+
</Typography>
13+
<Typography variant="h4" component="h4">
14+
This is H4
15+
</Typography>
16+
<Typography variant="h5" component="h5">
17+
This is H5
18+
</Typography>
19+
<Typography variant="h6" component="h6">
20+
This is H6
21+
</Typography>
1022
</div>
1123
);
1224
}

0 commit comments

Comments
 (0)