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
refactor: add repeated style control (#3717)
Bogdan Chadkin966568953802
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.tsxindex 2eb17289ec..e0539badb2 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@@ -1,4 +1,4 @@-import { useMemo, useState } from "react";+import { useState } from "react";import {toValue,type InvalidValue,@@ -22,13 +22,11 @@ import {Grid,} from "@webstudio-is/design-system";import {- extractTransitionProperties,parseCssValue,type ExtractedTransitionProperties,} from "@webstudio-is/css-data";import type {CreateBatchUpdate,- DeleteProperty,StyleUpdateOptions,} from "../../shared/use-style-data";import { type IntermediateStyleValue } from "../../shared/css-value-input";@@ -41,22 +39,14 @@ import {defaultTransitionTimingFunction,defaultTransitionDelay,deleteTransitionLayer,+ editTransitionLayer,} from "./transition-utils";import type { StyleInfo } from "../../shared/style-info";import { parseCssFragment } from "../../shared/parse-css-fragment";+import { InfoCircleIcon } from "@webstudio-is/icons";type TransitionContentProps = {index: number;- property: StyleProperty;- layer: TupleValue;- propertyValue: string;- tooltip: JSX.Element;- onEditLayer: (- index: number,- layer: LayersValue,- options: StyleUpdateOptions- ) => void;- deleteProperty: DeleteProperty;currentStyle: StyleInfo;createBatchUpdate: CreateBatchUpdate;};@@ -70,23 +60,44 @@ const getLayer = (value: undefined | StyleValue, index: number) =>value?.type === "layers" ? value.value[index] : undefined;export const TransitionContent = ({- layer,index,- tooltip,- onEditLayer,- propertyValue,createBatchUpdate,currentStyle,}: TransitionContentProps) => {+ const onEditLayer = (+ index: number,+ layers: LayersValue,+ options: StyleUpdateOptions+ ) => {+ editTransitionLayer({+ index,+ layers,+ options,+ createBatchUpdate,+ currentStyle,+ });+ };++ const property = getLayer(currentStyle.transitionProperty?.value, index);+ const duration = getLayer(currentStyle.transitionDuration?.value, index);+ const timingFunction = getLayer(+ currentStyle.transitionTimingFunction?.value,+ index+ );+ const delay = getLayer(currentStyle.transitionDelay?.value, index);+ const behavior = getLayer(currentStyle.transitionBehavior?.value, index);+const [intermediateValue, setIntermediateValue] = useState<IntermediateStyleValue | InvalidValue | undefined- >({ type: "intermediate", value: propertyValue });-- const { property, timing, delay, duration } =- useMemo<ExtractedTransitionProperties>(- () => extractTransitionProperties(layer),- [layer]- );+ >(() => ({+ type: "intermediate",+ value: toValue({+ type: "tuple",+ value: [property, duration, timingFunction, delay, behavior].filter(+ Boolean+ ) as TupleValueItem[],+ }),+ }));const handleChange = (value: string) => {setIntermediateValue({@@ -130,7 +141,7 @@ export const TransitionContent = ({options: StyleUpdateOptions = { isEphemeral: false }) => {const value: Array<UnitValue | KeywordValue> = Object.values({- ...{ property, duration, delay, timing },+ ...{ property, duration, delay, timingFunction },...params,}).filter<UnitValue | KeywordValue>((item): item is UnitValue | KeywordValue => item != null@@ -198,9 +209,7 @@ export const TransitionContent = ({styleSource="local"value={duration ?? defaultTransitionDuration}keywords={[]}- deleteProperty={() => {- handlePropertyUpdate({ duration });- }}+ deleteProperty={() => {}}setValue={(value, options) => {if (value === undefined ||@@ -238,7 +247,7 @@ export const TransitionContent = ({styleSource="local"value={delay ?? defaultTransitionDelay}keywords={[]}- deleteProperty={() => handlePropertyUpdate({ delay })}+ deleteProperty={() => {}}setValue={(value, options) => {if (value === undefined ||@@ -253,7 +262,7 @@ export const TransitionContent = ({/><TransitionTiming- timing={timing ?? defaultTransitionTimingFunction}+ timing={timingFunction ?? defaultTransitionTimingFunction}onTimingSelection={handlePropertyUpdate}/></Grid>@@ -271,7 +280,20 @@ export const TransitionContent = ({<Label><Flex align="center" gap="1">Code- {tooltip}+ <Tooltip+ variant="wrapped"+ content={+ <Text>+ Paste CSS code for a transition or part of a transition, for+ example:+ <br />+ <br />+ <Text variant="monoBold">opacity 200ms ease 0s</Text>+ </Text>+ }+ >+ <InfoCircleIcon />+ </Tooltip></Flex></Label><TextAreadiff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-property.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-property.tsxindex 0e6074d5c7..bb26dc332e 100644--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-property.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-property.tsx@@ -21,14 +21,19 @@ import {Flex,ComboboxScrollArea,} from "@webstudio-is/design-system";-import type { KeywordValue, UnparsedValue } from "@webstudio-is/css-engine";+import {+ toValue,+ type KeywordValue,+ type StyleValue,+ type UnparsedValue,+} from "@webstudio-is/css-engine";import { matchSorter } from "match-sorter";import { setUnion } from "~/shared/shim";type AnimatableProperties = (typeof animatableProperties)[number];type NameAndLabel = { name: string; label?: string };type TransitionPropertyProps = {- property: KeywordValue | UnparsedValue;+ property: StyleValue;onPropertySelection: (params: {property: KeywordValue | UnparsedValue;}) => void;@@ -44,8 +49,9 @@ export const TransitionProperty = ({property,onPropertySelection,}: TransitionPropertyProps) => {- const [inputValue, setInputValue] = useState(property.value ?? "all");- useEffect(() => setInputValue(property.value), [property.value]);+ const valueString = toValue(property);+ const [inputValue, setInputValue] = useState(valueString);+ useEffect(() => setInputValue(valueString), [valueString]);const {items,diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-timing.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-timing.tsxindex a05ace2c7c..920e382c4c 100644--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-timing.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-timing.tsx@@ -1,5 +1,6 @@import { useState, useEffect } from "react";import {+ StyleValue,toValue,type FunctionValue,type KeywordValue,@@ -26,7 +27,7 @@ import {} from "./transition-utils";type TransitionTimingProps = {- timing: KeywordValue | FunctionValue;+ timing: StyleValue;onTimingSelection: (params: { timing: KeywordValue | FunctionValue }) => void;};diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.test.ts b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.test.tsindex 8cfe68c43e..19a88c0cec 100644--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.test.ts+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.test.ts@@ -12,8 +12,6 @@ import {deleteTransitionLayer,editTransitionLayer,getTransitionProperties,- hideTransitionLayer,- swapTransitionLayers,} from "./transition-utils";import type { TransitionProperties } from "./transition-utils";import type { LayersValue } from "@webstudio-is/css-engine";@@ -195,69 +193,4 @@ describe("transition-utils", () => {`"opacity 0ms ease 0ms, width 0ms ease-in-out 0ms"`);});-- test("hide a layer from transition properties", () => {- addDefaultTransitionLayer({- createBatchUpdate,- currentStyle: styleInfo,- });-- addDefaultTransitionLayer({- createBatchUpdate,- currentStyle: styleInfo,- });-- hideTransitionLayer({- index: 1,- createBatchUpdate,- currentStyle: styleInfo,- });-- const layers = convertIndividualTransitionToLayers(- getTransitionProperties(styleInfo)- );-- expect(published).toBe(true);- expect(layers.value.length).toBe(2);- expect(toValue(layers)).toMatchInlineSnapshot(`"opacity 0ms ease 0ms"`);- });-- test("swap layer positions in transitions", () => {- addDefaultTransitionLayer({ currentStyle: styleInfo, createBatchUpdate });- addDefaultTransitionLayer({ currentStyle: styleInfo, createBatchUpdate });- editTransitionLayer({- currentStyle: styleInfo,- index: 1,- createBatchUpdate,- layers: {- type: "layers",- value: [- {- type: "tuple",- value: [- { type: "keyword", value: "width" },- { type: "keyword", value: "ease-in-out" },- ],- },- ],- },- options: { isEphemeral: false },- });- swapTransitionLayers({- oldIndex: 1,- newIndex: 0,- currentStyle: styleInfo,- createBatchUpdate,- });-- const layers = convertIndividualTransitionToLayers(- getTransitionProperties(styleInfo)- );-- expect(published).toBe(true);- expect(layers.value.length).toBe(2);- expect(toValue(layers)).toMatchInlineSnapshot(- `"width 0ms ease-in-out 0ms, opacity 0ms ease 0ms"`- );- });});diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.ts b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.tsindex ac776b4b7b..e8f0779e24 100644--- a/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.ts+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transition-utils.ts@@ -339,67 +339,3 @@ export const editTransitionLayer = (props: {batch.publish(options);};--export const swapTransitionLayers = (props: {- oldIndex: number;- newIndex: number;- createBatchUpdate: CreateBatchUpdate;- currentStyle: StyleInfo;-}) => {- const { oldIndex, newIndex, createBatchUpdate, currentStyle } = props;- const properties = getTransitionProperties(currentStyle);- const batch = createBatchUpdate();-- for (const property of transitionLongHandProperties) {- const layer = properties[property];- const layervalue = [...layer.value];-- // You can swap only if there are at least two layers- // As we are checking across multiple properties, we can't be sure- // which property don't have two layers so we are checking here.- if (layervalue.length < 2) {- continue;- }-- layervalue.splice(oldIndex, 1);- layervalue.splice(newIndex, 0, layer.value[oldIndex]);- batch.setProperty(property)({- ...layer,- value: layervalue,- });- }-- batch.publish();-};--export const hideTransitionLayer = (props: {- index: number;- createBatchUpdate: CreateBatchUpdate;- currentStyle: StyleInfo;-}) => {- const { createBatchUpdate, index, currentStyle } = props;- const properties = getTransitionProperties(currentStyle);- const batch = createBatchUpdate();-- for (const property of transitionLongHandProperties) {- const propertyLayer = properties[property];- batch.setProperty(property)({- type: "layers",- value: propertyLayer.value.map((layer, i) => {- if (- layer.type !== "keyword" &&- layer.type !== "unit" &&- layer.type !== "unparsed"- ) {- return layer;- }-- return i === index- ? { ...layer, hidden: layer.hidden ? false : true }- : layer;- }),- });- }-- batch.publish();-};diff --git a/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsx b/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsxnew file mode 100644index 0000000000..8709a108d3--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/sections/transitions/transitions.stories.tsx@@ -0,0 +1,105 @@+import { styled, theme } from "@webstudio-is/design-system";+import { useRef, useState } from "react";+import type { StyleInfo } from "../../shared/style-info";+import type {+ CreateBatchUpdate,+ DeleteProperty,+ SetProperty,+} from "../../shared/use-style-data";+import { Section } from "./transitions";++const Panel = styled("div", {+ width: theme.spacing[30],+ boxShadow: theme.shadows.panelSectionDropShadow,+});++const useStyleInfo = (styleInfoInitial: StyleInfo) => {+ const [styleInfo, setStyleInfo] = useState(() => styleInfoInitial);++ const setProperty: SetProperty = (name) => (value, options) => {+ if (options?.isEphemeral) {+ return;+ }++ setStyleInfo((styleInfo) => ({+ ...styleInfo,+ [name]: {+ ...styleInfo[name],+ value: value,+ local: value,+ },+ }));+ };++ const deleteProperty: DeleteProperty = (name, options) => {+ if (options?.isEphemeral) {+ return;+ }++ setStyleInfo((styleInfo) => {+ const { [name]: _, ...rest } = styleInfo;+ return rest;+ });+ };++ const execCommands = useRef<(() => void)[]>([]);++ const createBatchUpdate: CreateBatchUpdate = () => ({+ deleteProperty: (property) => {+ execCommands.current.push(() => {+ deleteProperty(property);+ });+ },+ setProperty: (property) => (style) => {+ execCommands.current.push(() => {+ setProperty(property)(style);+ });+ },+ publish: (options) => {+ if (options?.isEphemeral) {+ execCommands.current = [];+ return;+ }++ for (const command of execCommands.current) {+ command();+ }++ execCommands.current = [];+ },+ });++ return { styleInfo, setProperty, deleteProperty, createBatchUpdate };+};++export const Transitions = () => {+ const { styleInfo, setProperty, deleteProperty, createBatchUpdate } =+ useStyleInfo({+ transitionProperty: {+ value: {+ type: "layers",+ value: [+ { type: "unparsed", value: "opacity" },+ { type: "unparsed", value: "transform" },+ { type: "keyword", value: "all" },+ ],+ },+ },+ });++ return (+ <Panel>+ <Section+ currentStyle={styleInfo}+ setProperty={setProperty}+ deleteProperty={deleteProperty}+ createBatchUpdate={createBatchUpdate}+ />+ </Panel>+ );+};++export default {+ title: "Style Panel/Transitions",+ component: Transitions,+};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 42aa773091..6f1aa231d2 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@@ -1,11 +1,10 @@-import { useState, useMemo } from "react";+import { useState } from "react";import { useStore } from "@nanostores/react";-import { InfoCircleIcon, PlusIcon } from "@webstudio-is/icons";+import { PlusIcon } from "@webstudio-is/icons";import {SectionTitle,SectionTitleButton,SectionTitleLabel,- Text,Tooltip,} from "@webstudio-is/design-system";import { transitionLongHandProperties } from "@webstudio-is/css-data";@@ -14,32 +13,65 @@ import { CollapsibleSectionRoot } from "~/builder/shared/collapsible-section";import type { SectionProps } from "../shared/section";import { getDots } from "../../shared/collapsible-section";import { PropertyName } from "../../shared/property-name";-import { LayersList } from "../../style-layers-list";import { $selectedOrLastStyleSourceSelector } from "~/shared/nano-states";import { TransitionContent } from "./transition-content";import {- getTransitionProperties,deleteTransitionProperties,addDefaultTransitionLayer,- deleteTransitionLayer,- editTransitionLayer,- swapTransitionLayers,- hideTransitionLayer,- convertIndividualTransitionToLayers,+ findTimingFunctionFromValue,+ defaultTransitionProperty,+ defaultTransitionDuration,+ defaultTransitionTimingFunction,+ defaultTransitionDelay,} from "./transition-utils";-import type { StyleProperty } from "@webstudio-is/css-engine";-import { getStyleSource } from "../../shared/style-info";+import {+ toValue,+ type StyleValue,+ type StyleProperty,+} from "@webstudio-is/css-engine";+import { humanizeString } from "~/shared/string-utils";+import { RepeatedStyle } from "../../shared/repeated-style";+import { getStyleSource, type StyleInfo } from "../../shared/style-info";const label = "Transitions";-const initialTransition = "opacity 200ms ease 0s";export const properties = (transitionLongHandProperties as unknown as Array<StyleProperty>).filter((property) => property !== "transitionBehavior");+const getLayer = (value: undefined | StyleValue, index: number) =>+ value?.type === "layers" ? value.value[index] : undefined;++const getLayerLabel = ({+ style,+ index,+}: {+ style: StyleInfo;+ index: number;+}) => {+ // show label without hidden replacement+ const propertyLayer =+ getLayer(style.transitionProperty?.value, index) ??+ defaultTransitionProperty;+ const property = humanizeString(toValue({ ...propertyLayer, hidden: false }));+ const duration = toValue(+ getLayer(style.transitionDuration?.value, index) ??+ defaultTransitionDuration+ );+ const timingFunctionLayer =+ getLayer(style.transitionTimingFunction?.value, index) ??+ defaultTransitionTimingFunction;+ const timingFunction = toValue({ ...timingFunctionLayer, hidden: false });+ const humanizedTimingFunction =+ findTimingFunctionFromValue(timingFunction) ?? timingFunction;+ const delay = toValue(+ getLayer(style.transitionDelay?.value, index) ?? defaultTransitionDelay+ );+ return `${property}: ${duration} ${humanizedTimingFunction} ${delay}`;+};+export const Section = (props: SectionProps) => {const { currentStyle, createBatchUpdate } = props;const [isOpen, setIsOpen] = useState(true);- const extractedProperties = getTransitionProperties(currentStyle);const propertyValue = currentStyle?.["transitionProperty"]?.value;const sectionStyleSource =propertyValue?.type === "unparsed" ||@@ -47,11 +79,6 @@ export const Section = (props: SectionProps) => {? undefined: getStyleSource(currentStyle["transitionProperty"]);- const layers = useMemo(- () => convertIndividualTransitionToLayers(extractedProperties),- [extractedProperties]- );-const selectedOrLastStyleSourceSelector = useStore($selectedOrLastStyleSourceSelector);@@ -109,80 +136,28 @@ export const Section = (props: SectionProps) => {</SectionTitle>}>- {layers.value.length > 0 && (- <LayersList- {...props}- property={transitionLongHandProperties[0]}- value={layers}- label={label}- deleteProperty={() =>- deleteTransitionProperties({- createBatchUpdate,- })- }- deleteLayer={(index) =>- deleteTransitionLayer({- index,- createBatchUpdate,- currentStyle,- })- }- swapLayers={(oldIndex, newIndex) =>- swapTransitionLayers({- oldIndex,- newIndex,- createBatchUpdate,- currentStyle,- })- }- hideLayer={(index) => {- hideTransitionLayer({- index,- createBatchUpdate,- currentStyle,- });- }}- renderContent={(layerProps) => {- if (layerProps.layer.type !== "tuple") {- return <></>;- }-- return (- <TransitionContent- {...layerProps}- currentStyle={currentStyle}- layer={layerProps.layer}- createBatchUpdate={createBatchUpdate}- onEditLayer={(index, layers, options) =>- editTransitionLayer({- index,- layers,- options,- createBatchUpdate,- currentStyle,- })- }- tooltip={- <Tooltip- variant="wrapped"- content={- <Text>- Paste CSS code for a transition or part of a transition,- for example:- <br />- <br />- <Text variant="monoBold">{initialTransition}</Text>- </Text>- }- >- <InfoCircleIcon />- </Tooltip>- }- />- );- }}- />- )}+ <RepeatedStyle+ label={label}+ properties={[+ "transitionProperty",+ "transitionDuration",+ "transitionTimingFunction",+ "transitionDelay",+ "transitionBehavior",+ ]}+ style={currentStyle}+ createBatchUpdate={createBatchUpdate}+ getItemProps={(index) => ({+ label: getLayerLabel({ style: currentStyle, index }),+ })}+ renderItemContent={(index) => (+ <TransitionContent+ index={index}+ currentStyle={currentStyle}+ createBatchUpdate={createBatchUpdate}+ />+ )}+ /></CollapsibleSectionRoot>);};diff --git a/apps/builder/app/builder/features/style-panel/shared/repeated-style.tsx b/apps/builder/app/builder/features/style-panel/shared/repeated-style.tsxnew file mode 100644index 0000000000..4a757c3886--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/shared/repeated-style.tsx@@ -0,0 +1,176 @@+import { useMemo } from "react";+import type { RgbaColor } from "colord";+import type {+ LayersValue,+ StyleProperty,+ StyleValue,+} from "@webstudio-is/css-engine";+import {+ EyeconClosedIcon,+ EyeconOpenIcon,+ SubtractIcon,+} from "@webstudio-is/icons";+import {+ CssValueListArrowFocus,+ CssValueListItem,+ Flex,+ Label,+ SmallIconButton,+ SmallToggleButton,+ useSortable,+} from "@webstudio-is/design-system";+import { FloatingPanel } from "~/builder/shared/floating-panel";+import type { StyleInfo } from "./style-info";+import type { CreateBatchUpdate } from "./use-style-data";+import { ColorThumb } from "./color-thumb";++const createLayersTransformer =+ ({+ properties,+ style,+ createBatchUpdate,+ }: {+ properties: StyleProperty[];+ style: StyleInfo;+ createBatchUpdate: CreateBatchUpdate;+ }) =>+ (transform: (value: LayersValue) => Partial<LayersValue>) => {+ const batch = createBatchUpdate();+ for (const property of properties) {+ const value = style[property]?.value;+ if (value?.type === "layers") {+ const newLayers = { ...value, ...transform(value) };+ // delete empty layers+ if (newLayers.value.length === 0) {+ batch.deleteProperty(property);+ } else {+ batch.setProperty(property)(newLayers);+ }+ }+ }+ batch.publish();+ };++const hideLayer = (value: LayersValue, layerIndex: number) => ({+ value: value.value.map((item, index) =>+ index === layerIndex+ ? { ...item, hidden: false === (item.hidden ?? false) }+ : item+ ),+});++const deleteLayer = (value: LayersValue, layerIndex: number) => ({+ value: value.value.filter((_item, index) => index !== layerIndex),+});++const swapLayers = (value: LayersValue, oldIndex: number, newIndex: number) => {+ const newValue = Array.from(value.value);+ // You can swap only if there are at least two layers+ // As we are checking across multiple properties, we can't be sure+ // which property don't have two layers so we are checking here.+ if (value.value.length >= 2) {+ newValue.splice(oldIndex, 1);+ newValue.splice(newIndex, 0, value.value[oldIndex]);+ }+ return {+ value: newValue,+ };+};++export const RepeatedStyle = (props: {+ label: string;+ properties: StyleProperty[];+ style: StyleInfo;+ createBatchUpdate: CreateBatchUpdate;+ getItemProps: (+ index: number,+ primaryValue: StyleValue+ ) => { label: string; color?: RgbaColor };+ renderItemContent: (index: number) => JSX.Element;+}) => {+ const transformLayers = createLayersTransformer(props);+ const { label, properties, style, getItemProps, renderItemContent } = props;+ // first property should describe the amount of layers+ const layers = style[properties[0]]?.value;+ const primaryValues = layers?.type === "layers" ? layers.value : [];++ const sortableItems = useMemo(+ () =>+ Array.from(Array(primaryValues.length), (_, index) => ({+ id: String(index),+ index,+ })),+ [primaryValues.length]+ );++ const { dragItemId, placementIndicator, sortableRefCallback } = useSortable({+ items: sortableItems,+ onSort: (newIndex, oldIndex) =>+ transformLayers((value) => swapLayers(value, oldIndex, newIndex)),+ });++ if (primaryValues.length === 0) {+ return;+ }++ return (+ <CssValueListArrowFocus dragItemId={dragItemId}>+ <Flex direction="column" ref={sortableRefCallback}>+ {primaryValues.map((primaryValue, index) => {+ const id = String(index);+ const { label: itemLabel, color: itemColor } = getItemProps(+ index,+ primaryValue+ );+ return (+ <FloatingPanel+ key={index}+ title={label}+ content={renderItemContent(index)}+ >+ <CssValueListItem+ id={id}+ draggable={true}+ active={dragItemId === id}+ index={index}+ label={<Label truncate>{itemLabel}</Label>}+ hidden={primaryValue.hidden}+ thumbnail={itemColor && <ColorThumb color={itemColor} />}+ buttons={+ <>+ <SmallToggleButton+ variant="normal"+ pressed={primaryValue.hidden}+ disabled={false}+ tabIndex={-1}+ onPressedChange={() =>+ transformLayers((value) => hideLayer(value, index))+ }+ icon={+ primaryValue.hidden ? (+ <EyeconClosedIcon />+ ) : (+ <EyeconOpenIcon />+ )+ }+ />+ <SmallIconButton+ variant="destructive"+ tabIndex={-1}+ disabled={primaryValue.hidden}+ icon={<SubtractIcon />}+ onClick={() =>+ transformLayers((value) => deleteLayer(value, index))+ }+ />+ </>+ }+ />+ </FloatingPanel>+ );+ })}+ {placementIndicator}+ </Flex>+ </CssValueListArrowFocus>+ );+};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.tsindex e8b831e73d..f575e3ee07 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@@ -455,83 +455,3 @@ test("Generates humane layer names for filter style layer", () => {}`);});--test("Generates humane layer names for transition style layer", () => {- const transition: TupleValue = {- type: "tuple",- value: [- {- type: "keyword",- value: "width",- },- {- type: "unit",- value: 0,- unit: "ms",- },- {- type: "keyword",- value: "ease-in-out",- },- {- type: "unit",- value: 0,- unit: "ms",- },- ],- hidden: false,- };-- expect(getHumanizedTextFromLayer("transitionProperty", transition))- .toMatchInlineSnapshot(`-{- "color": undefined,- "name": "Width: 0ms 0ms ease-in-out",- "value": "width 0ms ease-in-out 0ms",-}-`);-- const transitionWithCustomTiming: TupleValue = {- type: "tuple",- value: [- {- type: "keyword",- value: "all",- },- {- type: "unit",- value: 50,- unit: "ms",- },- {- type: "unit",- value: 100,- unit: "ms",- },- {- type: "function",- name: "cubic-bezier",- args: {- type: "layers",- value: [- { type: "unit", value: 0.12, unit: "number" },- { type: "unit", value: 0, unit: "number" },- { type: "unit", value: 0.39, unit: "number" },- { type: "unit", value: 0, unit: "number" },- ],- },- },- ],- hidden: false,- };-- expect(- getHumanizedTextFromLayer("transitionProperty", transitionWithCustomTiming)- ).toMatchInlineSnapshot(`-{- "color": undefined,- "name": "All: 50ms 100ms ease-in-sine",- "value": "all 50ms 100ms cubic-bezier(0.12, 0, 0.39, 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.tsindex 506484bc3d..52f8c16f85 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@@ -1,8 +1,6 @@import {- KeywordValue,StyleValue,toValue,- type FunctionValue,type InvalidValue,type LayersValue,type StyleProperty,@@ -16,8 +14,6 @@ import type {} from "./shared/use-style-data";import { colord, type RgbaColor } from "colord";import { humanizeString } from "~/shared/string-utils";-import { isAnimatableProperty } from "@webstudio-is/css-data";-import { findTimingFunctionFromValue } from "./sections/transitions/transition-utils";import type { LayerListProperty } from "./style-layers-list";export const deleteLayer = <Layers extends TupleValue | LayersValue>(@@ -196,46 +192,6 @@ export const getHumanizedTextFromLayer = (layer: StyleValue) => {switch (property) {- case "transitionProperty":- if (layer.type === "tuple") {- const properties = [...layer.value];-- let transitionProperty = properties.find(- (item): item is KeywordValue =>- (item.type === "unparsed" || item.type === "keyword") &&- isAnimatableProperty(item.value) === true- );-- const transitionTimingFunction = properties.find(- (item): item is KeywordValue | FunctionValue =>- (item.type === "keyword" || item.type === "function") &&- isAnimatableProperty(toValue(item)) === false- );-- if (transitionProperty === undefined) {- transitionProperty = {- type: "keyword",- value: "unknown",- };- }-- properties.splice(properties.indexOf(transitionProperty), 1);- if (transitionTimingFunction !== undefined) {- properties.splice(properties.indexOf(transitionTimingFunction), 1);- }-- const customTimingFunction = findTimingFunctionFromValue(- toValue(transitionTimingFunction)- );-- return {- name: `${humanizeString(transitionProperty.value)}: ${toValue({ type: "tuple", value: properties })} ${customTimingFunction ?? toValue(transitionTimingFunction)}`,- value: toValue(layer),- color: undefined,- };- }- break;-case "textShadow":case "boxShadow":if (layer.type === "tuple") {