Skip to content

Commit

Permalink
feat: support font-size-
Browse files Browse the repository at this point in the history
  • Loading branch information
MellowCo committed Aug 19, 2023
1 parent e3bb66b commit 79abd90
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintcache

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/rules/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const fonts: Rule<Theme>[] = [
},
{ autocomplete: 'text-$fontSize' },
],
[/^text-size-(.+)$/, ([, s], { theme }) => {
[/^(?:text|font)-size-(.+)$/, ([, s], { theme }) => {
const themed = toArray(theme.fontSize?.[s])
const size = themed?.[0] ?? (theme.whRpx ? h.bracket.cssvar.global.rpx(s) : h.bracket.cssvar.global.remToRpx(s))
if (size != null)
Expand Down
2 changes: 2 additions & 0 deletions test/assets/output/preset-mini/targets.css
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ unocss .scope-\[unocss\]\:block{display:block;}
.peer:is(:placeholder-shown)~.peer-is-placeholder-shown\:text-3xl,
.peer:not(:placeholder-shown)~.peer-not-placeholder-shown\:text-3xl{font-size:60rpx;line-height:72rpx;}
.peer:not(:placeholder-shown)~.peer-not-placeholder-shown\:text-2xl{font-size:48rpx;line-height:64rpx;}
.font-size-1\.5rem{font-size:1.5rem;}
.text-size-1em{font-size:1em;}
.text-size-unset{font-size:unset;}
.as-parent .group .group-\[\.as-parent_\&\]\:font-13{font-weight:13;}
.as-parent .group\/label .group-\[\.as-parent_\&\]\/label\:font-18{font-weight:18;}
Expand Down
2 changes: 2 additions & 0 deletions test/assets/output/preset-weapp/targets-custom-rules.css
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ unocss .scope-_lfl11_unocss_lfr11__cl11_block{display:block;}
.peer:is(:placeholder-shown)~.peer-is-placeholder-shown_cl11_text-3xl,
.peer:not(:placeholder-shown)~.peer-not-placeholder-shown_cl11_text-3xl{font-size:60rpx;line-height:72rpx;}
.peer:not(:placeholder-shown)~.peer-not-placeholder-shown_cl11_text-2xl{font-size:48rpx;line-height:64rpx;}
.font-size-1_dl11_5rem{font-size:1.5rem;}
.text-size-1em{font-size:1em;}
.text-size-unset{font-size:unset;}
.as-parent .group .group-_lfl11__dl11_as-parent_\&_lfr11__cl11_font-13{font-weight:13;}
.as-parent .group_sl11_label .group-_lfl11__dl11_as-parent_\&_lfr11__sl11_label_cl11_font-18{font-weight:18;}
Expand Down
2 changes: 2 additions & 0 deletions test/assets/output/preset-weapp/targets.css
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ unocss .scope-_lfl_unocss_lfr__cl_block{display:block;}
.peer:is(:placeholder-shown)~.peer-is-placeholder-shown_cl_text-3xl,
.peer:not(:placeholder-shown)~.peer-not-placeholder-shown_cl_text-3xl{font-size:60rpx;line-height:72rpx;}
.peer:not(:placeholder-shown)~.peer-not-placeholder-shown_cl_text-2xl{font-size:48rpx;line-height:64rpx;}
.font-size-1_dl_5rem{font-size:1.5rem;}
.text-size-1em{font-size:1em;}
.text-size-unset{font-size:unset;}
.as-parent .group .group-_lfl__dl_as-parent_\&_lfr__cl_font-13{font-weight:13;}
.as-parent .group_sl_label .group-_lfl__dl_as-parent_\&_lfr__sl_label_cl_font-18{font-weight:18;}
Expand Down
2 changes: 2 additions & 0 deletions test/assets/preset-mini-targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ export const presetMiniTargets: string[] = [
'text-[12px]/[13px]',
'text-[12rpx]/[13rpx]',
'text-[length:var(--size)]:$leading',
'text-size-1em',
'font-size-1.5rem',

// color - bg
'bg-[#153]/10',
Expand Down

0 comments on commit 79abd90

Please sign in to comment.