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.

feat: Add UI section for filters and backdrop-filters (#3348)

Jaya Krishna Namburuef01841b6fa6
diff --git a/apps/builder/app/builder/features/style-panel/sections/backdrop-filter/backdrop-filter.tsx b/apps/builder/app/builder/features/style-panel/sections/backdrop-filter/backdrop-filter.tsx
index 54f1a78a75..a800a7da45 100644
--- a/apps/builder/app/builder/features/style-panel/sections/backdrop-filter/backdrop-filter.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/backdrop-filter/backdrop-filter.tsx
@@ -97,7 +97,7 @@ export const Section = (props: SectionProps) => {
content={
<Flex gap="2" direction="column">
<Text variant="regularBold">{label}</Text>
- <Text variant="monoBold">filter</Text>
+ <Text variant="monoBold">backdrop-filter</Text>
<Text>
Applies graphical effects like blur or color shift to
the area behind an element
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.tsx
index ddb9b68094..37a4018497 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
@@ -88,6 +88,7 @@ export const Section = (props: SectionProps) => {
<ShadowContent
{...layerProps}
layer={layerProps.layer}
+ property={property}
tooltip={
<Tooltip
variant="wrapped"
diff --git a/apps/builder/app/builder/features/style-panel/sections/text-shadows/text-shadows.tsx b/apps/builder/app/builder/features/style-panel/sections/text-shadows/text-shadows.tsx
index b3fe0c9b7c..5f92aa8ec0 100644
--- a/apps/builder/app/builder/features/style-panel/sections/text-shadows/text-shadows.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/text-shadows/text-shadows.tsx
@@ -88,6 +88,7 @@ export const Section = (props: SectionProps) => {
<ShadowContent
{...layerProps}
layer={layerProps.layer}
+ property={property}
tooltip={
<Tooltip
variant="wrapped"
diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx
index d66b77588c..b8fb29e990 100644
--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-content.tsx
@@ -39,7 +39,11 @@ type TransitionContentProps = {
layer: TupleValue;
propertyValue: string;
tooltip: JSX.Element;
- onEditLayer: (index: number, layer: LayersValue) => void;
+ onEditLayer: (
+ index: number,
+ layer: LayersValue,
+ options: StyleUpdateOptions
+ ) => void;
deleteProperty: DeleteProperty;
};
@@ -83,7 +87,7 @@ export const TransitionContent = ({
return;
}
- onEditLayer(index, layers);
+ onEditLayer(index, layers, { isEphemeral: false });
};
const handlePropertyUpdate = (
@@ -103,9 +107,7 @@ export const TransitionContent = ({
value: toValue(newLayer),
});
- if (options.isEphemeral === false) {
- onEditLayer(index, { type: "layers", value: [newLayer] });
- }
+ onEditLayer(index, { type: "layers", value: [newLayer] }, options);
};
return (
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 fe9bb45a59..c3fd09356d 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
@@ -1,8 +1,10 @@
-import type {
- FunctionValue,
- InvalidValue,
- StyleProperty,
- TupleValue,
+import {
+ type InvalidValue,
+ type StyleProperty,
+ type TupleValue,
+ type FunctionValue,
+ toValue,
+ StyleValue,
} from "@webstudio-is/css-engine";
import {
Flex,
@@ -10,11 +12,69 @@ import {
Label,
TextArea,
textVariants,
+ Separator,
+ Select,
+ Grid,
} from "@webstudio-is/design-system";
-import { useState } from "react";
-import type { IntermediateStyleValue } from "../shared/css-value-input";
-import { parseFilter } from "@webstudio-is/css-data";
-import type { DeleteProperty } from "../shared/use-style-data";
+import { useEffect, useState } from "react";
+import {
+ CssValueInputContainer,
+ type IntermediateStyleValue,
+} from "../shared/css-value-input";
+import { parseCssValue, parseFilter } from "@webstudio-is/css-data";
+import type {
+ DeleteProperty,
+ StyleUpdateOptions,
+} from "../shared/use-style-data";
+import { ShadowContent } from "./shadow-content";
+
+// filters can't be validated directly in the css-engine. Because, these are not properties
+// but functions that proeprties accept. So, we need to validate them manually using fake proeprties
+// which accepts the same values as the filter functions. This is a bit hacky but it works.
+//
+// https://developer.mozilla.org/en-US/docs/Web/CSS/opacity#syntax
+// number | percentage
+//
+// https://developer.mozilla.org/en-US/docs/Web/CSS/outline-offset#syntax
+// length
+// https://developer.mozilla.org/en-US/docs/Web/CSS/rotate#formal_syntax
+// angle
+
+const filterFunctions = {
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/blur#syntax
+ // length
+ blur: { default: "0px", fakeProperty: "outlineOffset" },
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/brightness#formal_syntax
+ // number | percentage
+ brightness: { default: "0%", fakeProperty: "opacity" },
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/contrast#formal_syntax
+ // number | percentage
+ contrast: { default: "0%", fakeProperty: "opacity" },
+ // text-shaodw and drop-shaodow accepts the same args so we can use the same component
+ // and pass the args as value and property
+ "drop-shadow": {
+ default: "0px 2px 5px rgba(0, 0, 0, 0.2)",
+ fakeProperty: "textShadow",
+ },
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/grayscale#syntax
+ // number | percentage
+ grayscale: { default: "0%", fakeProperty: "opacity" },
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/hue-rotate#syntax
+ // angle
+ "hue-rotate": { default: "0deg", fakeProperty: "rotate" },
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/invert#syntax
+ // number | percentage
+ invert: { default: "0%", fakeProperty: "opacity" },
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/opacity#syntax
+ // number | percentage
+ opacity: { default: "0%", fakeProperty: "opacity" },
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/saturate#syntax
+ // number | percentage
+ saturate: { default: "0%", fakeProperty: "opacity" },
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/sepia#parameters
+ // number | percentage
+ sepia: { default: "0%", fakeProperty: "opacity" },
+} as const;
type FilterContentProps = {
index: number;
@@ -22,10 +82,19 @@ type FilterContentProps = {
layer: FunctionValue;
propertyValue: string;
tooltip: JSX.Element;
- onEditLayer: (index: number, layers: TupleValue) => void;
+ onEditLayer: (
+ index: number,
+ layers: TupleValue,
+ options: StyleUpdateOptions
+ ) => void;
deleteProperty: DeleteProperty;
};
+type FilterFunction = keyof typeof filterFunctions;
+
+const isFilterFunction = (value: string): value is FilterFunction =>
+ Object.keys(filterFunctions).includes(value);
+
export const FilterSectionContent = ({
index,
property,
@@ -33,84 +102,188 @@ export const FilterSectionContent = ({
onEditLayer,
deleteProperty,
tooltip,
+ layer,
}: FilterContentProps) => {
const [intermediateValue, setIntermediateValue] = useState<
IntermediateStyleValue | InvalidValue | undefined
>();
+ const [filterFunction, setFilterFunction] = useState<
+ FilterFunction | undefined
+ >(undefined);
+ const [filterFunctionValue, setFilterFunctionValue] = useState<
+ StyleValue | undefined
+ >(undefined);
+
+ useEffect(() => {
+ if (isFilterFunction(layer.name) === false || layer.args.type !== "tuple") {
+ return;
+ }
- const handleChange = (value: string) => {
+ setFilterFunction(layer.name);
+ setFilterFunctionValue(layer.args.value[0]);
setIntermediateValue({
type: "intermediate",
- value,
+ value: propertyValue,
});
+ }, [layer, propertyValue]);
+
+ const handleFilterFunctionChange = (filterName: FilterFunction) => {
+ const defaultFilterValue = filterFunctions[filterName];
+ setFilterFunction(filterName);
+ const functionValue = parseCssValue(
+ defaultFilterValue.fakeProperty,
+ defaultFilterValue.default
+ );
+
+ setFilterFunctionValue(functionValue);
+ handleComplete(`${filterName}(${toValue(functionValue)})`);
};
- const handleComplete = () => {
- if (intermediateValue === undefined) {
- return;
- }
+ const handleFilterFunctionValueChange = (
+ value: StyleValue,
+ options: StyleUpdateOptions = { isEphemeral: false }
+ ) => {
+ setFilterFunctionValue(value);
+ handleComplete(`${filterFunction}(${toValue(value)})`, options);
+ };
+
+ const handleComplete = (
+ value: string,
+ options: StyleUpdateOptions = { isEphemeral: false }
+ ) => {
+ const layers = parseFilter(value);
+ setIntermediateValue({
+ type: layers.type === "invalid" ? "invalid" : "intermediate",
+ value,
+ });
- const layers = parseFilter(intermediateValue.value);
if (layers.type === "invalid") {
- setIntermediateValue({
- type: "invalid",
- value: intermediateValue.value,
- });
return;
}
- onEditLayer(index, layers);
+ onEditLayer(index, layers, options);
};
return (
- <Flex
- direction="column"
- css={{
- px: theme.spacing[9],
- paddingTop: theme.spacing[5],
- paddingBottom: theme.spacing[9],
- gap: theme.spacing[3],
- minWidth: theme.spacing[30],
- }}
- >
- <Label>
- <Flex align={"center"} gap={1}>
- Code
- {tooltip}
- </Flex>
- </Label>
- {
- // @todo Replace the TextArea with code-editor.
- // For more details, please refer to the issue
- // https://github.com/webstudio-is/webstudio/issues/2977
- }
- <TextArea
- rows={3}
- name="description"
- value={intermediateValue?.value ?? propertyValue ?? ""}
- css={{ minHeight: theme.spacing[14], ...textVariants.mono }}
- color={intermediateValue?.type === "invalid" ? "error" : undefined}
- onChange={handleChange}
- onKeyDown={(event) => {
- if (event.key === "Enter") {
- handleComplete();
- // On pressing Enter, the textarea is creating a new line.
- // In-order to prevent it and update the content.
- // We prevent the default behaviour
- event.preventDefault();
- }
+ <Flex direction="column">
+ <Flex direction="column" css={{ px: theme.spacing[9] }}>
+ <Grid
+ gap="2"
+ css={{
+ marginTop: theme.spacing[5],
+ paddingBottom: theme.spacing[5],
+ gridTemplateColumns: "1fr 3fr",
+ alignItems: "center",
+ }}
+ >
+ <Flex align="center">
+ <Label>Function</Label>
+ </Flex>
+ <Select
+ name="filterFunction"
+ placeholder="Select Filter"
+ options={Object.keys(filterFunctions) as FilterFunction[]}
+ value={filterFunction ?? "blur"}
+ onChange={handleFilterFunctionChange}
+ />
+ </Grid>
+ {filterFunction !== "drop-shadow" ? (
+ <Grid
+ gap="2"
+ css={{
+ marginTop: theme.spacing[5],
+ paddingBottom: theme.spacing[5],
+ gridTemplateColumns: "1fr 3fr",
+ alignItems: "center",
+ }}
+ >
+ <Flex align="center">
+ <Label>Value</Label>
+ </Flex>
+ <CssValueInputContainer
+ key="functionValue"
+ property={
+ filterFunction
+ ? filterFunctions[filterFunction].fakeProperty
+ : "outlineOffset"
+ }
+ styleSource="local"
+ value={
+ filterFunctionValue ?? {
+ type: "unit",
+ value: 0,
+ unit: "px",
+ }
+ }
+ keywords={[]}
+ setValue={handleFilterFunctionValueChange}
+ deleteProperty={deleteProperty}
+ />
+ </Grid>
+ ) : undefined}
+ </Flex>
- if (event.key === "Escape") {
- if (intermediateValue === undefined) {
- return;
- }
+ {filterFunction === "drop-shadow" && layer.args.type === "tuple" ? (
+ <ShadowContent
+ index={index}
+ property="textShadow"
+ layer={layer.args}
+ tooltip={<></>}
+ propertyValue={toValue(layer.args)}
+ onEditLayer={(_, dropShadowLayers, options) => {
+ handleComplete(
+ `drop-shadow(${toValue(dropShadowLayers)})`,
+ options
+ );
+ }}
+ deleteProperty={() => {}}
+ hideCodeEditor={true}
+ />
+ ) : undefined}
- deleteProperty(property, { isEphemeral: true });
- setIntermediateValue(undefined);
- event.preventDefault();
- }
+ <Separator css={{ gridAutoColumns: "span 2" }} />
+ <Flex
+ direction="column"
+ css={{
+ px: theme.spacing[9],
+ paddingTop: theme.spacing[5],
+ paddingBottom: theme.spacing[9],
+ gap: theme.spacing[3],
+ minWidth: theme.spacing[30],
}}
- />
+ >
+ <Label>
+ <Flex align={"center"} gap={1}>
+ Code
+ {tooltip}
+ </Flex>
+ </Label>
+ <TextArea
+ rows={3}
+ name="description"
+ value={intermediateValue?.value ?? ""}
+ css={{ minHeight: theme.spacing[14], ...textVariants.mono }}
+ color={intermediateValue?.type === "invalid" ? "error" : undefined}
+ onChange={(value) =>
+ setIntermediateValue({ type: "intermediate", value })
+ }
+ onKeyDown={(event) => {
+ if (event.key === "Enter" && intermediateValue !== undefined) {
+ handleComplete(intermediateValue.value);
+ // On pressing Enter, the textarea is creating a new line.
+ // In-order to prevent it and update the content.
+ // We prevent the default behaviour
+ event.preventDefault();
+ }
+
+ if (event.key === "Escape") {
+ deleteProperty(property, { isEphemeral: true });
+ setIntermediateValue(undefined);
+ event.preventDefault();
+ }
+ }}
+ />
+ </Flex>
</Flex>
);
};
diff --git a/apps/builder/app/builder/features/style-panel/shared/shadow-content.tsx b/apps/builder/app/builder/features/style-panel/shared/shadow-content.tsx
index e7991f8402..ac3fee29fc 100644
--- a/apps/builder/app/builder/features/style-panel/shared/shadow-content.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/shadow-content.tsx
@@ -3,7 +3,6 @@ import {
type InvalidValue,
type LayersValue,
type RgbValue,
- type StyleProperty,
type StyleValue,
type TupleValue,
type UnitValue,
@@ -32,7 +31,11 @@ import type { IntermediateStyleValue } from "../shared/css-value-input";
import { CssValueInputContainer } from "../shared/css-value-input";
import { toPascalCase } from "../shared/keyword-utils";
import { ColorControl } from "../controls";
-import type { DeleteProperty, SetProperty } from "../shared/use-style-data";
+import type {
+ DeleteProperty,
+ SetProperty,
+ StyleUpdateOptions,
+} from "../shared/use-style-data";
/*
When it comes to checking and validating individual CSS properties for the box-shadow,
@@ -60,12 +63,17 @@ import type { DeleteProperty, SetProperty } from "../shared/use-style-data";
type ShadowContentProps = {
index: number;
- property: StyleProperty;
+ property: "boxShadow" | "textShadow";
layer: TupleValue;
propertyValue: string;
tooltip: JSX.Element;
- onEditLayer: (index: number, layers: LayersValue) => void;
+ onEditLayer: (
+ index: number,
+ layers: LayersValue,
+ options: StyleUpdateOptions
+ ) => void;
deleteProperty: DeleteProperty;
+ hideCodeEditor?: boolean;
};
const convertValuesToTupple = (
@@ -91,6 +99,7 @@ export const ShadowContent = ({
property,
propertyValue,
tooltip,
+ hideCodeEditor = false,
onEditLayer,
deleteProperty,
}: ShadowContentProps) => {
@@ -122,7 +131,7 @@ export const ShadowContent = ({
if (intermediateValue === undefined) {
return;
}
- const layers = parseShadow("boxShadow", intermediateValue.value);
+ const layers = parseShadow(property, intermediateValue.value);
if (layers.type === "invalid") {
setIntermediateValue({
type: "invalid",
@@ -131,23 +140,24 @@ export const ShadowContent = ({
return;
}
- onEditLayer(index, layers);
+ onEditLayer(index, layers, { isEphemeral: false });
};
const handlePropertyChange = (
- params: Partial<Record<keyof ExtractedShadowProperties, StyleValue>>
+ params: Partial<Record<keyof ExtractedShadowProperties, StyleValue>>,
+ options: StyleUpdateOptions = { isEphemeral: false }
) => {
const newLayer = convertValuesToTupple({ ...layerValues, ...params });
setIntermediateValue({
type: "intermediate",
value: toValue(newLayer),
});
- onEditLayer(index, { type: "layers", value: [newLayer] });
+ onEditLayer(index, { type: "layers", value: [newLayer] }, options);
};
const colorControlCallback: SetProperty = () => {
- return (value) => {
- handlePropertyChange({ color: value });
+ return (value, options) => {
+ handlePropertyChange({ color: value }, options);
};
};
@@ -185,7 +195,9 @@ export const ShadowContent = ({
styleSource="local"
keywords={[]}
value={offsetX ?? { type: "unit", value: 0, unit: "px" }}
- setValue={(value) => handlePropertyChange({ offsetX: value })}
+ setValue={(value, options) =>
+ handlePropertyChange({ offsetX: value }, options)
+ }
deleteProperty={() =>
handlePropertyChange({
offsetX: offsetX ?? undefined,
@@ -217,7 +229,9 @@ export const ShadowContent = ({
styleSource="local"
keywords={[]}
value={offsetY ?? { type: "unit", value: 0, unit: "px" }}
- setValue={(value) => handlePropertyChange({ offsetY: value })}
+ setValue={(value, options) =>
+ handlePropertyChange({ offsetY: value }, options)
+ }
deleteProperty={() =>
handlePropertyChange({
offsetY: offsetY ?? undefined,
@@ -249,7 +263,9 @@ export const ShadowContent = ({
styleSource="local"
keywords={[]}
value={blur ?? { type: "unit", value: 0, unit: "px" }}
- setValue={(value) => handlePropertyChange({ blur: value })}
+ setValue={(value, options) =>
+ handlePropertyChange({ blur: value }, options)
+ }
deleteProperty={() =>
handlePropertyChange({
blur: blur ?? undefined,
@@ -282,7 +298,9 @@ export const ShadowContent = ({
styleSource="local"
keywords={[]}
value={spread ?? { type: "unit", value: 0, unit: "px" }}
- setValue={(value) => handlePropertyChange({ spread: value })}
+ setValue={(value, options) =>
+ handlePropertyChange({ spread: value }, options)
+ }
deleteProperty={() =>
handlePropertyChange({
spread: spread ?? undefined,
@@ -373,48 +391,50 @@ export const ShadowContent = ({
) : null}
</Grid>
- <Separator css={{ gridColumn: "span 2" }} />
- <Flex
- direction="column"
- css={{
- px: theme.spacing[9],
- paddingTop: theme.spacing[5],
- paddingBottom: theme.spacing[9],
- gap: theme.spacing[3],
- minWidth: theme.spacing[30],
- }}
- >
- <Label>
- <Flex align={"center"} gap={1}>
- Code
- {tooltip}
- </Flex>
- </Label>
- <TextArea
- rows={3}
- name="description"
- value={intermediateValue?.value ?? propertyValue ?? ""}
- css={{ minHeight: theme.spacing[14], ...textVariants.mono }}
- color={intermediateValue?.type === "invalid" ? "error" : undefined}
- onChange={handleChange}
- onKeyDown={(event) => {
- if (event.key === "Enter") {
- handleComplete();
- event.preventDefault();
- }
-
- if (event.key === "Escape") {
- if (intermediateValue === undefined) {
- return;
+ {hideCodeEditor === false ? (
+ <>
+ <Separator css={{ gridColumn: "span 2" }} />
+ <Flex
+ direction="column"
+ css={{
+ px: theme.spacing[9],
+ paddingTop: theme.spacing[5],
+ paddingBottom: theme.spacing[9],
+ gap: theme.spacing[3],
+ minWidth: theme.spacing[30],
+ }}
+ >
+ <Label>
+ <Flex align={"center"} gap={1}>
+ Code
+ {tooltip}
+ </Flex>
+ </Label>
+ <TextArea
+ rows={3}
+ name="description"
+ value={intermediateValue?.value ?? propertyValue ?? ""}
+ css={{ minHeight: theme.spacing[14], ...textVariants.mono }}
+ color={
+ intermediateValue?.type === "invalid" ? "error" : undefined
}
+ onChange={handleChange}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") {
+ handleComplete();
+ event.preventDefault();
+ }
- deleteProperty(property, { isEphemeral: true });
- setIntermediateValue(undefined);
- event.preventDefault();
- }
- }}
- />
- </Flex>
+ if (event.key === "Escape") {
+ deleteProperty(property, { isEphemeral: true });
+ setIntermediateValue(undefined);
+ event.preventDefault();
+ }
+ }}
+ />
+ </Flex>
+ </>
+ ) : undefined}
</Flex>
);
};
diff --git a/apps/builder/app/builder/features/style-panel/style-layer-utils.test.ts b/apps/builder/app/builder/features/style-panel/style-layer-utils.test.ts
index f552ae672c..f9c63f8c1f 100644
--- a/apps/builder/app/builder/features/style-panel/style-layer-utils.test.ts
+++ b/apps/builder/app/builder/features/style-panel/style-layer-utils.test.ts
@@ -309,7 +309,9 @@ describe("boxShadowUtils", () => {
],
};
- updateLayer(property, newLayer, oldLayers, 0, createBatchUpdate);
+ updateLayer(property, newLayer, oldLayers, 0, createBatchUpdate, {
+ isEphemeral: false,
+ });
const boxShadow = styleInfo["boxShadow"]?.value as LayersValue;
expect(boxShadow).toBeDefined();
expect(boxShadow.value[0]).toBe(newLayer.value[0]);
diff --git a/apps/builder/app/builder/features/style-panel/style-layer-utils.ts b/apps/builder/app/builder/features/style-panel/style-layer-utils.ts
index 1829c6e9bf..dab2e2d801 100644
--- a/apps/builder/app/builder/features/style-panel/style-layer-utils.ts
+++ b/apps/builder/app/builder/features/style-panel/style-layer-utils.ts
@@ -6,7 +6,10 @@ import type {
} from "@webstudio-is/css-engine";
import type { SectionProps } from "./sections";
import type { StyleInfo } from "./shared/style-info";
-import type { CreateBatchUpdate } from "./shared/use-style-data";
+import type {
+ CreateBatchUpdate,
+ StyleUpdateOptions,
+} from "./shared/use-style-data";
export const deleteLayer = <T extends TupleValue | LayersValue>(
property: StyleProperty,
@@ -104,7 +107,8 @@ export const updateLayer = <T extends LayersValue | TupleValue>(
newValue: T,
oldValue: T,
index: number,
- createBatchUpdate: SectionProps["createBatchUpdate"]
+ createBatchUpdate: SectionProps["createBatchUpdate"],
+ options: StyleUpdateOptions
) => {
const batch = createBatchUpdate();
const newLayers = [...oldValue.value];
@@ -122,7 +126,7 @@ export const updateLayer = <T extends LayersValue | TupleValue>(
};
batch.setProperty(property)(newPropertyValue);
- batch.publish();
+ batch.publish(options);
};
export const getLayerCount = (property: StyleProperty, style: StyleInfo) => {
diff --git a/apps/builder/app/builder/features/style-panel/style-layers-list.tsx b/apps/builder/app/builder/features/style-panel/style-layers-list.tsx
index e35b827c47..08f3bbf9f2 100644
--- a/apps/builder/app/builder/features/style-panel/style-layers-list.tsx
+++ b/apps/builder/app/builder/features/style-panel/style-layers-list.tsx
@@ -23,7 +23,10 @@ import {
updateLayer,
} from "./style-layer-utils";
import { useMemo } from "react";
-import type { DeleteProperty } from "./shared/use-style-data";
+import type {
+ DeleteProperty,
+ StyleUpdateOptions,
+} from "./shared/use-style-data";
import { FloatingPanel } from "~/builder/shared/floating-panel";
import {
EyeconClosedIcon,
@@ -44,7 +47,11 @@ type LayerListProps = SectionProps & {
property: StyleProperty;
propertyValue: string;
onDeleteLayer: (index: number) => void;
- onEditLayer: (index: number, layers: TupleValue | LayersValue) => void;
+ onEditLayer: (
+ index: number,
+ layers: TupleValue | LayersValue,
+ options: StyleUpdateOptions
+ ) => void;
deleteProperty: DeleteProperty;
}) => JSX.Element;
};
@@ -120,8 +127,19 @@ export const LayersList = ({
return hideLayer(property, index, value, createBatchUpdate);
};
- const onEditLayer = (index: number, newLayers: TupleValue | LayersValue) => {
- return updateLayer(property, newLayers, value, index, createBatchUpdate);
+ const onEditLayer = (
+ index: number,
+ newLayers: TupleValue | LayersValue,
+ options: StyleUpdateOptions
+ ) => {
+ return updateLayer(
+ property,
+ newLayers,
+ value,
+ index,
+ createBatchUpdate,
+ options
+ );
};
return (
diff --git a/packages/css-data/src/property-parsers/filter.ts b/packages/css-data/src/property-parsers/filter.ts
index e288978201..c36f1ab616 100644
--- a/packages/css-data/src/property-parsers/filter.ts
+++ b/packages/css-data/src/property-parsers/filter.ts
@@ -28,7 +28,7 @@ export const parseFilter = (input: string): TupleValue | InvalidValue => {
for (const cleanupKeyword of cleanupKeywords) {
tokenStream = tokenStream.startsWith(cleanupKeyword)
? tokenStream.slice(cleanupKeyword.length).trim()
- : tokenStream;
+ : tokenStream.trim();
}
const cssAst = cssTryParseValue(tokenStream);
@@ -39,7 +39,7 @@ export const parseFilter = (input: string): TupleValue | InvalidValue => {
};
}
- const isValidFilterDecleration = isValidDeclaration("filter", input);
+ const isValidFilterDecleration = isValidDeclaration("filter", tokenStream);
if (isValidFilterDecleration === false) {
return {
type: "invalid",