-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuno.config.js
executable file
·37 lines (35 loc) · 1.14 KB
/
uno.config.js
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
import { defineConfig } from 'unocss'
import presetUno from '@unocss/preset-uno'
export default defineConfig({
presets: [presetUno()],
rules: [
[/^(.*)-custom-(.*)$/, ([, prop, value]) => ({ [camelToKebab(prop)]: value })],
[
/^flex-\[(.*)\]$/,
([, value]) => {
const [align, justify, direction, wrap] = value.split(',')
return {
display: 'flex',
...(align ? { 'align-items': align } : {}),
...(justify ? { 'justify-content': justify } : {}),
...(direction ? { 'flex-direction': direction } : {}),
...(wrap ? { 'flex-wrap': wrap } : {})
}
}
],
[
/^border(\-?.*)-\[(.*)\]$/,
([, direction, value]) => {
const prop = direction ? `border${direction}` : 'border'
const [width, style, color] = value.split(',')
return {
[prop]: `${width || '1px'} ${style || 'solid'} ${color || 'transparent'}`
}
}
],
[/^shadow-custom-(.*)$/, ([, value]) => ({ 'box-shadow': value.replace(/_/g, ' ') })]
]
})
function camelToKebab(str) {
return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()
}