-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
235 lines (209 loc) · 5.34 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import type { Theme } from '@emotion/react'
import merge from 'deepmerge'
import { AppColorScheme } from '../../components/color-mode-provider/context'
import colors from '../modules/colors'
import { MODES } from './modes'
import typography, { FONT_FAMILIES, FONT_SIZES, FONT_WEIGHTS, LETTER_SPACINGS, LINE_HEIGHTS } from './typography'
/* eslint-disable @typescript-eslint/ban-types */
// Some values comes from chakra-ui, a great UI library!
export enum KleeBreakpoint {
Tablet = 'tablet',
Desktop = 'desktop',
Wide = 'wide',
UltraWide = 'ultraWide',
}
export type Breakpoints = Record<KleeBreakpoint, string>
export interface Typography {
letterSpacings: typeof LETTER_SPACINGS
lineHeights: typeof LINE_HEIGHTS
fontWeights: typeof FONT_WEIGHTS
fonts: typeof FONT_FAMILIES
fontSizes: typeof FONT_SIZES
}
export interface KleeTheme extends Typography {
currentMode: AppColorScheme
breakpoints: string[]
space: typeof SPACING
sizes: typeof SPACING
mediaQueries: {
tablet: string
desktop: string
wide: string
ultraWide: string
}
colors: typeof colors
radii: typeof RADII
shadows: typeof SHADOWS
borders: typeof BORDERS
zIndices: typeof Z_INDICES
modes: typeof MODES
}
export const theme = <Props extends { theme: KleeTheme }>(props: Props) => props.theme
export const BR_TABLET = 720
export const BR_DESKTOP = 1024
export const BR_WIDE = 1800
export const BR_ULTRAWIDE = 2200
export const breakpoints: Breakpoints = {
tablet: `${BR_TABLET}px`,
desktop: `${BR_DESKTOP}px`,
wide: `${BR_WIDE}px`,
ultraWide: `${BR_ULTRAWIDE}px`,
}
export const SPACING = {
px: '1px',
0: '0',
1: '0.25rem',
2: '0.5rem',
3: '0.75rem',
4: '1rem',
5: '1.25rem',
6: '1.5rem',
7: '1.75rem',
8: '2rem',
9: '2.25rem',
10: '2.5rem',
11: '3rem',
12: '3.5rem',
13: '4rem',
14: '5rem',
15: '6rem',
16: '7rem',
17: '8rem',
18: '9rem',
19: '10rem',
20: '11rem',
21: '12rem',
22: '13rem',
23: '14rem',
24: '15rem',
25: '16rem',
26: '18rem',
27: '20rem',
28: '24rem',
29: '28rem',
30: '32rem',
31: '36rem',
32: '42rem',
33: '50rem',
34: '64rem',
35: '128rem',
} as const
export type ThemeSpacingValues = keyof typeof SPACING | (string & {}) | (number & {})
export const SHADOWS = {
xs: '0 0 0 1px rgba(0, 0, 0, 0.05)',
sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
base: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
'2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)',
outline: '0 0 0 3px rgba(66, 153, 225, 0.6)',
inner: 'inset 0 2px 4px 0 rgba(0,0,0,0.06)',
none: 'none',
'dark-lg': 'rgba(0, 0, 0, 0.1) 0px 0px 0px 1px, rgba(0, 0, 0, 0.2) 0px 5px 10px, rgba(0, 0, 0, 0.4) 0px 15px 40px',
} as const
export enum KleeShadow {
Xs = 'xs',
Sm = 'sm',
Base = 'base',
Md = 'md',
Lg = 'lg',
Xl = 'xl',
'2xl' = '2xl',
Outline = 'outline',
Inner = 'inner',
None = 'none',
DarkLg = 'dark-lg',
}
export type ThemeShadowsValues = keyof typeof SHADOWS | (string & {})
export const RADII = {
none: '0',
sm: '0.125rem',
base: '0.25rem',
md: '0.375rem',
lg: '0.5rem',
xl: '0.75rem',
'2xl': '1rem',
'3xl': '1.5rem',
full: '9999px',
} as const
export enum KleeRadius {
None = 'none',
Sm = 'sm',
Base = 'base',
Md = 'md',
Lg = 'lg',
Xl = 'xl',
Xxl = '2xl',
Xxxl = '3xl',
Full = 'full',
}
export type ThemeRadiiValues = keyof typeof RADII | (string & {}) | (number & {})
export const BORDERS = {
none: 'none',
xs: '1px solid',
sm: '2px solid',
md: '4px solid',
lg: '10px solid',
} as const
export enum KleeBorder {
None = 'none',
Xs = 'xs',
Sm = 'sm',
Md = 'md',
Lg = 'lg',
}
export type ThemeBordersValues = keyof typeof BORDERS | (string & {})
export const Z_INDICES = {
hide: -1,
auto: 'auto',
base: 0,
docked: 10,
dropdown: 1000,
sticky: 1100,
banner: 1200,
overlay: 1300,
modal: 1400,
popover: 1500,
toast: 1700,
tooltip: 1800,
} as const
export enum KleeZIndex {
Hide = 'hide',
Auto = 'auto',
Base = 'base',
Docked = 'docked',
Dropdown = 'dropdown',
Sticky = 'sticky',
Banner = 'banner',
Overlay = 'overlay',
Modal = 'modal',
Popover = 'popover',
Toast = 'toast',
Tooltip = 'tooltip',
}
export type ThemeZIndicesValues = keyof typeof Z_INDICES | (string & {}) | (number & {})
export const kleeTheme: Theme = {
currentMode: 'light',
...typography,
colors,
breakpoints: [breakpoints.tablet, breakpoints.desktop, breakpoints.wide, breakpoints.ultraWide],
mediaQueries: {
tablet: `@media screen and (min-width: ${breakpoints.tablet})`,
desktop: `@media screen and (min-width: ${breakpoints.desktop})`,
wide: `@media screen and (min-width: ${breakpoints.wide})`,
ultraWide: `@media screen and (min-width: ${breakpoints.ultraWide})`,
},
space: SPACING,
sizes: SPACING,
radii: RADII,
borders: BORDERS,
shadows: SHADOWS,
zIndices: Z_INDICES,
modes: MODES,
}
export const extendTheme = <T extends Record<any, any>>(
extendedTheme: T &
Omit<Partial<Record<keyof KleeTheme, unknown>>, 'modes'> &
Partial<Record<'modes', Partial<typeof MODES>>>,
): KleeTheme & T => merge.all([kleeTheme, extendedTheme]) as KleeTheme & T