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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
feat: Updated initial units list (#3148)
Oleg Isonen05292c9eaf03
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select-options.ts b/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select-options.tsindex e360605453..996a5ea9e0 100644--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select-options.ts+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select-options.ts@@ -14,6 +14,10 @@ const preferedSorting = [...units.percentage,"em","rem",+ "svw",+ "svh",+ "lvw",+ "lvh","dvw","dvh",...units.length,@@ -26,7 +30,16 @@ const preferedSorting = [...units.time,];-const visibleLengthUnits = ["px", "em", "rem", "dvw", "dvh"] as const;+const initialLengthUnits = [+ "px",+ "em",+ "rem",+ "ch",+ "svw",+ "svh",+ "lvw",+ "lvh",+] as const;export const buildOptions = (property: string,@@ -56,7 +69,7 @@ export const buildOptions = (}const visibleUnits =- unitGroup === "length" ? visibleLengthUnits : units[unitGroup];+ unitGroup === "length" ? initialLengthUnits : units[unitGroup];for (const unit of visibleUnits) {options.push({id: unit,diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.test.ts b/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.test.tsindex d1ddaab778..c198130b52 100644--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.test.ts+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.test.ts@@ -12,44 +12,59 @@ describe("Unit menu options", () => {nestedSelectButtonUnitless)).toMatchInlineSnapshot(`- [- {- "id": "px",- "label": "px",- "type": "unit",- },- {- "id": "%",- "label": "%",- "type": "unit",- },- {- "id": "em",- "label": "em",- "type": "unit",- },- {- "id": "rem",- "label": "rem",- "type": "unit",- },- {- "id": "dvw",- "label": "dvw",- "type": "unit",- },- {- "id": "dvh",- "label": "dvh",- "type": "unit",- },- {- "id": "auto",- "label": "auto",- "type": "keyword",- },- ]- `);+[+ {+ "id": "px",+ "label": "px",+ "type": "unit",+ },+ {+ "id": "%",+ "label": "%",+ "type": "unit",+ },+ {+ "id": "em",+ "label": "em",+ "type": "unit",+ },+ {+ "id": "rem",+ "label": "rem",+ "type": "unit",+ },+ {+ "id": "svw",+ "label": "svw",+ "type": "unit",+ },+ {+ "id": "svh",+ "label": "svh",+ "type": "unit",+ },+ {+ "id": "lvw",+ "label": "lvw",+ "type": "unit",+ },+ {+ "id": "lvh",+ "label": "lvh",+ "type": "unit",+ },+ {+ "id": "ch",+ "label": "ch",+ "type": "unit",+ },+ {+ "id": "auto",+ "label": "auto",+ "type": "keyword",+ },+]+`);});test("Should show options with unitless if value supports unitless", () => {@@ -70,44 +85,59 @@ describe("Unit menu options", () => {nestedSelectButtonUnitless)).toMatchInlineSnapshot(`- [- {- "id": "px",- "label": "px",- "type": "unit",- },- {- "id": "%",- "label": "%",- "type": "unit",- },- {- "id": "em",- "label": "em",- "type": "unit",- },- {- "id": "rem",- "label": "rem",- "type": "unit",- },- {- "id": "dvw",- "label": "dvw",- "type": "unit",- },- {- "id": "dvh",- "label": "dvh",- "type": "unit",- },- {- "id": "auto",- "label": "auto",- "type": "keyword",- },- ]- `);+[+ {+ "id": "px",+ "label": "px",+ "type": "unit",+ },+ {+ "id": "%",+ "label": "%",+ "type": "unit",+ },+ {+ "id": "em",+ "label": "em",+ "type": "unit",+ },+ {+ "id": "rem",+ "label": "rem",+ "type": "unit",+ },+ {+ "id": "svw",+ "label": "svw",+ "type": "unit",+ },+ {+ "id": "svh",+ "label": "svh",+ "type": "unit",+ },+ {+ "id": "lvw",+ "label": "lvw",+ "type": "unit",+ },+ {+ "id": "lvh",+ "label": "lvh",+ "type": "unit",+ },+ {+ "id": "ch",+ "label": "ch",+ "type": "unit",+ },+ {+ "id": "auto",+ "label": "auto",+ "type": "keyword",+ },+]+`);});test("Should add unit to options even if it's not in a visibleLengthUnits", () => {