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: parse complex values with available parsers for sections (#3319)
Jaya Krishna Namburuc1961506d4c5
diff --git a/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx b/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsxindex b34e2df7ee..1d89a74c2b 100644--- a/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx@@ -160,12 +160,12 @@ export const Section = ({styleSource={getStyleSource(currentStyle[property])}keywords={keywords}value={currentStyle[property]?.value}- setValue={(styleValue, options) => {+ setValue={(styleValue, options) =>setProperty(property)(styleValue, {...options,listed: true,- });- }}+ })+ }deleteProperty={deleteProperty}/></Flex>diff --git a/apps/builder/app/builder/features/style-panel/sections/box-shadows/box-shadows.tsx b/apps/builder/app/builder/features/style-panel/sections/box-shadows/box-shadows.tsxindex cd16ac1606..6283cb31d6 100644--- a/apps/builder/app/builder/features/style-panel/sections/box-shadows/box-shadows.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/box-shadows/box-shadows.tsx@@ -29,8 +29,11 @@ const INITIAL_BOX_SHADOW = "0px 2px 5px 0px rgba(0, 0, 0, 0.2)";export const Section = (props: SectionProps) => {const { currentStyle, deleteProperty } = props;const [isOpen, setIsOpen] = useState(true);- const layersStyleSource = getStyleSource(currentStyle[property]);const value = currentStyle[property]?.value;+ const sectionStyleSource =+ value?.type === "unparsed" || value?.type === "guaranteedInvalid"+ ? undefined+ : getStyleSource(currentStyle[property]);return (<CollapsibleSectionRoot@@ -62,7 +65,7 @@ export const Section = (props: SectionProps) => {properties={properties}description="Adds shadow effects around an element's frame."label={- <SectionTitleLabel color={layersStyleSource}>+ <SectionTitleLabel color={sectionStyleSource}>{label}</SectionTitleLabel>}diff --git a/apps/builder/app/builder/features/style-panel/sections/filter/filter.tsx b/apps/builder/app/builder/features/style-panel/sections/filter/filter.tsxindex 9db09ede1c..e6e1b821f1 100644--- a/apps/builder/app/builder/features/style-panel/sections/filter/filter.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/filter/filter.tsx@@ -30,8 +30,11 @@ const INITIAL_FILTER = "blur(0px)";export const Section = (props: SectionProps) => {const { currentStyle, deleteProperty } = props;const [isOpen, setIsOpen] = useState(true);- const layerStyleSource = getStyleSource(currentStyle[property]);const value = currentStyle[property]?.value;+ const sectionStyleSource =+ value?.type === "unparsed" || value?.type === "guaranteedInvalid"+ ? undefined+ : getStyleSource(currentStyle[property]);return (<CollapsibleSectionRoot@@ -41,7 +44,7 @@ export const Section = (props: SectionProps) => {onOpenChange={setIsOpen}trigger={<SectionTitle- dots={getDots(currentStyle, [property])}+ dots={getDots(currentStyle, properties)}suffix={<Tooltip content={"Add a filter"}><SectionTitleButton@@ -65,7 +68,7 @@ export const Section = (props: SectionProps) => {properties={properties}description="Filter effects allow you to apply graphical effects like blurring, color shifting, and more to elements."label={- <SectionTitleLabel color={layerStyleSource}>+ <SectionTitleLabel color={sectionStyleSource}>{label}</SectionTitleLabel>}diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.tsxindex d9829b732d..991f572b76 100644--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.tsx@@ -32,8 +32,11 @@ const INITIAL_TRANSITION = "opacity 200ms ease";export const Section = (props: SectionProps) => {const { currentStyle, deleteProperty } = props;const [isOpen, setIsOpen] = useState(true);- const layersStyleSource = getStyleSource(currentStyle[property]);const value = currentStyle[property]?.value;+ const sectionStyleSource =+ value?.type === "unparsed" || value?.type === "guaranteedInvalid"+ ? undefined+ : getStyleSource(currentStyle[property]);const selectedOrLastStyleSourceSelector = useStore($selectedOrLastStyleSourceSelector@@ -82,7 +85,7 @@ export const Section = (props: SectionProps) => {description="Animate the transition between states on this instance."properties={properties}label={- <SectionTitleLabel color={layersStyleSource}>+ <SectionTitleLabel color={sectionStyleSource}>{label}</SectionTitleLabel>}diff --git a/apps/builder/app/builder/features/style-panel/shared/collapsible-section.tsx b/apps/builder/app/builder/features/style-panel/shared/collapsible-section.tsxindex 20323b8570..d269a672c9 100644--- a/apps/builder/app/builder/features/style-panel/shared/collapsible-section.tsx+++ b/apps/builder/app/builder/features/style-panel/shared/collapsible-section.tsx@@ -19,7 +19,17 @@ export const getDots = (const dots = new Set<"local" | "overwritten" | "remote">();for (const property of properties) {- const source = getStyleSource(currentStyle[property]);+ const style = currentStyle[property];++ // Unparsed values are not editable directly in the section, so we don't show the dot+ if (+ style?.value.type === "unparsed" ||+ style?.value.type === "guaranteedInvalid"+ ) {+ return;+ }++ const source = getStyleSource(style);if (source === "local" || source === "overwritten" || source === "remote") {dots.add(source);}diff --git a/packages/css-data/src/parse-css-value.ts b/packages/css-data/src/parse-css-value.tsindex 0c5523755d..f96565d649 100644--- a/packages/css-data/src/parse-css-value.ts+++ b/packages/css-data/src/parse-css-value.ts@@ -10,6 +10,7 @@ import {} from "@webstudio-is/css-engine";import { keywordValues } from "./__generated__/keyword-values";import { units } from "./__generated__/units";+import { parseFilter, parseShadow, parseTransition } from "./property-parsers";export const cssTryParseValue = (input: string) => {try {@@ -78,6 +79,18 @@ export const parseCssValue = (return invalidValue;}+ if (property === "filter" || property === "backdropFilter") {+ return parseFilter(input);+ }++ if (property === "boxShadow" || property === "textShadow") {+ return parseShadow(property, input);+ }++ if (property === "transition") {+ return parseTransition(input);+ }+if (ast != null &&ast.type === "Value" &&