feat(core): CSS wide keywords (#10709)

This commit is contained in:
Dimitris-Rafail Katsampas
2025-02-26 05:15:47 +02:00
committed by GitHub
parent 5024156f0d
commit 2d71ada46d
12 changed files with 247 additions and 94 deletions

View File

@@ -42,31 +42,32 @@ export function parseCSSShorthand(value: string): {
if (['', 'none', 'unset'].includes(first)) {
return null;
} else {
const invalidColors = ['inset', 'unset'];
const inset = parts.includes('inset');
const last = parts[parts.length - 1];
let color = 'black';
if (first && !isLength(first) && !invalidColors.includes(first)) {
color = first;
} else if (last && !isLength(last) && !invalidColors.includes(last)) {
color = last;
}
const values = parts
.filter((n) => !invalidColors.includes(n))
.filter((n) => n !== color)
.map((val) => {
try {
return Length.parse(val);
} catch (err) {
return CoreTypes.zeroLength;
}
});
return {
inset,
color,
values,
};
}
const invalidColors = ['inset', 'unset'];
const inset = parts.includes('inset');
const last = parts[parts.length - 1];
let color = 'black';
if (first && !isLength(first) && !invalidColors.includes(first)) {
color = first;
} else if (last && !isLength(last) && !invalidColors.includes(last)) {
color = last;
}
const values = parts
.filter((n) => !invalidColors.includes(n))
.filter((n) => n !== color)
.map((val) => {
try {
return Length.parse(val);
} catch (err) {
return CoreTypes.zeroLength;
}
});
return {
inset,
color,
values,
};
}