Support bare spacing scale values for font-size

This commit is contained in:
Jordan Pittman 2025-12-02 13:14:15 -05:00
parent d573991871
commit 66be2a6bb5
2 changed files with 16 additions and 2 deletions

View File

@ -243,7 +243,7 @@ export class Theme {
}
resolveWith(
candidateValue: string,
candidateValue: string | null,
themeKeys: ThemeKey[],
nestedKeys: `--${string}`[] = [],
): [string, Record<string, string>] | null {

View File

@ -5095,6 +5095,20 @@ export function createUtilities(theme: Theme) {
['--text', '--spacing'],
['--line-height', '--letter-spacing', '--font-weight'],
)
// Bare values use the spacing scale
if (!value) {
let multiplier = theme.resolveWith(
null,
['--spacing'],
['--line-height', '--letter-spacing', '--font-weight'],
)
if (!multiplier) return
if (!isValidSpacingMultiplier(candidate.value.value)) return
value = [`calc(${multiplier[0]} * ${candidate.value.value})`, multiplier[1]]
}
if (value) {
let [fontSize, options = {}] = Array.isArray(value) ? value : [value]
@ -5158,7 +5172,7 @@ export function createUtilities(theme: Theme) {
modifiers: Array.from({ length: 21 }, (_, index) => `${index * 5}`),
},
{
values: [],
values: theme.get(['--spacing']) ? DEFAULT_SPACING_SUGGESTIONS : [],
valueThemeKeys: ['--text', '--spacing'],
modifiers: [],
modifierThemeKeys: ['--leading', '--spacing'],