Skip to content

Commit

Permalink
feat: 扩充 unocss 自定义 shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
hooray committed Aug 5, 2024
1 parent 7668bd5 commit 6f59ddf
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions uno.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down

0 comments on commit 6f59ddf

Please sign in to comment.