Change CSS variable helper to proxy
This commit is contained in:
parent
05a673cb59
commit
545d6afa0e
1 changed files with 10 additions and 1 deletions
11
css.js
11
css.js
|
@ -33,4 +33,13 @@ export const style = styles => {
|
||||||
return style
|
return style
|
||||||
}
|
}
|
||||||
|
|
||||||
export const v = name => `var(--${keyToPropName(name)})`
|
const mkVar = name => {
|
||||||
|
const v = (def) => `var(--${name}, ${def})`
|
||||||
|
v.toString = () => `var(--${name})`
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
export const v = new Proxy(Window, {
|
||||||
|
get: (target, name, receiver) => mkVar(name),
|
||||||
|
apply: (target, object, [name]) => `var(--${keyToPropName(name)})`,
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue