forked from unocss/unocss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.ts
30 lines (27 loc) · 805 Bytes
/
variables.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
import type { Rule } from '@unocss/core'
import { handler as h } from '../utils'
const variablesAbbrMap: Record<string, string> = {
backface: 'backface-visibility',
break: 'word-break',
case: 'text-transform',
content: 'align-content',
fw: 'font-weight',
items: 'align-items',
justify: 'justify-content',
select: 'user-select',
self: 'align-self',
vertical: 'vertical-align',
visible: 'visibility',
whitespace: 'white-space',
ws: 'white-space',
}
export const cssVariables: Rule[] = [
[/^(.+?)-(\$.+)$/, ([, name, varname]) => {
const prop = variablesAbbrMap[name]
if (prop)
return { [prop]: h.cssvar(varname) }
}],
]
export const cssProperty: Rule[] = [
[/^\[(--(\w|\\\W)+|[\w-]+):(.+)\]$/, ([, prop,, value]) => ({ [prop]: h.bracket(`[${value}]`) })],
]