Skip to content

Commit 062eccd

Browse files
authored
Merge pull request #23 from AlSirang/fix/merge-typography-components
Consolidate Heading Components into a Single Typography Component
2 parents ceb8cdb + e9ab27b commit 062eccd

File tree

25 files changed

+3238
-4024
lines changed

25 files changed

+3238
-4024
lines changed

app/(docs)/docs/[[...slug]]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { allDocs } from "contentlayer/generated";
33
import { notFound } from "next/navigation";
44
import { format } from "date-fns";
55
import MDX from "@/components/MDX";
6-
import { H2 } from "@/packages/ui";
6+
import { Text } from "@/packages/ui";
77
import { Metadata } from "next";
88

99
interface IProps {
@@ -46,7 +46,7 @@ export default function page({ params }: IProps) {
4646
return (
4747
<div className="space-y-12 py-8">
4848
<div className="border-b border-black pb-4">
49-
<H2>{doc.title}</H2>
49+
<Text as="h2">{doc.title}</Text>
5050
<p className="text-lg text-muted">{doc.description}</p>
5151
</div>
5252
<div>

app/(marketing)/page.tsx

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import {
33
Badge,
44
BasicCard,
55
Button,
6-
H1,
7-
H2,
8-
H3,
9-
H4,
6+
Text,
107
Input,
118
Textarea,
129
} from "@/packages/ui";
@@ -20,8 +17,10 @@ export default function Home() {
2017
<main className="space-y-36">
2118
<section className="container max-w-6xl mx-auto px-4 lg:px-0 mt-36 text-gray-900 flex justify-center items-center">
2219
<div className="text-center lg:text-left w-full lg:w-2/3">
23-
<H1>Make your projects</H1>
24-
<H1 className="text-outlined">stand out!</H1>
20+
<Text as="h1">Make your projects</Text>
21+
<Text as="h1" className="text-outlined">
22+
stand out!
23+
</Text>
2524

2625
<p className="text-lg text-muted mb-8 mt-4">
2726
Retro styled component library for modern web apps. Comes with 20+
@@ -60,53 +59,53 @@ export default function Home() {
6059
</section>
6160

6261
<section className="container max-w-6xl mx-auto px-4 lg:px-0">
63-
<H2 className="mb-16 text-center">
62+
<Text as="h2" className="mb-16 text-center">
6463
Our components look both old school and modern! ✨
65-
</H2>
64+
</Text>
6665

6766
<div className="grid gap-4 grid-cols-2 lg:grid-cols-4 mb-8">
6867
<div className="space-y-4">
69-
<H4>Button</H4>
68+
<Text as="h4">Button</Text>
7069
<Button>Click Me</Button>
7170
</div>
7271
<div className="space-y-4">
73-
<H4>Badge</H4>
72+
<Text as="h4">Badge</Text>
7473
<div className="flex flex-wrap space-y-2 lg:space-y-0 space-x-2">
7574
<Badge>Default Badge</Badge>
7675
<Badge variant="error">Error Badge</Badge>
7776
</div>
7877
</div>
7978
<div className="space-y-4">
80-
<H4>Avatar</H4>
79+
<Text as="h4">Avatar</Text>
8180
<Avatar />
8281
</div>
8382
<div className="space-y-4">
84-
<H4>Input</H4>
83+
<Text as="h4">Input</Text>
8584
<Input />
8685
</div>
8786
</div>
8887
<div className="grid gap-8 grid-cols-1 lg:grid-cols-3">
8988
<div className="space-y-4">
90-
<H4>Textarea</H4>
89+
<Text as="h4">Textarea</Text>
9190
<Textarea />
9291
</div>
9392
<div className="space-y-4">
94-
<H4>Basic Card</H4>
93+
<Text as="h4">Basic Card</Text>
9594
<BasicCard />
9695
</div>
9796
<div className="space-y-4">
98-
<H4>Accordion</H4>
97+
<Text as="h4">Accordion</Text>
9998
<AccordionStyleDefault />
10099
</div>
101100
</div>
102101
</section>
103102

104103
<section className="container max-w-6xl mx-auto px-4 lg:px-0">
105-
<H2 className="mb-16 text-center">
104+
<Text as="h2" className="mb-16 text-center">
106105
And NO! We didn&apos;t just copy Gumroad!
107106
<br />
108107
Inspired, if you will... 💅
109-
</H2>
108+
</Text>
110109

111110
<div className="grid grid-cols-1 lg:grid-cols-3 items-center">
112111
<Image
@@ -115,11 +114,17 @@ export default function Home() {
115114
width={300}
116115
height={500}
117116
/>
118-
<H3 className="lg:hidden mt-2 mb-12">👆 RetroUI Card</H3>
117+
<Text as="h3" className="lg:hidden mt-2 mb-12">
118+
👆 RetroUI Card
119+
</Text>
119120

120121
<div className="hidden lg:block space-y-4">
121-
<H2 className="text-left">👈 RetroUI Card</H2>
122-
<H2 className="text-right">Gumroad&apos;s Card 👉</H2>
122+
<Text as="h2" className="text-left">
123+
👈 RetroUI Card
124+
</Text>
125+
<Text as="h2" className="text-right">
126+
Gumroad&apos;s Card 👉
127+
</Text>
123128
</div>
124129
<Image
125130
src="/images/gumroad_product_card.png"
@@ -128,14 +133,16 @@ export default function Home() {
128133
width={300}
129134
height={600}
130135
/>
131-
<H3 className="lg:hidden mt-2">👆 Gumroad&apos;s Card</H3>
136+
<Text as="h3" className="lg:hidden mt-2">
137+
👆 Gumroad&apos;s Card
138+
</Text>
132139
</div>
133140
</section>
134141

135142
<section className="container max-w-6xl mx-auto border-2 bg-primary-400 border-black py-16 px-4 lg:p-16">
136-
<H2 className="mb-8 text-center">
143+
<Text as="h2" className="mb-8 text-center">
137144
And did I mention it&apos;s Free and Open Source?
138-
</H2>
145+
</Text>
139146
<div className="flex flex-col lg:flex-row items-center justify-center space-y-4 lg:space-y-0 lg:space-x-4">
140147
<Link
141148
href="https://github.com/Logging-Stuff/retroui"

components/JoinNewsletter.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
"use client"
1+
"use client";
22

3-
import { Button, H2, Input } from "@/packages/ui";
3+
import { Button, Text, Input } from "@/packages/ui";
44
import { useState } from "react";
55

66
const INIT = "INIT";
@@ -150,7 +150,7 @@ export function JoinNewsletter() {
150150
return (
151151
<div className="w-full max-w-6xl mx-auto py-16 px-4 border-2 border-black">
152152
<div className="flex flex-col justify-center items-center text-center">
153-
<H2>Join Our Newsletter</H2>
153+
<Text as="h2">Join Our Newsletter</Text>
154154
<p className="text-lg text-muted mb-8">
155155
Get notified about latest updates and new launches.
156156
</p>

components/MDX.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { H1, H2, H3, H4, H5, H6 } from "@/packages/ui";
3+
import { Text } from "@/packages/ui";
44
import { useMDXComponent } from "next-contentlayer/hooks";
55
import React, { HTMLAttributes } from "react";
66
import { ComponentShowcase } from "./ComponentShowcase";
@@ -9,18 +9,20 @@ import { ComponentSource } from "./ComponentSource";
99
import { CodeBlock } from "./CodeBlock";
1010

1111
const components = {
12-
h1: H1,
12+
h1: (props: HTMLAttributes<HTMLHeadingElement>) => (
13+
<Text as="h1" {...props} />
14+
),
1315
h2: (props: HTMLAttributes<HTMLHeadingElement>) => (
14-
<H2 className="border-b lg:text-3xl pb-1 mb-6" {...props} />
16+
<Text as="h2" className="border-b lg:text-3xl pb-1 mb-6" {...props} />
1517
),
1618
h3: (props: HTMLAttributes<HTMLHeadingElement>) => (
17-
<H3 className="mb-4" {...props} />
19+
<Text as="h3" className="mb-4" {...props} />
1820
),
1921
h4: (props: HTMLAttributes<HTMLHeadingElement>) => (
20-
<H4 className="mb-2" {...props} />
22+
<Text as="h4" className="mb-2" {...props} />
2123
),
22-
h5: H5,
23-
h6: H6,
24+
h5: (props: HTMLAttributes<HTMLHeadElement>) => <Text as="h5" {...props} />,
25+
h6: (props: HTMLAttributes<HTMLHeadElement>) => <Text as="h6" {...props} />,
2426
pre: CodeBlock,
2527
code: ({
2628
className,

components/SideNav.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { navConfig } from "@/config/navigation";
2-
import { H6 } from "@/packages/ui";
2+
import { Text } from "@/packages/ui";
33
import Link from "next/link";
44

55
export default function SideNav() {
@@ -10,7 +10,7 @@ export default function SideNav() {
1010
<nav className="flex flex-col items-start pr-6 space-y-4">
1111
{navConfig.sideNavItems.map((item) => (
1212
<div key={item.title}>
13-
<H6>{item.title}</H6>
13+
<Text as="h6">{item.title}</Text>
1414
<div className="flex flex-col space-y-2">
1515
{item.children.map((child) => (
1616
<Link key={child.title} href={child.href}>

config/components.ts

Lines changed: 8 additions & 4 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+
text: {
22+
name: "text",
23+
filePath: "packages/ui/Text/Text.tsx",
24+
},
2125
},
2226
examples: {
2327
"accordion-style-default": {
@@ -103,10 +107,10 @@ export const componentConfig = {
103107
() => import("@/preview/components/textarea-style-default")
104108
),
105109
},
106-
"typography-headings": {
107-
name: "typography-headings",
108-
filePath: "preview/components/typography-headings.tsx",
109-
preview: lazy(() => import("@/preview/components/typography-headings")),
110+
"text-headings": {
111+
name: "text-headings",
112+
filePath: "preview/components/text-headings.tsx",
113+
preview: lazy(() => import("@/preview/components/text-headings")),
110114
},
111115
"typography-p": {
112116
name: "typography-p",

config/navigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const navConfig: INavigationConfig = {
2424
{ title: "Input", href: `${componentsRoute}/input` },
2525
{ title: "Tab", href: `${componentsRoute}/tab` },
2626
{ title: "Textarea", href: `${componentsRoute}/textarea` },
27-
{ title: "Typography", href: `${componentsRoute}/typography` },
27+
{ title: "Text", href: `${componentsRoute}/text` },
2828
],
2929
},
3030
{

content/docs/components/text.mdx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Text
3+
description: Show your texts in different styles. 💅
4+
lastUpdated: 22 Oct, 2024
5+
---
6+
7+
## Headings
8+
9+
The `Text` 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 />
13+
14+
<ComponentShowcase name="text-headings" />
15+
<br />
16+
17+
#### Props
18+
19+
`className`: Additional CSS classes to customize the component's styling.
20+
21+
<br />
22+
23+
`as`: Determines the heading and text style. Default is `p`. Variants include:
24+
25+
- `"h1", "h2", "h3", "h4", "h5", "h6", "p"`
26+
27+
<br />
28+
<br />
29+
30+
## Installation
31+
32+
#### 1. Install dependencies:
33+
34+
```bash
35+
npm install class-variance-authority
36+
```
37+
38+
#### 2. Copy the code 👇 into your project:
39+
40+
<ComponentSource name="text" />
41+
42+
<br />
43+
<br />
44+
<br />
45+
46+
## Paragraph
47+
48+
<hr />
49+
<br />
50+
51+
<ComponentShowcase name="typography-p" />

content/docs/components/typography.mdx

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/ui/Cards/Card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { cn } from "@/lib/utils";
22
import { HTMLAttributes } from "react";
3-
import { H3 } from "../Typography";
3+
import { Text } from "../Text";
44
import { Content } from "next/font/google";
55

66
interface ICardProps extends HTMLAttributes<HTMLDivElement> {
@@ -29,7 +29,7 @@ const CardHeader = ({ className, ...props }: ICardProps) => {
2929
};
3030

3131
const CardTitle = ({ className, ...props }: ICardProps) => {
32-
return <H3 className={cn("mb-2", className)} {...props} />;
32+
return <Text as="h3" className={cn("mb-2", className)} {...props} />;
3333
};
3434

3535
const CardDescription = ({ className, ...props }: ICardProps) => (

0 commit comments

Comments
 (0)