feat: 扩充 unocss 自定义 shortcuts

This commit is contained in:
Hooray Hu
2024-08-05 14:43:03 +08:00
parent 7668bd5063
commit 6f59ddf6b8
+19 -4
View File
@@ -22,10 +22,25 @@ export default defineConfig<Theme>({
},
},
shortcuts: [
{
'flex-center': 'flex justify-center items-center',
'flex-col-center': 'flex flex-col justify-center items-center',
},
[/^flex-?(col)?-(start|end|center|baseline|stretch)-?(start|end|center|between|around|evenly|left|right)?$/, ([, col, items, justify]) => {
const cls = ['flex']
if (col === 'col') {
cls.push('flex-col')
}
if (items === 'center' && !justify) {
cls.push('items-center')
cls.push('justify-center')
}
else {
cls.push(`items-${items}`)
if (justify) {
cls.push(`justify-${justify}`)
}
}
return cls.join(' ')
}],
[/^square-\[?(.*?)\]?$/, ([, size]) => `w-${size} h-${size}`],
[/^circle-\[?(.*?)\]?$/, ([, size]) => `square-${size} rounded-full`],
],
preflights: [
{