Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: expand font shorthand properly (#3603)

Bogdan Chadkinb3efb88915bc
diff --git a/packages/css-data/src/shorthands.test.ts b/packages/css-data/src/shorthands.test.ts
index 8c6eb79cd0..3d85cce1cb 100644
--- a/packages/css-data/src/shorthands.test.ts
+++ b/packages/css-data/src/shorthands.test.ts
@@ -388,7 +388,7 @@ test("expand font", () => {
["font-style", "italic"],
["font-variant-caps", "small-caps"],
["font-weight", "bold"],
- ["font-width", "ultra-condensed"],
+ ["font-stretch", "ultra-condensed"],
["font-size", "1.2em"],
["line-height", "initial"],
["font-family", '"Fira Sans",sans-serif'],
@@ -399,7 +399,7 @@ test("expand font", () => {
["font-style", "initial"],
["font-variant-caps", "initial"],
["font-weight", "initial"],
- ["font-width", "initial"],
+ ["font-stretch", "initial"],
["font-size", "1.2em"],
["line-height", "2"],
["font-family", '"Fira Sans",sans-serif'],
diff --git a/packages/css-data/src/shorthands.ts b/packages/css-data/src/shorthands.ts
index 11dae3f9f1..a98c6eb7bf 100644
--- a/packages/css-data/src/shorthands.ts
+++ b/packages/css-data/src/shorthands.ts
@@ -284,7 +284,7 @@ const expandBorderImage = function* (value: CssNode) {
/**
*
* font =
- * [ <'font-style'> || <font-variant-css2> || <'font-weight'> || <font-width-css3> ]?
+ * [ <'font-style'> || <font-variant-css21> || <'font-weight'> || <'font-stretch'> ]?
* <'font-size'> [ / <'line-height'> ]? <'font-family'>
*
*/
@@ -293,11 +293,9 @@ const expandFont = function* (value: CssNode) {
parseUnordered(
[
"<'font-style'>",
- // <font-variant-css2> is unsupported by csstree
- "[ normal | small-caps ]",
+ "<font-variant-css21>",
"<'font-weight'>",
- // <font-width-css3> is unsupported by csstree
- "[ normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded ]",
+ "<'font-stretch'>",
],
value
);
@@ -323,7 +321,7 @@ const expandFont = function* (value: CssNode) {
yield ["font-style", fontStyle ?? createInitialNode()] as const;
yield ["font-variant-caps", fontVariant ?? createInitialNode()] as const;
yield ["font-weight", fontWeight ?? createInitialNode()] as const;
- yield ["font-width", fontWidth ?? createInitialNode()] as const;
+ yield ["font-stretch", fontWidth ?? createInitialNode()] as const;
yield ["font-size", fontSize] as const;
yield ["line-height", lineHeight] as const;
yield ["font-family", fontFamily] as const;