forked from safe-global/safe-wallet-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcss-vars.ts
39 lines (31 loc) · 1.05 KB
/
css-vars.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
import lightPalette from '../src/components/theme/lightPalette'
import darkPalette from '../src/components/theme/darkPalette'
import spacings from '../src/styles/spacings.js'
const cssVars: string[] = []
Object.entries(lightPalette).forEach(([key, value]) => {
Object.entries(value).forEach(([subKey, color]) => {
cssVars.push(` --color-${key}-${subKey}: ${color};`)
})
})
Object.entries(spacings).forEach(([key, space]) => cssVars.push(` --space-${key}: ${space}px;`))
const darkColorVars: string[] = []
Object.entries(darkPalette).forEach(([key, value]) => {
Object.entries(value).forEach(([subKey, color]) => {
darkColorVars.push(` --color-${key}-${subKey}: ${color};`)
})
})
const css = `/* This file is generated from the MUI theme colors. Do not edit directly. */
:root {
${cssVars.join('\n')}
}
[data-theme="dark"] {
${darkColorVars.join('\n')}
}
/* The same as above for the brief moment before JS loads */
@media (prefers-color-scheme: dark) {
:root:not([data-theme='light']) {
${darkColorVars.join('\n')}
}
}
`
console.log(css)