|
1 |
| -import { DefaultTheme } from "styled-components"; |
| 1 | +type Color = { |
| 2 | + 25: string; |
| 3 | + 50: string; |
| 4 | + 100: string; |
| 5 | + 200: string; |
| 6 | + 300: string; |
| 7 | + 400: string; |
| 8 | + 500: string; |
| 9 | + 600: string; |
| 10 | + 700: string; |
| 11 | + 800: string; |
| 12 | + 900: string; |
| 13 | +}; |
| 14 | + |
| 15 | +type Font = { |
| 16 | + regular: string; |
| 17 | + medium: string; |
| 18 | + semibold: string; |
| 19 | +}; |
| 20 | + |
| 21 | +export type Theme = { |
| 22 | + color: { |
| 23 | + gray: Color; |
| 24 | + primary: Color; |
| 25 | + error: Color; |
| 26 | + warning: Color; |
| 27 | + success: Color; |
| 28 | + }; |
| 29 | + space: { |
| 30 | + 0: string; |
| 31 | + 1: string; |
| 32 | + 2: string; |
| 33 | + 3: string; |
| 34 | + 4: string; |
| 35 | + 5: string; |
| 36 | + 6: string; |
| 37 | + 8: string; |
| 38 | + 10: string; |
| 39 | + 12: string; |
| 40 | + 16: string; |
| 41 | + 20: string; |
| 42 | + 24: string; |
| 43 | + }; |
| 44 | + size: { |
| 45 | + headerHeight: string; |
| 46 | + }; |
| 47 | + breakpoint: { |
| 48 | + desktop: string; |
| 49 | + }; |
| 50 | + zIndex: { |
| 51 | + header: number; |
| 52 | + }; |
| 53 | + font: { |
| 54 | + text: { |
| 55 | + xs: Font; |
| 56 | + sm: Font; |
| 57 | + md: Font; |
| 58 | + }; |
| 59 | + display: { |
| 60 | + sm: Font; |
| 61 | + md: Font; |
| 62 | + }; |
| 63 | + }; |
| 64 | +}; |
2 | 65 |
|
3 | 66 | export const theme = {
|
4 | 67 | color: {
|
@@ -186,38 +249,37 @@ export const theme = {
|
186 | 249 | };
|
187 | 250 |
|
188 | 251 | export function color(
|
189 |
| - name: keyof DefaultTheme["color"], |
190 |
| - shade: keyof DefaultTheme["color"]["gray"] |
| 252 | + name: keyof Theme["color"], |
| 253 | + shade: keyof Theme["color"]["gray"] |
191 | 254 | ) {
|
192 |
| - return ({ theme }: { theme: DefaultTheme }) => theme.color[name][shade]; |
| 255 | + return ({ theme }: { theme: Theme }) => theme.color[name][shade]; |
193 | 256 | }
|
194 | 257 |
|
195 |
| -export function space(...names: Array<keyof DefaultTheme["space"]>) { |
196 |
| - return ({ theme }: { theme: DefaultTheme }) => { |
| 258 | +export function space(...names: Array<keyof Theme["space"]>) { |
| 259 | + return ({ theme }: { theme: Theme }) => { |
197 | 260 | const spaces = names.map((name) => theme.space[name]);
|
198 | 261 | return spaces.join(" ");
|
199 | 262 | };
|
200 | 263 | }
|
201 | 264 |
|
202 |
| -export function breakpoint(name: keyof DefaultTheme["breakpoint"]) { |
203 |
| - return ({ theme }: { theme: DefaultTheme }) => theme.breakpoint[name]; |
| 265 | +export function breakpoint(name: keyof Theme["breakpoint"]) { |
| 266 | + return ({ theme }: { theme: Theme }) => theme.breakpoint[name]; |
204 | 267 | }
|
205 | 268 |
|
206 |
| -export function zIndex(name: keyof DefaultTheme["zIndex"]) { |
207 |
| - return ({ theme }: { theme: DefaultTheme }) => theme.zIndex[name]; |
| 269 | +export function zIndex(name: keyof Theme["zIndex"]) { |
| 270 | + return ({ theme }: { theme: Theme }) => theme.zIndex[name]; |
208 | 271 | }
|
209 | 272 |
|
210 | 273 | export function textFont(
|
211 |
| - size: keyof DefaultTheme["font"]["text"], |
212 |
| - weight: keyof DefaultTheme["font"]["text"]["sm"] |
| 274 | + size: keyof Theme["font"]["text"], |
| 275 | + weight: keyof Theme["font"]["text"]["sm"] |
213 | 276 | ) {
|
214 |
| - return ({ theme }: { theme: DefaultTheme }) => theme.font.text[size][weight]; |
| 277 | + return ({ theme }: { theme: Theme }) => theme.font.text[size][weight]; |
215 | 278 | }
|
216 | 279 |
|
217 | 280 | export function displayFont(
|
218 |
| - size: keyof DefaultTheme["font"]["display"], |
219 |
| - weight: keyof DefaultTheme["font"]["display"]["sm"] |
| 281 | + size: keyof Theme["font"]["display"], |
| 282 | + weight: keyof Theme["font"]["display"]["sm"] |
220 | 283 | ) {
|
221 |
| - return ({ theme }: { theme: DefaultTheme }) => |
222 |
| - theme.font.display[size][weight]; |
| 284 | + return ({ theme }: { theme: Theme }) => theme.font.display[size][weight]; |
223 | 285 | }
|
0 commit comments