Skip to content

Commit 479e5b6

Browse files
manudeliTkDodo
andauthored
fix(query-devtools): typed tokens (TanStack#6745)
* fix(query-devtools): typed tokens * chore: update --------- Co-authored-by: Dominik Dorfmeister <[email protected]>
1 parent 63b83bd commit 479e5b6

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

packages/query-devtools/src/theme.ts

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
1-
const ShadowVariants = {
2-
xs: '0 1px 2px 0 rgb(0 0 0 / 0.05)',
3-
sm: '0 1px 3px 0 color, 0 1px 2px -1px color',
4-
md: '0 4px 6px -1px color, 0 2px 4px -2px color',
5-
lg: '0 10px 15px -3px color, 0 4px 6px -4px color',
6-
xl: '0 20px 25px -5px color, 0 8px 10px -6px color',
7-
'2xl': '0 25px 50px -12px color',
8-
inner: 'inset 0 2px 4px 0 color',
9-
none: 'none',
10-
}
11-
12-
type ShadowVariantType = keyof typeof ShadowVariants
13-
14-
const getShadow = (variant: ShadowVariantType, color: string = ''): string => {
15-
return ShadowVariants[variant].replace(/color/g, color)
16-
}
17-
18-
const Shadow = {
19-
xs: (color: string = 'rgb(0 0 0 / 0.1)') => getShadow('xs', color),
20-
sm: (color: string = 'rgb(0 0 0 / 0.1)') => getShadow('sm', color),
21-
md: (color: string = 'rgb(0 0 0 / 0.1)') => getShadow('md', color),
22-
lg: (color: string = 'rgb(0 0 0 / 0.1)') => getShadow('lg', color),
23-
xl: (color: string = 'rgb(0 0 0 / 0.1)') => getShadow('xl', color),
24-
'2xl': (color: string = 'rgb(0 0 0 / 0.25)') => getShadow('2xl', color),
25-
inner: (color: string = 'rgb(0 0 0 / 0.05)') => getShadow('inner', color),
26-
none: () => getShadow('none'),
27-
}
28-
291
export const tokens = {
302
colors: {
313
inherit: 'inherit',
@@ -292,7 +264,23 @@ export const tokens = {
292264
80: 'calc(var(--tsqd-font-size) * 20)',
293265
96: 'calc(var(--tsqd-font-size) * 24)',
294266
},
295-
shadow: Shadow,
267+
shadow: {
268+
xs: (_: string = 'rgb(0 0 0 / 0.1)') =>
269+
`0 1px 2px 0 rgb(0 0 0 / 0.05)` as const,
270+
sm: (color: string = 'rgb(0 0 0 / 0.1)') =>
271+
`0 1px 3px 0 ${color}, 0 1px 2px -1px ${color}` as const,
272+
md: (color: string = 'rgb(0 0 0 / 0.1)') =>
273+
`0 4px 6px -1px ${color}, 0 2px 4px -2px ${color}` as const,
274+
lg: (color: string = 'rgb(0 0 0 / 0.1)') =>
275+
`0 10px 15px -3px ${color}, 0 4px 6px -4px ${color}` as const,
276+
xl: (color: string = 'rgb(0 0 0 / 0.1)') =>
277+
`0 20px 25px -5px ${color}, 0 8px 10px -6px ${color}` as const,
278+
'2xl': (color: string = 'rgb(0 0 0 / 0.25)') =>
279+
`0 25px 50px -12px ${color}` as const,
280+
inner: (color: string = 'rgb(0 0 0 / 0.05)') =>
281+
`inset 0 2px 4px 0 ${color}` as const,
282+
none: () => `none` as const,
283+
},
296284
zIndices: {
297285
hide: -1,
298286
auto: 'auto',
@@ -308,4 +296,4 @@ export const tokens = {
308296
toast: 1700,
309297
tooltip: 1800,
310298
},
311-
}
299+
} as const

0 commit comments

Comments
 (0)