@tanstack/devtools-ui 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,9 @@
1
1
  import * as goober from 'goober'
2
- import { createSignal } from 'solid-js'
2
+ import { createEffect, createSignal } from 'solid-js'
3
+ import { useTheme } from '../components/theme'
3
4
  import { tokens } from './tokens'
4
5
  import type { ButtonVariant } from '../components/button'
6
+ import type { Theme } from '../components/theme'
5
7
 
6
8
  const buttonVariantColors: Record<
7
9
  ButtonVariant,
@@ -51,7 +53,7 @@ const buttonVariantColors: Record<
51
53
  },
52
54
  }
53
55
  export const css = goober.css
54
- const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
56
+ const stylesFactory = (theme: Theme = 'dark') => {
55
57
  const { colors, font, size, alpha, border } = tokens
56
58
  const { fontFamily } = font
57
59
 
@@ -87,12 +89,12 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
87
89
  selectLabel: css`
88
90
  font-size: 0.875rem;
89
91
  font-weight: 500;
90
- color: ${colors.gray[100]};
92
+ color: ${t(colors.gray[900], colors.gray[100])};
91
93
  text-align: left;
92
94
  `,
93
95
  selectDescription: css`
94
96
  font-size: 0.8rem;
95
- color: ${colors.gray[400]};
97
+ color: ${t(colors.gray[500], colors.gray[400])};
96
98
  margin: 0;
97
99
  line-height: 1.3;
98
100
  text-align: left;
@@ -102,9 +104,9 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
102
104
  width: 100%;
103
105
  padding: 0.75rem 3rem 0.75rem 0.75rem;
104
106
  border-radius: 0.5rem;
105
- background-color: ${colors.darkGray[800]};
106
- color: ${colors.gray[100]};
107
- border: 1px solid ${colors.gray[700]};
107
+ background-color: ${t(colors.gray[50], colors.darkGray[800])};
108
+ color: ${t(colors.gray[900], colors.gray[100])};
109
+ border: 1px solid ${t(colors.gray[300], colors.gray[700])};
108
110
  font-size: 0.875rem;
109
111
  transition: all 0.2s ease;
110
112
  cursor: pointer;
@@ -116,7 +118,7 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
116
118
  background-size: 1.25rem;
117
119
 
118
120
  &:hover {
119
- border-color: ${colors.gray[600]};
121
+ border-color: ${t(colors.gray[400], colors.gray[600])};
120
122
  }
121
123
 
122
124
  &:focus {
@@ -138,12 +140,12 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
138
140
  inputLabel: css`
139
141
  font-size: 0.875rem;
140
142
  font-weight: 500;
141
- color: ${colors.gray[100]};
143
+ color: ${t(colors.gray[900], colors.gray[100])};
142
144
  text-align: left;
143
145
  `,
144
146
  inputDescription: css`
145
147
  font-size: 0.8rem;
146
- color: ${colors.gray[400]};
148
+ color: ${t(colors.gray[500], colors.gray[400])};
147
149
  margin: 0;
148
150
  line-height: 1.3;
149
151
  text-align: left;
@@ -153,25 +155,26 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
153
155
  width: 100%;
154
156
  padding: 0.75rem;
155
157
  border-radius: 0.5rem;
156
- background-color: ${colors.darkGray[800]};
157
- color: ${colors.gray[100]};
158
- border: 1px solid ${colors.gray[700]};
158
+ background-color: ${t(colors.gray[50], colors.darkGray[800])};
159
+ color: ${t(colors.gray[900], colors.gray[100])};
160
+ border: 1px solid ${t(colors.gray[300], colors.gray[700])};
159
161
  font-size: 0.875rem;
160
162
  font-family: ${fontFamily.mono};
161
163
  transition: all 0.2s ease;
162
164
 
163
165
  &::placeholder {
164
- color: ${colors.gray[500]};
166
+ color: ${t(colors.gray[400], colors.gray[500])};
165
167
  }
166
168
 
167
169
  &:hover {
168
- border-color: ${colors.gray[600]};
170
+ border-color: ${t(colors.gray[400], colors.gray[600])};
169
171
  }
170
172
 
171
173
  &:focus {
172
174
  outline: none;
173
- border-color: ${colors.purple[400]};
174
- box-shadow: 0 0 0 3px ${colors.purple[400]}${alpha[20]};
175
+ border-color: ${t(colors.purple[500], colors.purple[400])};
176
+ box-shadow: 0 0 0 3px
177
+ ${t(colors.purple[100] + alpha[20], colors.purple[400] + alpha[20])};
175
178
  }
176
179
  `,
177
180
  checkboxWrapper: css`
@@ -185,7 +188,7 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
185
188
  transition: background-color 0.2s ease;
186
189
 
187
190
  &:hover {
188
- background-color: ${colors.darkGray[800]};
191
+ background-color: ${t(colors.gray[100], colors.darkGray[800])};
189
192
  }
190
193
  `,
191
194
  checkboxContainer: css`
@@ -201,9 +204,9 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
201
204
  appearance: none;
202
205
  width: 1.25rem;
203
206
  height: 1.25rem;
204
- border: 2px solid ${colors.gray[700]};
207
+ border: 2px solid ${t(colors.gray[300], colors.gray[700])};
205
208
  border-radius: 0.375rem;
206
- background-color: ${colors.darkGray[800]};
209
+ background-color: ${t(colors.gray[50], colors.darkGray[800])};
207
210
  display: grid;
208
211
  place-items: center;
209
212
  transition: all 0.2s ease;
@@ -211,33 +214,33 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
211
214
  margin-top: 0.125rem;
212
215
 
213
216
  &:hover {
214
- border-color: ${colors.purple[400]};
217
+ border-color: ${t(colors.purple[500], colors.purple[400])};
215
218
  }
216
219
 
217
220
  &:checked {
218
- background-color: ${colors.purple[500]};
219
- border-color: ${colors.purple[500]};
221
+ background-color: ${t(colors.purple[500], colors.purple[700])};
222
+ border-color: ${t(colors.purple[500], colors.purple[700])};
220
223
  }
221
224
 
222
225
  &:checked::after {
223
226
  content: '';
224
227
  width: 0.4rem;
225
228
  height: 0.6rem;
226
- border: solid white;
229
+ border: solid ${t('#fff', colors.gray[100])};
227
230
  border-width: 0 2px 2px 0;
228
231
  transform: rotate(45deg);
229
232
  margin-top: -3px;
230
233
  }
231
234
  `,
232
235
  checkboxLabel: css`
233
- color: ${colors.gray[100]};
236
+ color: ${t(colors.gray[900], colors.gray[100])};
234
237
  font-size: 0.875rem;
235
238
  font-weight: 500;
236
239
  line-height: 1.4;
237
240
  text-align: left;
238
241
  `,
239
242
  checkboxDescription: css`
240
- color: ${colors.gray[400]};
243
+ color: ${t(colors.gray[500], colors.gray[400])};
241
244
  font-size: 0.8rem;
242
245
  line-height: 1.3;
243
246
  text-align: left;
@@ -267,43 +270,43 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
267
270
  if (ghost) {
268
271
  return css`
269
272
  background: transparent;
270
- color: ${v.bg};
273
+ color: ${t(v.bg, v.bg)};
271
274
  border-color: transparent;
272
275
  &:hover {
273
- background: ${tokens.colors.purple[100]};
276
+ background: ${t(colors.purple[100], colors.darkGray[700])};
274
277
  }
275
278
  &:active {
276
- background: ${tokens.colors.purple[200]};
279
+ background: ${t(colors.purple[200], colors.darkGray[800])};
277
280
  }
278
281
  `
279
282
  }
280
283
  if (outline) {
281
284
  return css`
282
285
  background: transparent;
283
- color: ${v.bg};
284
- border-color: ${v.bg};
286
+ color: ${t(v.bg, v.bg)};
287
+ border-color: ${t(v.bg, v.bg)};
285
288
  &:hover {
286
- background: ${tokens.colors.purple[100]};
287
- border-color: ${v.hover};
289
+ background: ${t(colors.purple[100], colors.darkGray[700])};
290
+ border-color: ${t(v.hover, v.hover)};
288
291
  }
289
292
  &:active {
290
- background: ${tokens.colors.purple[200]};
291
- border-color: ${v.active};
293
+ background: ${t(colors.purple[200], colors.darkGray[800])};
294
+ border-color: ${t(v.active, v.active)};
292
295
  }
293
296
  `
294
297
  }
295
298
  // Default solid button
296
299
  return css`
297
- background: ${v.bg};
298
- color: ${v.text};
299
- border-color: ${v.border};
300
+ background: ${t(v.bg, v.bg)};
301
+ color: ${t(v.text, v.text)};
302
+ border-color: ${t(v.border, v.border)};
300
303
  &:hover {
301
- background: ${v.hover};
302
- border-color: ${v.hover};
304
+ background: ${t(v.hover, v.hover)};
305
+ border-color: ${t(v.hover, v.hover)};
303
306
  }
304
307
  &:active {
305
- background: ${v.active};
306
- border-color: ${v.active};
308
+ background: ${t(v.active, v.active)};
309
+ border-color: ${t(v.active, v.active)};
307
310
  }
308
311
  `
309
312
  },
@@ -313,7 +316,10 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
313
316
  width: ${tokens.size[1.5]};
314
317
  height: ${tokens.size[1.5]};
315
318
  border-radius: ${tokens.border.radius.full};
316
- background-color: ${tokens.colors[color][500]};
319
+ background-color: ${t(
320
+ tokens.colors[color][500],
321
+ tokens.colors[color][500],
322
+ )};
317
323
  `,
318
324
  base: css`
319
325
  display: flex;
@@ -333,7 +339,7 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
333
339
  position: relative;
334
340
  &:focus-visible {
335
341
  outline-offset: 2px;
336
- outline: 2px solid ${colors.blue[800]};
342
+ outline: 2px solid ${t(colors.blue[700], colors.blue[800])};
337
343
  }
338
344
  `,
339
345
  label: css`
@@ -357,7 +363,6 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
357
363
  color: ${t(colors.gray[500], colors.gray[500])};
358
364
  font-size: ${font.size.xs};
359
365
  margin-right: ${size[1]};
360
- /* outline: 1px solid ${colors.yellow[400]}; */
361
366
  `,
362
367
  actionButton: css`
363
368
  background-color: transparent;
@@ -379,7 +384,7 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
379
384
 
380
385
  &:focus-visible {
381
386
  border-radius: ${border.radius.xs};
382
- outline: 2px solid ${colors.blue[800]};
387
+ outline: 2px solid ${t(colors.blue[700], colors.blue[800])};
383
388
  outline-offset: 2px;
384
389
  }
385
390
  `,
@@ -388,10 +393,11 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
388
393
  `,
389
394
  expander: css`
390
395
  position: absolute;
396
+ cursor: pointer;
391
397
  left: -16px;
392
398
  top: 3px;
393
399
  & path {
394
- stroke: ${colors.blue[300]};
400
+ stroke: ${t(colors.blue[400], colors.blue[300])};
395
401
  }
396
402
  & svg {
397
403
  width: ${size[3]};
@@ -401,19 +407,20 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
401
407
  display: inline-flex;
402
408
  align-items: center;
403
409
  transition: all 0.1s ease;
404
- /* outline: 1px solid ${colors.blue[400]}; */
405
410
  `,
406
411
  expandedLine: (hasBorder: boolean) => css`
407
412
  display: block;
408
413
  padding-left: 0.75rem;
409
414
  margin-left: -0.7rem;
410
- ${hasBorder ? `border-left: 1px solid ${colors.blue[300]};` : ''}
415
+ ${hasBorder
416
+ ? `border-left: 1px solid ${t(colors.blue[400], colors.blue[300])};`
417
+ : ''}
411
418
  `,
412
419
  collapsible: css`
413
420
  cursor: pointer;
414
421
  transition: all 0.2s ease;
415
422
  &:hover {
416
- background-color: ${colors.darkGray[700]};
423
+ background-color: ${t(colors.gray[100], colors.darkGray[700])};
417
424
  border-radius: ${tokens.border.radius.sm};
418
425
  padding: 0 ${tokens.size[1]};
419
426
  }
@@ -429,26 +436,26 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
429
436
  }
430
437
  `,
431
438
  valueCollapsed: css`
432
- color: ${colors.gray[400]};
439
+ color: ${t(colors.gray[500], colors.gray[400])};
433
440
  `,
434
441
  valueFunction: css`
435
- color: ${colors.cyan[400]};
442
+ color: ${t(colors.cyan[500], colors.cyan[400])};
436
443
  `,
437
444
  valueString: css`
438
- color: ${colors.green[400]};
445
+ color: ${t(colors.green[500], colors.green[400])};
439
446
  `,
440
447
  valueNumber: css`
441
- color: ${colors.yellow[400]};
448
+ color: ${t(colors.yellow[500], colors.yellow[400])};
442
449
  `,
443
450
  valueBoolean: css`
444
- color: ${colors.pink[400]};
451
+ color: ${t(colors.pink[500], colors.pink[400])};
445
452
  `,
446
453
  valueNull: css`
447
- color: ${colors.gray[400]};
454
+ color: ${t(colors.gray[500], colors.gray[400])};
448
455
  font-style: italic;
449
456
  `,
450
457
  valueKey: css`
451
- color: ${colors.blue[300]};
458
+ color: ${t(colors.blue[400], colors.blue[300])};
452
459
  `,
453
460
  valueBraces: css`
454
461
  color: ${colors.gray[500]};
@@ -511,7 +518,7 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
511
518
  font-weight: ${font.weight.bold};
512
519
  line-height: ${font.lineHeight.xs};
513
520
  white-space: nowrap;
514
- color: ${t(colors.gray[600], colors.gray[300])};
521
+ color: ${t(colors.gray[700], colors.gray[300])};
515
522
  `,
516
523
  flavorLogo: (flavorLight: string, flavorDark: string) => css`
517
524
  font-weight: ${font.weight.semibold};
@@ -528,18 +535,21 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
528
535
  main: css`
529
536
  margin-bottom: 2rem;
530
537
  padding: 1.5rem;
531
- background-color: ${colors.darkGray[800]};
532
- border: 1px solid ${colors.gray[700]};
538
+ background-color: ${t(colors.gray[50], colors.darkGray[800])};
539
+ border: 1px solid ${t(colors.gray[300], colors.gray[700])};
533
540
  border-radius: 0.75rem;
534
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
541
+ box-shadow: ${t(
542
+ '0 1px 3px rgba(0,0,0,0.06)',
543
+ '0 1px 3px rgba(0,0,0,0.18)',
544
+ )};
535
545
  `,
536
546
  title: css`
537
547
  font-size: 1.125rem;
538
548
  font-weight: 600;
539
- color: ${colors.gray[100]};
549
+ color: ${t(colors.gray[900], colors.gray[100])};
540
550
  margin: 0 0 1rem 0;
541
551
  padding-bottom: 0.5rem;
542
- border-bottom: 1px solid ${colors.gray[700]};
552
+ border-bottom: 1px solid ${t(colors.gray[300], colors.gray[700])};
543
553
  display: flex;
544
554
  align-items: center;
545
555
  gap: 0.5rem;
@@ -552,10 +562,10 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
552
562
  height: 100%;
553
563
  width: 100%;
554
564
  }
555
- color: ${colors.purple[400]};
565
+ color: ${t(colors.purple[500], colors.purple[400])};
556
566
  `,
557
567
  description: css`
558
- color: ${colors.gray[400]};
568
+ color: ${t(colors.gray[500], colors.gray[400])};
559
569
  font-size: 0.875rem;
560
570
  margin: 0 0 1.5rem 0;
561
571
  line-height: 1.5;
@@ -563,20 +573,21 @@ const stylesFactory = (theme: 'light' | 'dark' = 'dark') => {
563
573
  `,
564
574
  },
565
575
  mainPanel: {
566
- panel: css`
567
- padding: 0;
568
- background: ${colors.darkGray[700]};
576
+ panel: (withPadding: boolean) => css`
577
+ padding: ${withPadding ? tokens.size[4] : 0};
578
+ background: ${t(colors.gray[50], colors.darkGray[700])};
569
579
  overflow-y: auto;
570
580
  height: 100%;
571
581
  `,
572
- withPadding: css`
573
- padding: ${tokens.size[4]};
574
- `,
575
582
  },
576
583
  }
577
584
  }
578
585
 
579
586
  export function useStyles() {
580
- const [_styles] = createSignal(stylesFactory())
581
- return _styles
587
+ const { theme } = useTheme()
588
+ const [styles, setStyles] = createSignal(stylesFactory(theme()))
589
+ createEffect(() => {
590
+ setStyles(stylesFactory(theme()))
591
+ })
592
+ return styles
582
593
  }