Skip to content

Commit d4f2d21

Browse files
committed
Move typography styles to a Tailwind plugin so they autocomplete
1 parent e9cb9a0 commit d4f2d21

File tree

2 files changed

+84
-103
lines changed

2 files changed

+84
-103
lines changed

src/app/typography.css

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

tailwind.config.ts

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { fontFamily } from "tailwindcss/defaultTheme"
22
import type { Config } from "tailwindcss"
33
import typography from "@tailwindcss/typography"
4+
import plugin from "tailwindcss/plugin"
45

56
const config: Config = {
67
content: ["./src/**/*.{js,ts,jsx,tsx,mdx}", "./theme.config.tsx"],
@@ -71,7 +72,89 @@ const config: Config = {
7172
},
7273
},
7374
},
74-
plugins: [typography],
75+
plugins: [
76+
typography,
77+
plugin(({ addUtilities }) => {
78+
const headingStyles = {
79+
".typography-d1, .typography-h1, .typography-h2, .typography-h3": {
80+
lineHeight: "1.2",
81+
},
82+
".typography-d1": {
83+
fontSize: "96px",
84+
"@screen lg": {
85+
fontSize: "48px",
86+
},
87+
},
88+
".typography-h1": {
89+
fontSize: "40px",
90+
"@screen lg": {
91+
fontSize: "72px",
92+
},
93+
},
94+
".typography-h2": {
95+
fontSize: "32px",
96+
"@screen md": {
97+
fontSize: "48px",
98+
},
99+
},
100+
".typography-h3": {
101+
fontSize: "24px",
102+
"@screen md": {
103+
fontSize: "32px",
104+
},
105+
},
106+
}
107+
108+
const bodyStyles = {
109+
".typography-body-lg, .typography-body-md, .typography-body-sm, .typography-body-xs":
110+
{
111+
lineHeight: "1.5",
112+
},
113+
".typography-body-lg": {
114+
fontSize: "16px",
115+
"@screen md": {
116+
fontSize: "20px",
117+
},
118+
},
119+
".typography-body-md": {
120+
fontSize: "14px",
121+
"@screen md": {
122+
fontSize: "16px",
123+
},
124+
},
125+
".typography-body-sm": {
126+
fontSize: "12px",
127+
"@screen md": {
128+
fontSize: "14px",
129+
},
130+
},
131+
".typography-body-xs": {
132+
fontSize: "10px",
133+
"@screen md": {
134+
fontSize: "12px",
135+
},
136+
},
137+
}
138+
139+
const specialStyles = {
140+
".typography-button, .typography-tagline": {
141+
fontSize: "16px",
142+
lineHeight: "1",
143+
},
144+
".typography-tagline": {
145+
textTransform: "uppercase",
146+
},
147+
".typography-menu": {
148+
fontFamily: "var(--font-mono)",
149+
fontSize: "14px",
150+
lineHeight: "1",
151+
textTransform: "uppercase",
152+
},
153+
}
154+
155+
addUtilities({ ...headingStyles, ...bodyStyles, ...specialStyles })
156+
}),
157+
],
75158
darkMode: ["class", 'html[class~="dark"]'],
76159
}
77160
export default config

0 commit comments

Comments
 (0)