Skip to content

Commit 7623e65

Browse files
Mini-ghostzyyvantfu
authored
feat(preset-mini): support size-* shorthand (#3425)
Co-authored-by: Chris <1633711653@qq.com> Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
1 parent 526c141 commit 7623e65

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

packages/preset-mini/src/_rules/size.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function getSizeValue(minmax: string, hw: string, theme: Theme, prop: string) {
3232
}
3333

3434
export const sizes: Rule<Theme>[] = [
35+
[/^size-(min-|max-)?(.+)$/, ([, m, s], { theme }) => ({ [getPropName(m, 'w')]: getSizeValue(m, 'w', theme, s), [getPropName(m, 'h')]: getSizeValue(m, 'h', theme, s) })],
3536
[/^(?:size-)?(min-|max-)?([wh])-?(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) })],
3637
[/^(?:size-)?(min-|max-)?(block|inline)-(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) }), {
3738
autocomplete: [

test/assets/output/preset-mini-targets.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,11 @@ unocss .scope-\[unocss\]\:block{display:block;}
671671
.pos-unset{position:unset;}
672672
.position-inherit{position:inherit;}
673673
.static{position:static;}
674+
.size-\[calc\(1000px-4rem\)\]{width:calc(1000px - 4rem);height:calc(1000px - 4rem);}
675+
.size-\[var\(--something\)\]{width:var(--something);height:var(--something);}
676+
.size-10{width:2.5rem;height:2.5rem;}
677+
.size-max-10{max-width:2.5rem;max-height:2.5rem;}
678+
.size-min-10{min-width:2.5rem;min-height:2.5rem;}
674679
.h-\[calc\(1000px-4rem\)\],
675680
.size-h-\[calc\(1000px-4rem\)\]{height:calc(1000px - 4rem);}
676681
.h-\$var{height:var(--var);}

test/assets/preset-mini-targets.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,11 @@ export const presetMiniTargets: string[] = [
559559
'size-w-10',
560560
'size-h-[calc(1000px-4rem)]',
561561
'size-min-w-full',
562+
'size-10',
563+
'size-[calc(1000px-4rem)]',
564+
'size-[var(--something)]',
565+
'size-min-10',
566+
'size-max-10',
562567

563568
// size - logical
564569
'block-auto',

0 commit comments

Comments
 (0)