-
Notifications
You must be signed in to change notification settings - Fork 121
/
panda.config.ts
376 lines (360 loc) · 9.36 KB
/
panda.config.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
// https://panda-css.com/docs/references/config
import { defineConfig, defineGlobalStyles, defineKeyframes } from '@pandacss/dev'
import durationsConfig from './src/durations.config'
import anchorButtonRecipe from './src/recipes/anchorButton'
import bulletRecipe from './src/recipes/bullet'
import buttonRecipe from './src/recipes/button'
import childRecipe from './src/recipes/child'
import dropEndRecipe from './src/recipes/dropEnd'
import dropHoverRecipe from './src/recipes/dropHover'
import editableRecipe from './src/recipes/editable'
import extendTapRecipe from './src/recipes/extendTap'
import fadeTransitionRecipe from './src/recipes/fadeTransition'
import iconRecipe from './src/recipes/icon'
import invalidOptionRecipe from './src/recipes/invalidOption'
import linkRecipe from './src/recipes/link'
import modalRecipe from './src/recipes/modal'
import modalActionLinkRecipe from './src/recipes/modalActionLink'
import modalTextRecipe from './src/recipes/modalText'
import multilineRecipe from './src/recipes/multiline'
import slideTransitionRecipe from './src/recipes/slideTransition'
import textNoteRecipe from './src/recipes/textNote'
import thoughtRecipe from './src/recipes/thought'
import toolbarPointerEventsRecipe from './src/recipes/toolbarPointerEvents'
import tutorialBulletRecipe from './src/recipes/tutorialBullet'
import upperRightRecipe from './src/recipes/upperRight'
import convertColorsToPandaCSS from './src/util/convertColorsToPandaCSS'
import keyValueBy from './src/util/keyValueBy'
const { colorTokens, colorSemanticTokens } = convertColorsToPandaCSS()
type DurationToken = {
value: {
base: string
_test: string
}
}
/** Returns durations formatted for the PandaCSS config. */
const durationsReducer = (pv: Record<string, DurationToken>, [key, duration]: [string, number]) => {
pv[key] = {
value: {
base: `${duration}ms`,
_test: '0ms',
},
}
return pv
}
/**
* Generates zIndex value entries in descending order from [n...1].
* @example zIndexDescending(['a', 'b', 'c']) => { a: { value: 3 }, b: { value: 2 }, c: { value: 1 } }
*/
const zIndexDescending = (keys: string[]) => keyValueBy(keys.reverse(), (key, i) => ({ [key]: { value: i + 1 } }))
/** Add `ms` units to raw value. */
const durations = Object.entries(durationsConfig).reduce(durationsReducer, {})
const keyframes = defineKeyframes({
fademostlyin: {
from: {
opacity: 0,
},
to: {
opacity: 0.85,
},
},
fadein: {
from: {
opacity: 0,
},
to: {
opacity: 0.99,
},
},
pulse: {
from: {
opacity: 1,
},
to: {
opacity: 0.25,
},
},
pulseLight: {
from: {
opacity: 1,
},
to: {
opacity: 0.5,
},
},
preventAutoscroll: {
'0%': {
opacity: 0,
},
'100%': {
opacity: 1,
},
},
ripple_loader: {
'0%': {
top: '100%',
left: '100%',
width: '0',
height: '0',
opacity: 1,
},
'100%': {
top: '7.14%',
left: '7.14%',
width: '162.5%',
height: '162.5%',
opacity: 0,
},
},
ellipsis: {
to: {
width: '1.25em',
},
},
toblack: {
to: {
color: 'black',
fill: 'black',
},
},
towhite: {
to: {
color: 'white',
fill: 'white',
},
},
bobble: {
'0%': {
transform: 'translateX(-50%) translateY(0)',
},
'50%': {
transform: 'translateX(-50%) translateY(10px)',
},
'100%': {
transform: 'translateX(-50%) translateY(0)',
},
},
})
const globalCss = defineGlobalStyles({
'*': {
_mobile: {
_dragInProgress: {
userSelect: 'none',
},
},
},
'html, body, #root, #app': { height: '100%', fontSize: '16px' },
'body, textarea': {
fontWeight: 300,
fontFamily: "'Helvetica'",
lineHeight: 1.25,
},
/* Disables pull-to-refresh but allows overscroll glow effects. */
body: { overscrollBehaviorY: 'contain', color: 'fg', backgroundColor: 'bg' },
button: { fontSize: '1.2em' },
a: {
cursor: 'pointer',
textDecorationLine: 'underline',
outline: 'none',
color: 'link',
fontWeight: 400,
userSelect: 'none',
},
h1: {
fontSize: '32px',
fontWeight: 400,
marginTop: '0',
marginBottom: '12px',
},
h2: {
fontSize: '100%',
fontWeight: 300,
borderBottom: 'solid 1px {colors.fg}',
marginBottom: '25px',
},
ul: { marginLeft: '1.5em', paddingLeft: '0' },
'ul ul': { marginLeft: '1.2em' },
li: { listStyle: 'none' },
input: {
color: 'fg',
border: 'solid 1px {colors.bgMuted}',
backgroundColor: 'bg',
},
"input[type='email'], input[type='password'], input[type='text']": {
width: '40%',
minWidth: '300px',
display: 'block',
margin: '0 auto',
padding: '10px',
fontSize: '16px',
border: 'solid 1px {colors.bgMuted}',
borderRadius: '5px',
marginBottom: '2vh',
},
'input:focus': {
border: 'solid 1px {colors.inputBorder}',
outline: '0 none',
},
/** Aligns checkbox and label vertically. */
"input[type='checkbox']": {
verticalAlign: 'middle',
position: 'relative',
bottom: '1px',
},
label: { display: 'block' },
textarea: {
width: 'calc(100% - 40px)',
display: 'block',
margin: '0 auto',
height: '50vh',
padding: '10px',
fontSize: '16px',
border: 'solid 1px {colors.bgMuted}',
color: 'fg',
backgroundColor: 'bg',
},
code: {
backgroundColor: 'codeBg',
fontFamily: 'monospace',
},
'button[disabled]': {
opacity: 0.25,
pointerEvents: 'none',
userSelect: 'none',
cursor: 'auto',
},
'[contenteditable]': {
outline: 'none',
userSelect: 'text',
},
/* empty class is set dynamically by javascript during editing. */
/* :empty does not work because thought may contain <br> */
'[placeholder]:empty::before': {
fontStyle: 'italic',
color: 'dim',
content: 'attr(placeholder)',
cursor: 'text',
},
})
export default defineConfig({
// Where to look for your css declarations
include: ['./src/**/*.{js,jsx,ts,tsx}'],
// Files to exclude
exclude: [],
// Disable style props on JSX components
jsxStyleProps: 'none',
// Disable Panda-specific shorthand properties
shorthands: false,
// Useful for theme customization
theme: {
extend: {
keyframes,
tokens: {
colors: colorTokens,
easings: {
// Ease in even slower at the beginning of the animation.
// For reference, ease-in is equivalent to cubic-bezier(.42, 0, 1, 1).
easeInSlow: {
value: 'cubic-bezier(.84, 0, 1, 1)',
},
},
fontSizes: {
sm: {
value: '80%',
},
md: {
value: '90%',
},
},
spacing: {
modalPadding: { value: '8%' },
safeAreaTop: { value: 'env(safe-area-inset-top)' },
safeAreaBottom: { value: 'env(safe-area-inset-bottom)' },
},
/* z-index schedule
Keep these in one place to make it easier to determine interactions and prevent conflicts. */
zIndex: {
...zIndexDescending([
'popup',
'hoverArrow',
'gestureTrace',
'commandPalette',
'modal',
'hamburgerMenu',
'sidebar',
'toolbarContainer',
'toolbarOverlay',
'toolbarArrow',
'toolbar',
'navbar',
'latestShortcuts',
'tutorialTraceGesture',
'dropEmpty',
'subthoughtsDropEnd',
'tutorial',
'thoughtAnnotationLink',
'resizer',
'bullet',
'stack',
'content',
'scrollZone',
]),
hide: { value: -1 },
},
},
recipes: {
icon: iconRecipe,
child: childRecipe,
anchorButton: anchorButtonRecipe,
button: buttonRecipe,
bullet: bulletRecipe,
link: linkRecipe,
extendTap: extendTapRecipe,
thought: thoughtRecipe,
editable: editableRecipe,
textNote: textNoteRecipe,
multiline: multilineRecipe,
modalActionLink: modalActionLinkRecipe,
toolbarPointerEvents: toolbarPointerEventsRecipe,
tutorialBullet: tutorialBulletRecipe,
upperRight: upperRightRecipe,
dropHover: dropHoverRecipe,
dropEnd: dropEndRecipe,
invalidOption: invalidOptionRecipe,
},
slotRecipes: {
modal: modalRecipe,
modalText: modalTextRecipe,
fadeTransition: fadeTransitionRecipe,
slideTransition: slideTransitionRecipe,
},
semanticTokens: {
colors: {
...colorSemanticTokens,
invalidOption: {
value: 'tomato !important',
},
},
durations,
},
},
},
globalCss,
conditions: {
light: '[data-color-mode=light] &',
dark: '[data-color-mode=dark] &',
test: '[data-env=test] &',
chrome: '[data-browser=chrome] &',
safari: '[data-browser=safari] &',
mobile: '[data-device=mobile] &',
desktop: '[data-device=desktop] &',
native: '[data-native=true] &',
android: '[data-platform=android] &',
mac: '[data-platform=mac] &',
iphone: '[data-platform=iphone] &',
dragInProgress: '[data-drag-in-progress=true] &',
},
// The output directory for your css system
outdir: 'styled-system',
presets: [],
})