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.

refactor: migrate css-data to hyphenated properties (#5031)

Bogdan Chadkin5637e71287c2
diff --git a/apps/builder/app/builder/features/settings-panel/props-section/animation/new-view-animations.ts b/apps/builder/app/builder/features/settings-panel/props-section/animation/new-view-animations.ts
index f721214a09..fe106c6357 100644
--- a/apps/builder/app/builder/features/settings-panel/props-section/animation/new-view-animations.ts
+++ b/apps/builder/app/builder/features/settings-panel/props-section/animation/new-view-animations.ts
@@ -114,13 +114,13 @@ const newWipeInViewAnimation: ViewAnimation = {
{
offset: 0,
styles: {
- "clip-path": parseCssValue("clipPath", "inset(0 100% 0 0)"),
+ "clip-path": parseCssValue("clip-path", "inset(0 100% 0 0)"),
},
},
{
offset: 1,
styles: {
- "clip-path": parseCssValue("clipPath", "inset(0 0 0 0)"),
+ "clip-path": parseCssValue("clip-path", "inset(0 0 0 0)"),
},
},
],
@@ -140,14 +140,14 @@ const newWipeOutViewAnimation: ViewAnimation = {
{
offset: 0,
styles: {
- "clip-path": parseCssValue("clipPath", "inset(0 0 0 0)"),
+ "clip-path": parseCssValue("clip-path", "inset(0 0 0 0)"),
},
},
{
offset: 1,
styles: {
- "clip-path": parseCssValue("clipPath", "inset(0 0 0 100%)"),
+ "clip-path": parseCssValue("clip-path", "inset(0 0 0 100%)"),
},
},
],
diff --git a/apps/builder/app/builder/features/style-panel/controls/font-family/font-family-control.tsx b/apps/builder/app/builder/features/style-panel/controls/font-family/font-family-control.tsx
index d8a7887906..da4369bcce 100644
--- a/apps/builder/app/builder/features/style-panel/controls/font-family/font-family-control.tsx
+++ b/apps/builder/app/builder/features/style-panel/controls/font-family/font-family-control.tsx
@@ -86,7 +86,7 @@ export const FontFamilyControl = () => {
itemToString={(item) => item?.label ?? item?.value ?? ""}
onItemHighlight={(item) => {
if (item === null) {
- setValue(parseCssValue("fontFamily", itemValue), {
+ setValue(parseCssValue("font-family", itemValue), {
isEphemeral: true,
});
return;
@@ -97,7 +97,7 @@ export const FontFamilyControl = () => {
);
}}
onItemSelect={(item) => {
- setValue(parseCssValue("fontFamily", item.value));
+ setValue(parseCssValue("font-family", item.value));
setIntermediateValue(undefined);
}}
value={{ value: intermediateValue ?? itemValue }}
@@ -108,7 +108,7 @@ export const FontFamilyControl = () => {
if (isFontManagerOpen) {
return;
}
- setValue(parseCssValue("fontFamily", itemValue));
+ setValue(parseCssValue("font-family", itemValue));
}}
match={matchOrSuggestToCreate}
/>
diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx
index 163139c95a..74d33ad9fb 100644
--- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx
@@ -49,7 +49,7 @@ export const BackgroundGradient = ({ index }: { index: number }) => {
// This doesn't have the same behavior as CssValueInput.
// However, it's great to see the immediate results when making gradient changes,
// especially until we have a better gradient tool.
- const newValue = parseCssValue("backgroundImage", value);
+ const newValue = parseCssValue("background-image", value);
if (newValue.type === "unparsed" || newValue.type === "var") {
setRepeatedStyleItem(styleDecl, index, newValue, { isEphemeral: true });
diff --git a/apps/builder/app/builder/features/style-panel/sections/shared/value-text.stories.tsx b/apps/builder/app/builder/features/style-panel/sections/shared/value-text.stories.tsx
index 98816569fb..f86e576b51 100644
--- a/apps/builder/app/builder/features/style-panel/sections/shared/value-text.stories.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/shared/value-text.stories.tsx
@@ -46,7 +46,7 @@ export default {
control: "select",
options: valueOptions,
labels: Object.fromEntries(
- valueOptions.map((value) => [value, parseCssValue("marginTop", value)])
+ valueOptions.map((value) => [value, parseCssValue("margin-top", value)])
),
},
},
diff --git a/apps/builder/app/builder/features/style-panel/sections/transforms/transform-extractors.test.ts b/apps/builder/app/builder/features/style-panel/sections/transforms/transform-extractors.test.ts
index f9f0b47403..b37da2d9d6 100644
--- a/apps/builder/app/builder/features/style-panel/sections/transforms/transform-extractors.test.ts
+++ b/apps/builder/app/builder/features/style-panel/sections/transforms/transform-extractors.test.ts
@@ -112,7 +112,7 @@ describe("extractTransformOrPerspectiveOriginValues", () => {
test("parses transform-origin and returns the individual properties from the value", () => {
expect(
extractTransformOrPerspectiveOriginValues(
- parseCssValue("transformOrigin", "center") as TupleValue
+ parseCssValue("transform-origin", "center") as TupleValue
)
).toEqual({
x: { type: "keyword", value: "center" },
@@ -122,7 +122,7 @@ describe("extractTransformOrPerspectiveOriginValues", () => {
expect(
extractTransformOrPerspectiveOriginValues(
- parseCssValue("transformOrigin", "top") as TupleValue
+ parseCssValue("transform-origin", "top") as TupleValue
)
).toEqual({
x: { type: "keyword", value: "center" },
@@ -132,7 +132,7 @@ describe("extractTransformOrPerspectiveOriginValues", () => {
expect(
extractTransformOrPerspectiveOriginValues(
- parseCssValue("transformOrigin", "right") as TupleValue
+ parseCssValue("transform-origin", "right") as TupleValue
)
).toEqual({
x: { type: "keyword", value: "right" },
@@ -142,7 +142,7 @@ describe("extractTransformOrPerspectiveOriginValues", () => {
expect(
extractTransformOrPerspectiveOriginValues(
- parseCssValue("transformOrigin", "45px") as TupleValue
+ parseCssValue("transform-origin", "45px") as TupleValue
)
).toEqual({
x: { type: "unit", unit: "px", value: 45 },
@@ -152,7 +152,7 @@ describe("extractTransformOrPerspectiveOriginValues", () => {
expect(
extractTransformOrPerspectiveOriginValues(
- parseCssValue("transformOrigin", "20px 40px") as TupleValue
+ parseCssValue("transform-origin", "20px 40px") as TupleValue
)
).toEqual({
x: { type: "unit", unit: "px", value: 20 },
@@ -162,7 +162,7 @@ describe("extractTransformOrPerspectiveOriginValues", () => {
expect(
extractTransformOrPerspectiveOriginValues(
- parseCssValue("transformOrigin", "10px 20px 30px") as TupleValue
+ parseCssValue("transform-origin", "10px 20px 30px") as TupleValue
)
).toEqual({
x: { type: "unit", unit: "px", value: 10 },
@@ -172,7 +172,7 @@ describe("extractTransformOrPerspectiveOriginValues", () => {
expect(
extractTransformOrPerspectiveOriginValues(
- parseCssValue("transformOrigin", "left top 30px") as TupleValue
+ parseCssValue("transform-origin", "left top 30px") as TupleValue
)
).toEqual({
x: { type: "keyword", value: "left" },
@@ -182,7 +182,7 @@ describe("extractTransformOrPerspectiveOriginValues", () => {
expect(
extractTransformOrPerspectiveOriginValues(
- parseCssValue("transformOrigin", "bottom right 60px") as TupleValue
+ parseCssValue("transform-origin", "bottom right 60px") as TupleValue
)
).toEqual({
x: { type: "keyword", value: "right" },
@@ -192,7 +192,7 @@ describe("extractTransformOrPerspectiveOriginValues", () => {
expect(
extractTransformOrPerspectiveOriginValues(
- parseCssValue("transformOrigin", "left 50% 60px") as TupleValue
+ parseCssValue("transform-origin", "left 50% 60px") as TupleValue
)
).toEqual({
x: { type: "keyword", value: "left" },
@@ -202,7 +202,7 @@ describe("extractTransformOrPerspectiveOriginValues", () => {
expect(
extractTransformOrPerspectiveOriginValues(
- parseCssValue("transformOrigin", "50% bottom 60px") as TupleValue
+ parseCssValue("transform-origin", "50% bottom 60px") as TupleValue
)
).toEqual({
x: { type: "unit", value: 50, unit: "%" },
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-fragment.test.ts b/apps/builder/app/builder/features/style-panel/shared/css-fragment.test.ts
index 7de7fbf87b..2beca5ea2c 100644
--- a/apps/builder/app/builder/features/style-panel/shared/css-fragment.test.ts
+++ b/apps/builder/app/builder/features/style-panel/shared/css-fragment.test.ts
@@ -7,7 +7,7 @@ setEnv("*");
test("parse var()", () => {
const result = new Map([
- ["background-image", parseCssValue("backgroundImage", "var(--bg)")],
+ ["background-image", parseCssValue("background-image", "var(--bg)")],
]);
expect(
parseCssFragment("var(--bg)", ["background-image", "background"])
@@ -22,17 +22,17 @@ test("parse var()", () => {
test("fallback further to valid values", () => {
const result = new Map([
- ["background-image", parseCssValue("backgroundImage", "none")],
- ["background-position-x", parseCssValue("backgroundPositionX", "0%")],
- ["background-position-y", parseCssValue("backgroundPositionY", "0%")],
- ["background-size", parseCssValue("backgroundSize", "auto auto")],
- ["background-repeat", parseCssValue("backgroundRepeat", "repeat")],
- ["background-attachment", parseCssValue("backgroundAttachment", "scroll")],
- ["background-origin", parseCssValue("backgroundOrigin", "padding-box")],
- ["background-clip", parseCssValue("backgroundClip", "border-box")],
+ ["background-image", parseCssValue("background-image", "none")],
+ ["background-position-x", parseCssValue("background-position-x", "0%")],
+ ["background-position-y", parseCssValue("background-position-y", "0%")],
+ ["background-size", parseCssValue("background-size", "auto auto")],
+ ["background-repeat", parseCssValue("background-repeat", "repeat")],
+ ["background-attachment", parseCssValue("background-attachment", "scroll")],
+ ["background-origin", parseCssValue("background-origin", "padding-box")],
+ ["background-clip", parseCssValue("background-clip", "border-box")],
[
"background-color",
- parseCssValue("backgroundColor", "rgba(255, 255, 255, 1)"),
+ parseCssValue("background-color", "rgba(255, 255, 255, 1)"),
],
]);
expect(parseCssFragment("#fff", ["background-image", "background"])).toEqual(
@@ -42,14 +42,14 @@ test("fallback further to valid values", () => {
test("parse shorthand property", () => {
const result = new Map([
- ["transition-property", parseCssValue("transitionProperty", "opacity")],
- ["transition-duration", parseCssValue("transitionDuration", "1s")],
+ ["transition-property", parseCssValue("transition-property", "opacity")],
+ ["transition-duration", parseCssValue("transition-duration", "1s")],
[
"transition-timing-function",
- parseCssValue("transitionTimingFunction", "ease"),
+ parseCssValue("transition-timing-function", "ease"),
],
- ["transition-delay", parseCssValue("transitionDelay", "0s")],
- ["transition-behavior", parseCssValue("transitionBehavior", "normal")],
+ ["transition-delay", parseCssValue("transition-delay", "0s")],
+ ["transition-behavior", parseCssValue("transition-behavior", "normal")],
]);
expect(parseCssFragment("opacity 1s", ["transition"])).toEqual(result);
expect(parseCssFragment("transition: opacity 1s", ["transition"])).toEqual(
@@ -68,8 +68,8 @@ test("parse longhand properties", () => {
)
).toEqual(
new Map([
- ["transition-property", parseCssValue("transitionProperty", "opacity")],
- ["transition-duration", parseCssValue("transitionDuration", "1s")],
+ ["transition-property", parseCssValue("transition-property", "opacity")],
+ ["transition-duration", parseCssValue("transition-duration", "1s")],
])
);
});
diff --git a/apps/builder/app/builder/features/style-panel/shared/filter-content.tsx b/apps/builder/app/builder/features/style-panel/shared/filter-content.tsx
index ecebd40de4..058a6d9462 100644
--- a/apps/builder/app/builder/features/style-panel/shared/filter-content.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/filter-content.tsx
@@ -50,7 +50,7 @@ const filterFunctions = {
// and pass the args as value and property
"drop-shadow": {
default: "0px 2px 5px rgba(0, 0, 0, 0.2)",
- fakeProperty: "textShadow",
+ fakeProperty: "text-shadow",
},
// https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/grayscale#syntax
// number | percentage
diff --git a/packages/css-data/bin/mdn-data.ts b/packages/css-data/bin/mdn-data.ts
index ba52b25ac7..6db7ab1341 100755
--- a/packages/css-data/bin/mdn-data.ts
+++ b/packages/css-data/bin/mdn-data.ts
@@ -7,15 +7,14 @@ import properties from "mdn-data/css/properties.json";
import syntaxes from "mdn-data/css/syntaxes.json";
import selectors from "mdn-data/css/selectors.json";
import data from "css-tree/dist/data";
-import {
- type KeywordValue,
- type StyleValue,
- type Unit,
- type UnitValue,
- type UnparsedValue,
- type FontFamilyValue,
- type CssProperty,
- hyphenateProperty,
+import type {
+ KeywordValue,
+ StyleValue,
+ Unit,
+ UnitValue,
+ UnparsedValue,
+ FontFamilyValue,
+ CssProperty,
} from "@webstudio-is/css-engine";
import * as customData from "../src/custom-data";
import { camelCaseProperty } from "../src/parse-css";
@@ -356,7 +355,7 @@ const getPropertiesData = (
);
}
- propertiesData[camelCaseProperty(property as CssProperty)] = {
+ propertiesData[property] = {
unitGroups: Array.from(unitGroups),
inherited: config.inherited,
initial: parseInitialValue(property, config.initial, unitGroups),
@@ -383,20 +382,16 @@ const getKeywordValues = (filteredProperties: FilteredProperties) => {
const commonKeywords = ["initial", "inherit", "unset"];
for (const property in filteredProperties) {
- const key = camelCaseProperty(property as CssProperty);
// prevent merging with custom keywords
- if (result[key]) {
+ if (result[property]) {
continue;
}
const keywords = new Set<string>();
- walkSyntax(
- filteredProperties[property as keyof typeof filteredProperties].syntax,
- (node) => {
- if (node.type === "Keyword") {
- keywords.add(beautifyKeyword(property, node.name));
- }
+ walkSyntax(filteredProperties[property].syntax, (node) => {
+ if (node.type === "Keyword") {
+ keywords.add(beautifyKeyword(property, node.name));
}
- );
+ });
if (property in nonStandardValues) {
for (const nonStandartKeyword of nonStandardValues[
@@ -411,7 +406,7 @@ const getKeywordValues = (filteredProperties: FilteredProperties) => {
keywords.add(commonKeyword);
}
- result[key] = [...(result[key] ?? []), ...keywords];
+ result[property] = [...(result[property] ?? []), ...keywords];
}
return result;
@@ -421,11 +416,11 @@ const getTypes = (propertiesData: typeof customData.propertiesData) => {
let types = "";
const camelCasedProperties = Object.keys(propertiesData).map((property) =>
- JSON.stringify(property)
+ JSON.stringify(camelCaseProperty(property as CssProperty))
);
types += `export type CamelCasedProperty = ${camelCasedProperties.join(" | ")};\n\n`;
const hyphenatedProperties = Object.keys(propertiesData).map((property) =>
- JSON.stringify(hyphenateProperty(property))
+ JSON.stringify(property)
);
types += `export type HyphenatedProperty = ${hyphenatedProperties.join(" | ")};\n\n`;
@@ -450,7 +445,7 @@ writeToFile("units.ts", "units", units);
const propertiesData = Object.fromEntries(
Object.entries(longhandPropertiesData).map(([property, data]) => [
- hyphenateProperty(property),
+ property,
data,
])
);
@@ -474,7 +469,7 @@ writeFileSync(join(targetDir, "properties.ts"), propertiesContent);
const keywordValues = Object.fromEntries(
Object.entries(getKeywordValues(filteredData.allLonghands)).map(
- ([property, data]) => [hyphenateProperty(property), data]
+ ([property, data]) => [property, data]
)
);
const keywordValuesContent = `${autogeneratedHint}
diff --git a/packages/css-data/src/custom-data.ts b/packages/css-data/src/custom-data.ts
index 8da6140578..8e7d5d5069 100644
--- a/packages/css-data/src/custom-data.ts
+++ b/packages/css-data/src/custom-data.ts
@@ -41,7 +41,7 @@ export type RawPropertyData = {
export const propertiesData: { [property: string]: RawPropertyData } = {};
export const keywordValues: { [property: string]: Array<string> } = {};
-propertiesData.WebkitFontSmoothing = {
+propertiesData["-webkit-font-smoothing"] = {
unitGroups: [],
inherited: true,
initial: {
@@ -50,14 +50,14 @@ propertiesData.WebkitFontSmoothing = {
},
mdnUrl: "https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth",
};
-keywordValues.WebkitFontSmoothing = [
+keywordValues["-webkit-font-smoothing"] = [
"auto",
"none",
"antialiased",
"subpixel-antialiased",
];
-propertiesData.MozOsxFontSmoothing = {
+propertiesData["-moz-osx-font-smoothing"] = {
unitGroups: [],
inherited: true,
initial: {
@@ -66,7 +66,7 @@ propertiesData.MozOsxFontSmoothing = {
},
mdnUrl: "https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth",
};
-keywordValues.MozOsxFontSmoothing = ["auto", "grayscale"];
+keywordValues["-moz-osx-font-smoothing"] = ["auto", "grayscale"];
propertiesData["-webkit-box-orient"] = {
unitGroups: [],
@@ -76,7 +76,7 @@ propertiesData["-webkit-box-orient"] = {
};
keywordValues["-webkit-box-orient"] = ["horizontal", "vertical"];
-propertiesData.viewTimelineName = {
+propertiesData["view-timeline-name"] = {
unitGroups: [],
inherited: false,
initial: {
@@ -85,8 +85,8 @@ propertiesData.viewTimelineName = {
},
mdnUrl: "https://developer.mozilla.org/en-US/docs/Web/CSS/view-timeline-name",
};
-keywordValues.viewTimelineName = [];
-propertiesData.scrollTimelineName = {
+keywordValues["view-timeline-name"] = [];
+propertiesData["scroll-timeline-name"] = {
unitGroups: [],
inherited: false,
initial: {
@@ -96,9 +96,9 @@ propertiesData.scrollTimelineName = {
mdnUrl:
"https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-timeline-name",
};
-keywordValues.scrollTimelineName = [];
+keywordValues["scroll-timeline-name"] = [];
-propertiesData.viewTimelineInset = {
+propertiesData["view-timeline-inset"] = {
unitGroups: ["length", "percentage"],
inherited: false,
initial: {
@@ -108,9 +108,9 @@ propertiesData.viewTimelineInset = {
mdnUrl:
"https://developer.mozilla.org/en-US/docs/Web/CSS/view-timeline-inset",
};
-keywordValues.viewTimelineInset = [];
+keywordValues["view-timeline-inset"] = [];
-keywordValues.listStyleType = [
+keywordValues["list-style-type"] = [
"disc",
"circle",
"square",
@@ -126,7 +126,13 @@ keywordValues.listStyleType = [
// removed auto from keywords
// fixed in webref btw
-keywordValues.textWrapMode = ["wrap", "nowrap", "initial", "inherit", "unset"];
+keywordValues["text-wrap-mode"] = [
+ "wrap",
+ "nowrap",
+ "initial",
+ "inherit",
+ "unset",
+];
export const customLonghandPropertyNames = [
"boxShadowOffsetX",
diff --git a/packages/css-data/src/parse-css-value.test.ts b/packages/css-data/src/parse-css-value.test.ts
index 78477fc3da..d85cad31d7 100644
--- a/packages/css-data/src/parse-css-value.test.ts
+++ b/packages/css-data/src/parse-css-value.test.ts
@@ -332,7 +332,7 @@ test("parse transition-timing-function property", () => {
value: "ease, testing",
});
expect(
- parseCssValue("transitionTimingFunction", "linear(0 0%, 1 100%)")
+ parseCssValue("transition-timing-function", "linear(0 0%, 1 100%)")
).toEqual({
type: "layers",
value: [{ type: "unparsed", value: "linear(0 0%,1 100%)" }],
@@ -377,7 +377,7 @@ test("parse unknown properties as unparsed", () => {
}
);
expect(
- parseCssValue("animationTimingFunction", "linear(0 0%, 1 100%)")
+ parseCssValue("animation-timing-function", "linear(0 0%, 1 100%)")
).toEqual({ type: "unparsed", value: "linear(0 0%, 1 100%)" });
});
diff --git a/packages/css-data/src/parse-css-value.ts b/packages/css-data/src/parse-css-value.ts
index 36d21625da..0a887423b3 100644
--- a/packages/css-data/src/parse-css-value.ts
+++ b/packages/css-data/src/parse-css-value.ts
@@ -3,7 +3,6 @@ import { type CssNode, generate, lexer, List, parse } from "css-tree";
import warnOnce from "warn-once";
import {
cssWideKeywords,
- hyphenateProperty,
type ImageValue,
type KeywordValue,
type LayersValue,
@@ -17,7 +16,6 @@ import {
type FunctionValue,
type TupleValueItem,
type CssProperty,
- type StyleProperty,
} from "@webstudio-is/css-engine";
import { keywordValues } from "./__generated__/keyword-values";
import { units } from "./__generated__/units";
@@ -46,11 +44,9 @@ const splitRepeated = (nodes: CssNode[]) => {
// Because csstree parser has bugs we use CSSStyleValue to validate css properties if available
// and fall back to csstree.
export const isValidDeclaration = (
- property: string,
+ property: CssProperty,
value: string
): boolean => {
- const cssPropertyName = hyphenateProperty(property);
-
if (property.startsWith("--") || value.includes("var(")) {
return true;
}
@@ -59,14 +55,14 @@ export const isValidDeclaration = (
// though rendered styles are merged as shorthand
// so validate artifically
if (
- cssPropertyName === "white-space-collapse" ||
- cssPropertyName === "text-wrap-mode" ||
- cssPropertyName === "text-wrap-style"
+ property === "white-space-collapse" ||
+ property === "text-wrap-mode" ||
+ property === "text-wrap-style"
) {
- return keywordValues[cssPropertyName].includes(value);
+ return keywordValues[property].includes(value);
}
- if (cssPropertyName === "transition-behavior") {
+ if (property === "transition-behavior") {
return true;
}
@@ -75,7 +71,7 @@ export const isValidDeclaration = (
// - https://github.com/csstree/csstree/issues/164
if (typeof CSSStyleValue !== "undefined") {
try {
- CSSStyleValue.parse(cssPropertyName, value);
+ CSSStyleValue.parse(property, value);
return true;
} catch {
return false;
@@ -91,14 +87,14 @@ export const isValidDeclaration = (
// The syntax from MDN is incorrect and should be updated.
// Here is a PR that fixes the same, but it is not merged yet.
// https://github.com/mdn/data/pull/746
- if (cssPropertyName === "scale") {
+ if (property === "scale") {
const syntax = "none | [ <number> | <percentage> ]{1,3}";
return lexer.match(syntax, ast).matched !== null;
}
if (
- cssPropertyName === "transition-timing-function" ||
- cssPropertyName === "animation-timing-function"
+ property === "transition-timing-function" ||
+ property === "animation-timing-function"
) {
if (
lexer.match("linear( [ <number> && <percentage>{0,2} ]# )", ast).matched
@@ -107,7 +103,7 @@ export const isValidDeclaration = (
}
}
- const matchResult = lexer.matchProperty(cssPropertyName, ast);
+ const matchResult = lexer.matchProperty(property, ast);
// allow to parse unknown properties as unparsed
if (matchResult.error?.message.includes("Unknown property")) {
@@ -326,11 +322,10 @@ const parseLiteral = (
};
export const parseCssValue = (
- multiCaseProperty: StyleProperty | CssProperty, // Handles only long-hand values.
+ property: CssProperty, // Handles only long-hand values.
input: string,
topLevel = true
): StyleValue => {
- const property = hyphenateProperty(multiCaseProperty);
const potentialKeyword = input.toLowerCase().trim();
if (cssWideKeywords.has(potentialKeyword)) {
return { type: "keyword", value: potentialKeyword };
diff --git a/packages/css-data/src/parse-css.ts b/packages/css-data/src/parse-css.ts
index f497b8ede7..4ab42950b4 100644
--- a/packages/css-data/src/parse-css.ts
+++ b/packages/css-data/src/parse-css.ts
@@ -1,9 +1,9 @@
import { camelCase } from "change-case";
import * as csstree from "css-tree";
-import {
+import type {
StyleValue,
- type CssProperty,
- type StyleProperty,
+ CssProperty,
+ StyleProperty,
} from "@webstudio-is/css-engine";
import { parseCssValue as parseCssValueLonghand } from "./parse-css-value";
import { expandShorthands } from "./shorthands";
@@ -71,12 +71,9 @@ export const camelCaseProperty = (
return camelCase(property) as StyleProperty;
};
-const parseCssValue = (
- property: CssProperty,
- value: string
-): Map<StyleProperty, StyleValue> => {
+const parseCssValue = (property: CssProperty, value: string) => {
const expanded = new Map(expandShorthands([[property, value]]));
- const final = new Map();
+ const final = new Map<CssProperty, StyleValue>();
for (const [property, value] of expanded) {
if (value === "") {
// Keep the browser behavior when property is defined with an empty value e.g. `color:;`
diff --git a/packages/sdk-components-animation/private-src b/packages/sdk-components-animation/private-src
index d17da84813..bc17045f23 160000
--- a/packages/sdk-components-animation/private-src
+++ b/packages/sdk-components-animation/private-src
@@ -1 +1 @@
-Subproject commit d17da8481348a4fa0e1545d16c63fdd35798e4f8
+Subproject commit bc17045f232d95176d6317d655e06abb92ed6356