From 286bb3a1da7ac483eb124c5bd6f6cd2f4f61da7e Mon Sep 17 00:00:00 2001 From: Hooray Hu <304327508@qq.com> Date: Mon, 5 Aug 2024 14:55:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=A9=E5=85=85=20unocss=20=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=20shortcuts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uno.config.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/uno.config.ts b/uno.config.ts index 84c0073..9a8bfa8 100755 --- a/uno.config.ts +++ b/uno.config.ts @@ -35,10 +35,25 @@ export default defineConfig({ }, ], 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: [ {