remove fallback theme key lookup

- In case of `columns`, bare values can be used for the amount of columns
- In case of `divide-width`, we can always look at `--border-width`
This commit is contained in:
Robin Malfait 2024-03-20 16:03:38 +01:00
parent ef3b47aaee
commit 0a5fc2dd39
No known key found for this signature in database

View file

@ -1294,8 +1294,7 @@ export function createUtilities(theme: Theme) {
return [decl('rotate', value)]
}
} else {
value = theme.resolve(candidate.value.value, ['--rotate'])
if (!value && !Number.isNaN(Number(candidate.value.value))) {
if (!Number.isNaN(Number(candidate.value.value))) {
value = `${candidate.value.value}deg`
}
if (!value) return
@ -1427,8 +1426,7 @@ export function createUtilities(theme: Theme) {
value = candidate.value.value
return [decl('scale', value)]
} else {
value = theme.resolve(candidate.value.value, ['--scale'])
if (!value && !Number.isNaN(Number(candidate.value.value))) {
if (!Number.isNaN(Number(candidate.value.value))) {
value = `${candidate.value.value}%`
}
if (!value) return
@ -1818,7 +1816,8 @@ export function createUtilities(theme: Theme) {
staticUtility('columns-auto', [['columns', 'auto']])
functionalUtility('columns', {
themeKeys: ['--columns', '--width'],
// TODO: Do we want to remove the `--columns` or not?
themeKeys: ['--width'],
handleBareValue: ({ value }) => {
if (!Number.isInteger(Number(value))) return null
return value
@ -2335,7 +2334,8 @@ export function createUtilities(theme: Theme) {
functionalUtility('divide-x', {
defaultValue: theme.get(['--default-border-width']) ?? '1px',
themeKeys: ['--divide-width', '--border-width'],
// TODO: Do we want to remove `--divide-width` or not?
themeKeys: ['--border-width'],
handleBareValue: ({ value }) => {
if (Number.isNaN(Number(value))) return null
return `${value}px`
@ -2358,7 +2358,8 @@ export function createUtilities(theme: Theme) {
functionalUtility('divide-y', {
defaultValue: theme.get(['--default-border-width']) ?? '1px',
themeKeys: ['--divide-width', '--border-width'],
// TODO: Do we want to remove `--divide-width` or not?
themeKeys: ['--border-width'],
handleBareValue: ({ value }) => {
if (Number.isNaN(Number(value))) return null
return `${value}px`
@ -2380,7 +2381,7 @@ export function createUtilities(theme: Theme) {
suggest('divide-x', () => [
{
values: ['0', '2', '4', '8'],
valueThemeKeys: ['--divide-width', '--border-width'],
valueThemeKeys: ['--border-width'],
hasDefaultValue: true,
},
])
@ -2388,7 +2389,7 @@ export function createUtilities(theme: Theme) {
suggest('divide-y', () => [
{
values: ['0', '2', '4', '8'],
valueThemeKeys: ['--divide-width', '--border-width'],
valueThemeKeys: ['--border-width'],
hasDefaultValue: true,
},
])