Skip to content

Commit

Permalink
feat(preset-mini): support size-* shorthand (#3425)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris <1633711653@qq.com>
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
3 people committed Dec 27, 2023
1 parent 526c141 commit 7623e65
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/preset-mini/src/_rules/size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function getSizeValue(minmax: string, hw: string, theme: Theme, prop: string) {
}

export const sizes: Rule<Theme>[] = [
[/^size-(min-|max-)?(.+)$/, ([, m, s], { theme }) => ({ [getPropName(m, 'w')]: getSizeValue(m, 'w', theme, s), [getPropName(m, 'h')]: getSizeValue(m, 'h', theme, s) })],
[/^(?:size-)?(min-|max-)?([wh])-?(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) })],
[/^(?:size-)?(min-|max-)?(block|inline)-(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) }), {
autocomplete: [
Expand Down
5 changes: 5 additions & 0 deletions test/assets/output/preset-mini-targets.css
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,11 @@ unocss .scope-\[unocss\]\:block{display:block;}
.pos-unset{position:unset;}
.position-inherit{position:inherit;}
.static{position:static;}
.size-\[calc\(1000px-4rem\)\]{width:calc(1000px - 4rem);height:calc(1000px - 4rem);}
.size-\[var\(--something\)\]{width:var(--something);height:var(--something);}
.size-10{width:2.5rem;height:2.5rem;}
.size-max-10{max-width:2.5rem;max-height:2.5rem;}
.size-min-10{min-width:2.5rem;min-height:2.5rem;}
.h-\[calc\(1000px-4rem\)\],
.size-h-\[calc\(1000px-4rem\)\]{height:calc(1000px - 4rem);}
.h-\$var{height:var(--var);}
Expand Down
5 changes: 5 additions & 0 deletions test/assets/preset-mini-targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,11 @@ export const presetMiniTargets: string[] = [
'size-w-10',
'size-h-[calc(1000px-4rem)]',
'size-min-w-full',
'size-10',
'size-[calc(1000px-4rem)]',
'size-[var(--something)]',
'size-min-10',
'size-max-10',

// size - logical
'block-auto',
Expand Down

0 comments on commit 7623e65

Please sign in to comment.