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: Support all css properties in Advanced section (#3061)
Oleg Isonenfcfcbd9480fd
diff --git a/apps/builder/app/builder/builder.tsx b/apps/builder/app/builder/builder.tsxindex 9f24076f46..ed2e40d938 100644--- a/apps/builder/app/builder/builder.tsx+++ b/apps/builder/app/builder/builder.tsx@@ -107,7 +107,8 @@ const SidePanel = ({height: "100%",...css,"&:last-of-type": {- borderLeft: `1px solid ${theme.colors.borderMain}`,+ // Ensure content still has full width, avoid subpixels give layout round numbers+ boxShadow: `inset 1px 0 0 0 ${theme.colors.borderMain}`,},}}>diff --git a/apps/builder/app/builder/features/settings-panel/props-section/props-section.tsx b/apps/builder/app/builder/features/settings-panel/props-section/props-section.tsxindex a7dd8bcde7..49ee8484a6 100644--- a/apps/builder/app/builder/features/settings-panel/props-section/props-section.tsx+++ b/apps/builder/app/builder/features/settings-panel/props-section/props-section.tsx@@ -1,19 +1,7 @@import { useState } from "react";import { useStore } from "@nanostores/react";import type { Instance } from "@webstudio-is/sdk";-import {- theme,- useCombobox,- Combobox,- ComboboxContent,- ComboboxAnchor,- ComboboxListbox,- ComboboxListboxItem,- Separator,- Flex,- InputField,- NestedInputButton,-} from "@webstudio-is/design-system";+import { theme, Combobox, Separator, Flex } from "@webstudio-is/design-system";import {$propValuesByInstanceSelector,$propsIndex,@@ -56,57 +44,6 @@ const matchOrSuggestToCreate = (return matched;};-const PropsCombobox = ({- items,- onItemSelect,-}: {- items: NameAndLabel[];- onItemSelect: (item: NameAndLabel) => void;-}) => {- const [inputValue, setInputValue] = useState("");-- const combobox = useCombobox<NameAndLabel>({- items,- itemToString,- onItemSelect,- selectedItem: undefined,- match: matchOrSuggestToCreate,- // this weird handling of value is needed to work around a limitation in useCombobox- // where it doesn't allow to leave both `value` and `selectedItem` empty/uncontrolled- value: { name: "", label: inputValue },- onInputChange: (value) => setInputValue(value ?? ""),- });-- return (- <Combobox open={combobox.isOpen}>- <div {...combobox.getComboboxProps()}>- <ComboboxAnchor>- <InputField- autoFocus- {...combobox.getInputProps()}- placeholder="Find or create a property"- suffix={<NestedInputButton {...combobox.getToggleButtonProps()} />}- />- </ComboboxAnchor>- <ComboboxContent align="start" sideOffset={2}>- <ComboboxListbox {...combobox.getMenuProps()}>- {combobox.isOpen &&- combobox.items.map((item, index) => (- <ComboboxListboxItem- key={item.name}- selectable={false}- {...combobox.getItemProps({ item, index })}- >- {itemToString(item)}- </ComboboxListboxItem>- ))}- </ComboboxListbox>- </ComboboxContent>- </div>- </Combobox>- );-};-const renderProperty = ({ propsLogic: logic, propValues, component, instanceId }: PropsSectionProps,{ prop, propName, meta }: PropAndMeta,@@ -149,20 +86,43 @@ const renderProperty = (},});-const AddPropertyForm = ({+const forbiddenProperties = new Set(["style"]);++const AddProperty = ({availableProps,onPropSelected,}: {availableProps: NameAndLabel[];onPropSelected: (propName: string) => void;-}) => (- <Flex css={{ height: theme.spacing[13] }} direction="column" justify="center">- <PropsCombobox- items={availableProps}- onItemSelect={(item) => onPropSelected(item.name)}- />- </Flex>-);+}) => {+ const [value, setValue] = useState("");+ return (+ <Flex+ css={{ height: theme.spacing[13] }}+ direction="column"+ justify="center"+ >+ <Combobox<NameAndLabel>+ autoFocus+ placeholder="Find or create a property"+ // @todo add descriptions+ items={availableProps}+ itemToString={itemToString}+ onItemSelect={(item) => {+ if (forbiddenProperties.has(item.name)) {+ return;+ }+ onPropSelected(item.name);+ }}+ match={matchOrSuggestToCreate}+ value={{ name: "", label: value }}+ onInputChange={(value) => {+ setValue(value ?? "");+ }}+ />+ </Flex>+ );+};type PropsSectionProps = {propsLogic: ReturnType<typeof usePropsLogic>;@@ -195,7 +155,7 @@ export const PropsSection = (props: PropsSectionProps) => {><Flex gap="1" direction="column">{addingProp && (- <AddPropertyForm+ <AddPropertyavailableProps={logic.availableProps}onPropSelected={(propName) => {setAddingProp(false);diff --git a/apps/builder/app/builder/features/settings-panel/variables-section.tsx b/apps/builder/app/builder/features/settings-panel/variables-section.tsxindex 34985e2ec0..4ad4db387e 100644--- a/apps/builder/app/builder/features/settings-panel/variables-section.tsx+++ b/apps/builder/app/builder/features/settings-panel/variables-section.tsx@@ -31,7 +31,7 @@ import {} from "~/shared/nano-states";import { serverSyncStore } from "~/shared/sync";import {- CollapsibleSectionBase,+ CollapsibleSectionRoot,useOpenState,} from "~/builder/shared/collapsible-section";import { formatValuePreview } from "~/builder/shared/expression-editor";@@ -219,7 +219,7 @@ export const VariablesSection = () => {});return (<VariablePopoverProvider value={{ containerRef }}>- <CollapsibleSectionBase+ <CollapsibleSectionRootlabel="Variables"fullWidth={true}isOpen={isOpen}@@ -248,7 +248,7 @@ export const VariablesSection = () => {<div ref={containerRef}><VariablesList /></div>- </CollapsibleSectionBase>+ </CollapsibleSectionRoot></VariablePopoverProvider>);};diff --git a/apps/builder/app/builder/features/sidebar-left/panels/navigator/css-preview.tsx b/apps/builder/app/builder/features/sidebar-left/panels/navigator/css-preview.tsxindex 6e48641860..4828609b97 100644--- a/apps/builder/app/builder/features/sidebar-left/panels/navigator/css-preview.tsx+++ b/apps/builder/app/builder/features/sidebar-left/panels/navigator/css-preview.tsx@@ -25,7 +25,7 @@ const preStyle = css(textVariants.mono, {// - Compiles a CSS string from the style info// - Groups by category and separates categories with comments-const getCssText = (instanceStyle: StyleInfo) => {+const getCssText = (currentStyle: StyleInfo) => {const sheet = createRegularStyleSheet();type StyleValueInfoMap = Map<StyleProperty,@@ -38,8 +38,8 @@ const getCssText = (instanceStyle: StyleInfo) => {// Aggregate styles by category so we can group them when rendering.let property: StyleProperty;- for (property in instanceStyle) {- const value = instanceStyle[property];+ for (property in currentStyle) {+ const value = currentStyle[property];if (value === undefined) {continue;}diff --git a/apps/builder/app/builder/features/style-panel/controls/advanced-value-tooltip.tsx b/apps/builder/app/builder/features/style-panel/controls/advanced-value-tooltip.tsxnew file mode 100644index 0000000000..a211b268c8--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/controls/advanced-value-tooltip.tsx@@ -0,0 +1,59 @@+import type { ReactNode } from "react";+import { Box, Flex, Tooltip, rawTheme } from "@webstudio-is/design-system";+import { AlertIcon } from "@webstudio-is/icons";+import { declarationDescriptions } from "@webstudio-is/css-data";+import type { StyleProperty } from "@webstudio-is/css-engine";+import { TooltipContent } from "../shared/property-name";+import { toKebabCase, toPascalCase } from "../shared/keyword-utils";+import type { StyleInfo } from "../shared/style-info";+import type { DeleteProperty } from "../shared/use-style-data";++// Visual controls can't represent all CSS values and in that case we show it in the Advanced section.+export const AdvancedValueTooltip = ({+ isAdvanced = false,+ children,+ property,+ value,+ currentStyle,+ deleteProperty,+}: {+ isAdvanced?: boolean;+ children: ReactNode;+ property: StyleProperty;+ value: string;+ currentStyle: StyleInfo;+ deleteProperty: DeleteProperty;+}) => {+ if (isAdvanced === false) {+ return children;+ }+ const content = (+ <TooltipContent+ scrollableContent={`${toKebabCase(property)}: ${value};`}+ description={+ <Flex gap="2" direction="column">+ {+ declarationDescriptions[+ `${property}:${value}` as keyof typeof declarationDescriptions+ ]+ }+ <Flex gap="1">+ <AlertIcon color={rawTheme.colors.backgroundAlertMain} /> This value+ was defined in the Advanced section.+ </Flex>+ </Flex>+ }+ title={toPascalCase(toKebabCase(property))}+ properties={[property]}+ style={currentStyle}+ onReset={() => {+ deleteProperty(property);+ }}+ />+ );+ return (+ <Tooltip content={content}>+ <Box>{children}</Box>+ </Tooltip>+ );+};diff --git a/apps/builder/app/builder/features/style-panel/controls/color/color-control.tsx b/apps/builder/app/builder/features/style-panel/controls/color/color-control.tsxindex f78a5c1446..73a9665017 100644--- a/apps/builder/app/builder/features/style-panel/controls/color/color-control.tsx+++ b/apps/builder/app/builder/features/style-panel/controls/color/color-control.tsx@@ -1,15 +1,16 @@+import { useState } from "react";import { Flex } from "@webstudio-is/design-system";import { toValue } from "@webstudio-is/css-engine";-import type { ControlProps } from "../../style-sections";+import type { RgbValue, StyleValue } from "@webstudio-is/css-engine";+import { colord } from "colord";import {type CssColorPickerValueInput,ColorPicker,} from "../../shared/color-picker";-import { colord } from "colord";import { getStyleSource } from "../../shared/style-info";import { styleConfigByName } from "../../shared/configs";-import { useState } from "react";-import type { RgbValue, StyleValue } from "@webstudio-is/css-engine";+import type { ControlProps } from "../types";+import { AdvancedValueTooltip } from "../advanced-value-tooltip";const parseColor = (color?: StyleValue): RgbValue => {const colordValue = colord(toValue(color));@@ -42,6 +43,7 @@ export const ColorControl = ({currentStyle,setProperty,deleteProperty,+ isAdvanced,}: ControlProps) => {const [intermediateValue, setIntermediateValue] =useState<CssColorPickerValueInput>();@@ -65,43 +67,52 @@ export const ColorControl = ({return (<Flex align="center" gap="1">- <ColorPicker- currentColor={currentColor}+ <AdvancedValueTooltip+ isAdvanced={isAdvanced}property={property}- value={value}- styleSource={getStyleSource(styleInfo)}- keywords={(items ?? defaultItems).map((item) => ({- type: "keyword",- value: item.name,- }))}- intermediateValue={intermediateValue}- onChange={(styleValue) => {- setIntermediateValue(styleValue);+ value={toValue(currentColor)}+ currentStyle={currentStyle}+ deleteProperty={deleteProperty}+ >+ <ColorPicker+ disabled={isAdvanced}+ currentColor={currentColor}+ property={property}+ value={value}+ styleSource={getStyleSource(styleInfo)}+ keywords={(items ?? defaultItems).map((item) => ({+ type: "keyword",+ value: item.name,+ }))}+ intermediateValue={intermediateValue}+ onChange={(styleValue) => {+ setIntermediateValue(styleValue);- if (styleValue === undefined) {- deleteProperty(property, { isEphemeral: true });- return;- }+ if (styleValue === undefined) {+ deleteProperty(property, { isEphemeral: true });+ return;+ }- if (styleValue.type !== "intermediate") {- setValue(styleValue, { isEphemeral: true });- }- }}- onHighlight={(styleValue) => {- if (styleValue !== undefined) {- setValue(styleValue, { isEphemeral: true });- } else {+ if (styleValue.type !== "intermediate") {+ setValue(styleValue, { isEphemeral: true });+ }+ }}+ onHighlight={(styleValue) => {+ if (styleValue !== undefined) {+ setValue(styleValue, { isEphemeral: true });+ } else {+ deleteProperty(property, { isEphemeral: true });+ }+ }}+ onChangeComplete={({ value }) => {+ setValue(value);+ setIntermediateValue(undefined);+ }}+ onAbort={() => {deleteProperty(property, { isEphemeral: true });- }- }}- onChangeComplete={({ value }) => {- setValue(value);- setIntermediateValue(undefined);- }}- onAbort={() => {- deleteProperty(property, { isEphemeral: true });- }}- />+ }}+ />+ </AdvancedValueTooltip></Flex>);};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.tsxindex 1853bf3224..70af5effbf 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@@ -1,6 +1,6 @@import { DeprecatedTextField } from "@webstudio-is/design-system";import { FontsManager } from "~/builder/shared/fonts-manager";-import type { ControlProps } from "../../style-sections";+import type { ControlProps } from "../types";import { FloatingPanel } from "~/builder/shared/floating-panel";import { useState } from "react";import { toValue } from "@webstudio-is/css-engine";diff --git a/apps/builder/app/builder/features/style-panel/controls/font-weight/font-weight-control.tsx b/apps/builder/app/builder/features/style-panel/controls/font-weight/font-weight-control.tsxindex 0a33836c70..94d7d36281 100644--- a/apps/builder/app/builder/features/style-panel/controls/font-weight/font-weight-control.tsx+++ b/apps/builder/app/builder/features/style-panel/controls/font-weight/font-weight-control.tsx@@ -3,7 +3,7 @@ import { type FontWeight, fontWeights } from "@webstudio-is/fonts";import { toValue } from "@webstudio-is/css-engine";import { useMemo } from "react";import { useAssets } from "~/builder/shared/assets";-import type { ControlProps } from "../../style-sections";+import type { ControlProps } from "../types";import { isSupportedFontWeight } from "./is-supported-font-weight";type FontWeightItem = {@@ -77,6 +77,7 @@ export const FontWeightControl = ({property,currentStyle,setProperty,+ isAdvanced,}: ControlProps) => {const fontWeight = currentStyle[property]?.value;@@ -112,6 +113,7 @@ export const FontWeightControl = ({return (<Select+ disabled={isAdvanced}// show empty field instead of radix placeholder// like css value input doesplaceholder=""diff --git a/apps/builder/app/builder/features/style-panel/controls/image/image-control.tsx b/apps/builder/app/builder/features/style-panel/controls/image/image-control.tsxindex 4eaa34d7c7..fcecee99a1 100644--- a/apps/builder/app/builder/features/style-panel/controls/image/image-control.tsx+++ b/apps/builder/app/builder/features/style-panel/controls/image/image-control.tsx@@ -3,7 +3,7 @@ import { Button } from "@webstudio-is/design-system";import { $assets } from "~/shared/nano-states";import { FloatingPanel } from "~/builder/shared/floating-panel";import { ImageManager } from "~/builder/shared/image-manager";-import type { ControlProps } from "../../style-sections";+import type { ControlProps } from "../types";export const ImageControl = ({property,diff --git a/apps/builder/app/builder/features/style-panel/controls/index.ts b/apps/builder/app/builder/features/style-panel/controls/index.tsindex 7c32157a66..cf8b9d60d2 100644--- a/apps/builder/app/builder/features/style-panel/controls/index.ts+++ b/apps/builder/app/builder/features/style-panel/controls/index.ts@@ -7,3 +7,4 @@ export * from "./font-weight/font-weight-control";export * from "./image/image-control";export * from "./object-position/object-position-control";export * from "./position/position-control";+export type { ControlProps } from "./types";diff --git a/apps/builder/app/builder/features/style-panel/controls/menu/menu-control.tsx b/apps/builder/app/builder/features/style-panel/controls/menu/menu-control.tsxindex 63985697dc..1dce1fc1da 100644--- a/apps/builder/app/builder/features/style-panel/controls/menu/menu-control.tsx+++ b/apps/builder/app/builder/features/style-panel/controls/menu/menu-control.tsx@@ -1,5 +1,5 @@import { toValue } from "@webstudio-is/css-engine";-import type { IconRecord } from "@webstudio-is/icons";+import type { IconComponent, IconRecord } from "@webstudio-is/icons";import {DropdownMenu,DropdownMenuArrow,@@ -12,29 +12,29 @@ import {IconButton,theme,} from "@webstudio-is/design-system";-import type { ControlProps } from "../../style-sections";+import type { ControlProps } from "../types";import { iconConfigs, styleConfigByName } from "../../shared/configs";import { getStyleSource } from "../../shared/style-info";import { PropertyTooltip } from "../../shared/property-name";+import { AdvancedValueTooltip } from "../advanced-value-tooltip";export const MenuControl = ({currentStyle,property,icons,+ DefaultIcon,items: passedItems,setProperty,deleteProperty,-}: Pick<- ControlProps,- "currentStyle" | "property" | "items" | "setProperty" | "deleteProperty"-> & { icons?: IconRecord }) => {+ isAdvanced,+}: ControlProps & { icons?: IconRecord; DefaultIcon?: IconComponent }) => {const { label, items: defaultItems } = styleConfigByName(property);const styleValue = currentStyle[property];const value = styleValue?.value;const styleSource = getStyleSource(styleValue);if (value === undefined) {- return null;+ return;}const setValue = setProperty(property);@@ -48,18 +48,27 @@ export const MenuControl = ({return { ...item, icon: ItemIcon && <ItemIcon /> };}).filter((item) => item.icon);-+ const icon = items.find(({ name }) => name === currentValue)?.icon;+ // If there is no icon, we can't represent the value visually and assume the value comes from advanced section.+ isAdvanced = isAdvanced ?? icon === undefined;return (<DropdownMenu modal={false}>- <DropdownMenuTrigger asChild>- <div>- <PropertyTooltip- title={label}- properties={[property]}- style={currentStyle}- onReset={() => deleteProperty(property)}- >+ <AdvancedValueTooltip+ isAdvanced={isAdvanced}+ property={property}+ value={currentValue}+ currentStyle={currentStyle}+ deleteProperty={deleteProperty}+ >+ <PropertyTooltip+ title={label}+ properties={[property]}+ style={currentStyle}+ onReset={() => deleteProperty(property)}+ >+ <DropdownMenuTrigger asChild><IconButton+ disabled={isAdvanced ?? icon === undefined}variant={styleSource}onPointerDown={(event) => {// tooltip reset property when click with altKey@@ -68,11 +77,11 @@ export const MenuControl = ({}}}>- {items.find(({ name }) => name === currentValue)?.icon ?? <></>}+ {icon ?? (DefaultIcon ? <DefaultIcon /> : <></>)}</IconButton>- </PropertyTooltip>- </div>- </DropdownMenuTrigger>+ </DropdownMenuTrigger>+ </PropertyTooltip>+ </AdvancedValueTooltip><DropdownMenuPortal><DropdownMenuContent sideOffset={4} collisionPadding={16} side="bottom"><DropdownMenuRadioGroup@@ -82,6 +91,7 @@ export const MenuControl = ({{items.map(({ name, label, icon }) => {return (<DropdownMenuRadioItem+ text="sentence"key={name}value={label}onFocus={() =>diff --git a/apps/builder/app/builder/features/style-panel/controls/object-position/object-position-control.tsx b/apps/builder/app/builder/features/style-panel/controls/object-position/object-position-control.tsxindex acbdbd8081..541d017f9a 100644--- a/apps/builder/app/builder/features/style-panel/controls/object-position/object-position-control.tsx+++ b/apps/builder/app/builder/features/style-panel/controls/object-position/object-position-control.tsx@@ -1,5 +1,5 @@import { Flex, IconButton, theme } from "@webstudio-is/design-system";-import type { ControlProps } from "../../style-sections";+import type { ControlProps } from "../types";import { FloatingPanel } from "~/builder/shared/floating-panel";import { EllipsesIcon } from "@webstudio-is/icons";import { PositionControl } from "../position/position-control";@@ -9,6 +9,7 @@ export const ObjectPositionControl = ({currentStyle,setProperty,deleteProperty,+ isAdvanced,}: ControlProps) => {return (<Flex justify="end">@@ -21,6 +22,7 @@ export const ObjectPositionControl = ({currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}+ isAdvanced={isAdvanced}/></Flex>}diff --git a/apps/builder/app/builder/features/style-panel/controls/position/css-value-input-container.tsx b/apps/builder/app/builder/features/style-panel/controls/position/css-value-input-container.tsxindex 328453f5e2..98fdd66178 100644--- a/apps/builder/app/builder/features/style-panel/controls/position/css-value-input-container.tsx+++ b/apps/builder/app/builder/features/style-panel/controls/position/css-value-input-container.tsx@@ -18,18 +18,19 @@ type CssValueInputContainerProps = {deleteProperty: DeleteProperty;disabled?: boolean;icon?: JSX.Element;+ autoFocus?: boolean;};export const CssValueInputContainer = ({property,keywords,- label,styleSource,value,setValue,deleteProperty,disabled,icon,+ autoFocus,}: CssValueInputContainerProps) => {const [intermediateValue, setIntermediateValue] = useState<StyleValue | IntermediateStyleValue@@ -38,6 +39,7 @@ export const CssValueInputContainer = ({return (<Box><CssValueInput+ autoFocus={autoFocus}icon={icon}disabled={disabled}styleSource={styleSource}diff --git a/apps/builder/app/builder/features/style-panel/controls/position/position-control.tsx b/apps/builder/app/builder/features/style-panel/controls/position/position-control.tsxindex fbc73133ba..6ddb3a2e3b 100644--- a/apps/builder/app/builder/features/style-panel/controls/position/position-control.tsx+++ b/apps/builder/app/builder/features/style-panel/controls/position/position-control.tsx@@ -4,7 +4,7 @@ import {TupleValueItem,} from "@webstudio-is/css-engine";import { Flex, Grid, PositionGrid } from "@webstudio-is/design-system";-import type { ControlProps } from "../../style-sections";+import type { ControlProps } from "../types";import { styleConfigByName } from "../../shared/configs";import { getStyleSource } from "../../shared/style-info";import { CssValueInputContainer } from "./css-value-input-container";@@ -49,6 +49,7 @@ export const PositionControl = ({property,setProperty,deleteProperty,+ isAdvanced,}: ControlProps) => {const { label, items } = styleConfigByName(property);const styleInfo = currentStyle[property];@@ -114,6 +115,7 @@ export const PositionControl = ({value={value.value[0]}setValue={setValueX}deleteProperty={deleteProperty}+ disabled={isAdvanced}/><NonResetablePropertyName@@ -131,6 +133,7 @@ export const PositionControl = ({value={value.value[1]}setValue={setValueY}deleteProperty={deleteProperty}+ disabled={isAdvanced}/></Grid></Flex>diff --git a/apps/builder/app/builder/features/style-panel/controls/select/select-control.tsx b/apps/builder/app/builder/features/style-panel/controls/select/select-control.tsxindex d36e2ab594..7468c92969 100644--- a/apps/builder/app/builder/features/style-panel/controls/select/select-control.tsx+++ b/apps/builder/app/builder/features/style-panel/controls/select/select-control.tsx@@ -1,9 +1,9 @@+import { declarationDescriptions, parseCssValue } from "@webstudio-is/css-data";import { toValue } from "@webstudio-is/css-engine";import { Box, Select, theme } from "@webstudio-is/design-system";import { styleConfigByName } from "../../shared/configs";-import { toPascalCase } from "../../shared/keyword-utils";-import { declarationDescriptions, parseCssValue } from "@webstudio-is/css-data";-import type { ControlProps } from "../../style-sections";+import { toKebabCase } from "../../shared/keyword-utils";+import type { ControlProps } from "../types";export const SelectControl = ({property,@@ -11,12 +11,15 @@ export const SelectControl = ({setProperty,deleteProperty,items,+ isAdvanced,}: ControlProps) => {const { items: defaultItems } = styleConfigByName(property);const styleValue = currentStyle[property]?.value;const setValue = setProperty(property);const options = (items ?? defaultItems).map(({ name }) => name);- const value = toValue(styleValue);+ // We can't render an empty string as a value when display was added but without a value.+ // One case is when advanced property is being added, but no value is set.+ const value = toValue(styleValue) || "empty";// Append selected value when not present in the list of options// because radix requires values to always be in the list.@@ -26,10 +29,11 @@ export const SelectControl = ({return (<Select+ disabled={isAdvanced}// Show empty field instead of radix placeholder like css value input does.placeholder=""options={options}- getLabel={toPascalCase}+ getLabel={toKebabCase}value={value}onChange={(name) => {const nextValue = parseCssValue(property, name);@@ -54,15 +58,17 @@ export const SelectControl = ({}}}getDescription={(option) => {- const key =- `${property}:${option}` as keyof typeof declarationDescriptions;+ const description =+ declarationDescriptions[+ `${property}:${option}` as keyof typeof declarationDescriptions+ ];- return (- <Box css={{ width: theme.spacing[25] }}>- {declarationDescriptions[key]}- </Box>- );+ if (description === undefined) {+ return;+ }+ return <Box css={{ width: theme.spacing[25] }}>{description}</Box>;}}+ getItemProps={() => ({ text: "sentence" })}/>);};diff --git a/apps/builder/app/builder/features/style-panel/controls/text/text-control.tsx b/apps/builder/app/builder/features/style-panel/controls/text/text-control.tsxindex e29f0e5b89..1ca2c4704b 100644--- a/apps/builder/app/builder/features/style-panel/controls/text/text-control.tsx+++ b/apps/builder/app/builder/features/style-panel/controls/text/text-control.tsx@@ -2,7 +2,7 @@ import {CssValueInput,type IntermediateStyleValue,} from "../../shared/css-value-input";-import type { ControlProps } from "../../style-sections";+import type { ControlProps } from "../types";import type { StyleValue } from "@webstudio-is/css-engine";import { useState } from "react";import { Box } from "@webstudio-is/design-system";@@ -16,7 +16,7 @@ export const TextControl = ({setProperty,deleteProperty,icon,- disabled,+ isAdvanced,}: ControlProps & { icon?: JSX.Element }) => {const { items: defaultItems } = styleConfigByName(property);const styleInfo = currentStyle[property];@@ -31,7 +31,7 @@ export const TextControl = ({return (<Box><CssValueInput- disabled={disabled}+ disabled={isAdvanced}styleSource={getStyleSource(styleInfo)}icon={icon}property={property}diff --git a/apps/builder/app/builder/features/style-panel/controls/toggle-group/toggle-group-control.tsx b/apps/builder/app/builder/features/style-panel/controls/toggle-group/toggle-group-control.tsxnew file mode 100644index 0000000000..0e44413a65--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/controls/toggle-group/toggle-group-control.tsx@@ -0,0 +1,119 @@+import {+ Flex,+ ToggleGroup,+ ToggleGroupButton,+} from "@webstudio-is/design-system";+import { getStyleSource } from "../../shared/style-info";+import { useState } from "react";+import { PropertyTooltip } from "../../shared/property-name";+import { toValue } from "@webstudio-is/css-engine";+import type { ControlProps } from "..";+import { AdvancedValueTooltip } from "../advanced-value-tooltip";++export type ToggleGroupControlProps = Omit<ControlProps, "items"> & {+ value?: string;+ items: {+ child: JSX.Element;+ title: string;+ description: string;+ value: string;+ propertyValues: string | string[];+ }[];+ isAdvanced?: boolean;+};++export const ToggleGroupControl = ({+ currentStyle,+ property,+ items = [],+ setProperty,+ deleteProperty,+ value,+ isAdvanced,+}: ToggleGroupControlProps) => {+ const styleSource = getStyleSource(currentStyle[property]);+ const currentValue = value ?? toValue(currentStyle[property]?.value);++ // Issue: The tooltip's grace area is too big and overlaps with nearby buttons,+ // preventing the tooltip from changing when the buttons are hovered over in certain cases.+ // To solve issue and allow tooltips to change on button hover,+ // we close the button tooltip in the ToggleGroupButton.onMouseEnter handler.+ // onMouseEnter used to preserve default hovering behavior on tooltip.+ const [openTootips, setOpenTooltips] = useState(() =>+ Array.from(items, () => false)+ );++ isAdvanced =+ isAdvanced ?? items.some((item) => item.value === currentValue) === false;++ return (+ <AdvancedValueTooltip+ isAdvanced={isAdvanced}+ property={property}+ value={currentValue}+ currentStyle={currentStyle}+ deleteProperty={deleteProperty}+ >+ <ToggleGroup+ color={styleSource}+ type="single"+ value={currentValue}+ onValueChange={(value) => {+ setProperty(property)({ type: "keyword", value });+ }}+ css={{ width: "fit-content" }}+ >+ {items.map((item, index) => {+ const scrollableContent = Array.isArray(item.propertyValues)+ ? item.propertyValues.map((propertyValue) => (+ <div key={propertyValue}>{propertyValue}</div>+ ))+ : item.propertyValues;+ const handleReset = () => {+ if (item.value === currentValue) {+ deleteProperty(property);+ }+ };+ return (+ <PropertyTooltip+ key={item.value}+ open={openTootips[index]}+ onOpenChange={(open) => {+ setOpenTooltips((openTooltips) => {+ const newOpenTooltips = [...openTooltips];+ newOpenTooltips[index] = open;+ return newOpenTooltips;+ });+ }}+ title={item.title}+ scrollableContent={scrollableContent}+ description={item.description}+ properties={item.value === currentValue ? [property] : []}+ style={currentStyle}+ onReset={handleReset}+ >+ <ToggleGroupButton+ disabled={isAdvanced}+ onMouseEnter={() => {+ setOpenTooltips((openTooltips) => {+ return openTooltips.map((openTooltip, i) =>+ i !== index ? false : openTooltip+ );+ });+ }}+ value={item.value}+ onClick={(event) => {+ if (event.altKey) {+ handleReset();+ }+ }}+ >+ <Flex>{item.child}</Flex>+ </ToggleGroupButton>+ </PropertyTooltip>+ );+ })}+ </ToggleGroup>+ </AdvancedValueTooltip>+ );+};diff --git a/apps/builder/app/builder/features/style-panel/controls/toggle/toggle-control.tsx b/apps/builder/app/builder/features/style-panel/controls/toggle/toggle-control.tsxindex 708896a44c..e0713c333d 100644--- a/apps/builder/app/builder/features/style-panel/controls/toggle/toggle-control.tsx+++ b/apps/builder/app/builder/features/style-panel/controls/toggle/toggle-control.tsx@@ -1,149 +1,76 @@-import {- Flex,- ToggleGroup,- ToggleGroupButton,-} from "@webstudio-is/design-system";-import type { StyleInfo, StyleSource } from "../../shared/style-info";-import { useState, type ReactElement } from "react";+import { ToggleButton } from "@webstudio-is/design-system";+import { styleConfigByName } from "../../shared/configs";import { PropertyTooltip } from "../../shared/property-name";-import type { StyleProperty } from "@webstudio-is/css-engine";+import type { ControlProps } from "../types";+import { getStyleSource } from "../../shared/style-info";+import type { IconComponent } from "@webstudio-is/icons";+import { AdvancedValueTooltip } from "../advanced-value-tooltip";-export type ToggleGroupControlProps = {- style: StyleInfo;- styleSource?: StyleSource;+type Item = {+ isPressed: boolean;+ Icon: IconComponent;value: string;- items: {- child: JSX.Element;- title: string;- description: string;- value: string;- propertyValues: string | string[];- }[];- onValueChange?: (value: string) => void;- onReset?: () => void;- properties?: StyleProperty[] | undefined;};-const ToggleGroupButtonWithTooltip = ({- title,- propertyValues,- description,- children,- value,- onReset,- tooltipOpen,- onTooltipOpenChange,- onMouseEnter,- style,- properties,-}: {- title: string;- value: string;- propertyValues: string | string[];- description: React.ReactNode;- children: ReactElement;- onReset?: () => void;- tooltipOpen: boolean;- onTooltipOpenChange: (open: boolean) => void;- onMouseEnter: (event: React.MouseEvent<HTMLButtonElement>) => void;- style: StyleInfo;- properties?: StyleProperty[] | undefined;+export const ToggleControl = ({+ property,+ currentStyle,+ setProperty,+ deleteProperty,+ items,+ DefaultIcon,+ isAdvanced,+}: Omit<ControlProps, "items"> & {+ items: [Item, Item];+ DefaultIcon?: IconComponent;}) => {- const scrollableContent = Array.isArray(propertyValues)- ? propertyValues.map((propertyValue) => (- <div key={propertyValue}>{propertyValue}</div>- ))- : propertyValues;+ const { label } = styleConfigByName(property);+ const styleValue = currentStyle[property]?.value;- return (- <PropertyTooltip- open={tooltipOpen}- onOpenChange={onTooltipOpenChange}- title={title}- scrollableContent={scrollableContent}- description={description}- properties={properties ?? []}- style={style}- onReset={onReset}- >- <ToggleGroupButton- onMouseEnter={onMouseEnter}- value={value}- onClick={(event) => {- if (event.altKey) {- onReset?.();- }- }}- >- <Flex>{children}</Flex>- </ToggleGroupButton>- </PropertyTooltip>- );-};--// @todo refactor this control to follow the standard interface we otherwise have for all controls-export const ToggleGroupControl = ({- styleSource,- value = "",- items = [],- onValueChange,- onReset,- style,- properties,-}: ToggleGroupControlProps) => {- // Issue: The tooltip's grace area is too big and overlaps with nearby buttons,- // preventing the tooltip from changing when the buttons are hovered over in certain cases.- // To solve issue and allow tooltips to change on button hover,- // we close the button tooltip in the ToggleGroupButton.onMouseEnter handler.- // onMouseEnter used to preserve default hovering behavior on tooltip.- const [openTootips, setOpenTooltips] = useState(() =>- Array.from(items, () => false)- );+ if (styleValue?.type !== "keyword") {+ return;+ }+ const currentItem =+ items[0].value === styleValue.value+ ? items[0]+ : items[1].value === styleValue.value+ ? items[1]+ : undefined;+ const isPressed = currentItem?.isPressed ?? false;+ const Icon = currentItem?.Icon ?? DefaultIcon;+ isAdvanced = isAdvanced ?? currentItem === undefined;return (- <ToggleGroup- color={styleSource}- type="single"- value={value}- onValueChange={onValueChange}- css={{ width: "fit-content" }}+ <AdvancedValueTooltip+ isAdvanced={isAdvanced}+ property={property}+ value={styleValue.value}+ currentStyle={currentStyle}+ deleteProperty={deleteProperty}>- {items.map(- (- { child, title, value: itemValue, description, propertyValues },- index- ) => {- return (- <ToggleGroupButtonWithTooltip- key={index}- style={style}- title={title}- propertyValues={propertyValues}- properties={itemValue === value ? properties : []}- description={description}- value={itemValue}- onReset={itemValue === value ? onReset : undefined}- tooltipOpen={openTootips[index]}- onTooltipOpenChange={(open) => {- setOpenTooltips((openTooltips) => {- const newOpenTooltips = [...openTooltips];- newOpenTooltips[index] = open;- return newOpenTooltips;- });- }}- onMouseEnter={(event) => {- setOpenTooltips((openTooltips) => {- return openTooltips.map((openTooltip, i) =>- i !== index ? false : openTooltip- );- });- }}- >- {child}- </ToggleGroupButtonWithTooltip>- );- }- )}- </ToggleGroup>+ <PropertyTooltip+ title={label}+ properties={[property]}+ style={currentStyle}+ onReset={() => deleteProperty(property)}+ >+ <ToggleButton+ disabled={isAdvanced}+ pressed={isPressed}+ onPressedChange={(isPressed) => {+ setProperty(property)({+ type: "keyword",+ value:+ items[0].isPressed === isPressed+ ? items[0].value+ : items[1].value,+ });+ }}+ variant={getStyleSource(currentStyle[property])}+ >+ {Icon ? <Icon /> : <></>}+ </ToggleButton>+ </PropertyTooltip>+ </AdvancedValueTooltip>);};diff --git a/apps/builder/app/builder/features/style-panel/controls/types.ts b/apps/builder/app/builder/features/style-panel/controls/types.tsnew file mode 100644index 0000000000..a169ca77bc--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/controls/types.ts@@ -0,0 +1,12 @@+import type { StyleProperty } from "@webstudio-is/css-engine";+import type { StyleInfo } from "../shared/style-info";+import type { DeleteProperty, SetProperty } from "../shared/use-style-data";++export type ControlProps = {+ property: StyleProperty;+ items?: Array<{ label: string; name: string }>;+ currentStyle: StyleInfo;+ setProperty: SetProperty;+ deleteProperty: DeleteProperty;+ isAdvanced?: boolean;+};diff --git a/apps/builder/app/builder/features/style-panel/sections/advanced/add.tsx b/apps/builder/app/builder/features/style-panel/sections/advanced/add.tsxnew file mode 100644index 0000000000..073548a11f--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/sections/advanced/add.tsx@@ -0,0 +1,77 @@+import { useState } from "react";+import { theme, Combobox, Box } from "@webstudio-is/design-system";+import { propertyDescriptions } from "@webstudio-is/css-data";+import type { StyleProperty } from "@webstudio-is/css-engine";+import { matchSorter } from "match-sorter";+import { isFeatureEnabled } from "@webstudio-is/feature-flags";+import { toKebabCase } from "../../shared/keyword-utils";++type Item = { value: string; label: string };++const matchOrSuggestToCreate = (+ search: string,+ items: Array<Item>,+ itemToString: (item: Item) => string+): Array<Item> => {+ const matched = matchSorter(items, search, {+ keys: [itemToString],+ });++ if (isFeatureEnabled("cssVars") === false) {+ return matched;+ }++ if (+ search.trim() !== "" &&+ itemToString(matched[0]).toLocaleLowerCase() !==+ search.toLocaleLowerCase().trim()+ ) {+ matched.unshift({+ value: search.trim(),+ label: `Create "${search.trim()}"`,+ });+ }+ return matched;+};++export const Add = ({+ onSelect,+ propertyNames,+}: {+ onSelect: (value: string) => void;+ propertyNames: Array<StyleProperty>;+}) => {+ const [item, setItem] = useState<Item>({ value: "", label: "" });++ return (+ <Combobox<Item>+ autoFocus+ placeholder="Find or create a property"+ items={propertyNames.map((value) => ({+ value,+ label: toKebabCase(value),+ }))}+ itemToString={(item) => item?.label ?? ""}+ getItemProps={() => ({ text: "sentence" })}+ onItemSelect={(item) => onSelect(item.value)}+ value={item}+ onInputChange={(value) => {+ setItem({ value: value ?? "", label: value ?? "" });+ }}+ match={matchOrSuggestToCreate}+ getDescription={(item) => {+ let description = `Please look up ${+ item?.value ? `"${toKebabCase(item?.value)}"` : "property"+ } in MDN.`;+ if (item && item.value in propertyDescriptions) {+ description =+ propertyDescriptions[+ item.value as keyof typeof propertyDescriptions+ ];+ }+ return <Box css={{ width: theme.spacing[25] }}>{description}</Box>;+ }}+ defaultHighlightedIndex={0}+ />+ );+};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.tsxnew file mode 100644index 0000000000..6cae9b0550--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx@@ -0,0 +1,133 @@+import { Fragment, useMemo, useState } from "react";+import { theme, Grid } from "@webstudio-is/design-system";+import { properties as propertiesData } from "@webstudio-is/css-data";+import { useStore } from "@nanostores/react";+import type { StyleProperty } from "@webstudio-is/css-engine";+import {+ $selectedInstanceSelector,+ useInstanceStyles,+} from "~/shared/nano-states";+import type { SectionProps } from "../shared/section";+import { CssValueInputContainer } from "../../controls/position/css-value-input-container";+import { styleConfigByName } from "../../shared/configs";+import { PropertyName } from "../../shared/property-name";+import {+ getStyleSource,+ hasInstanceValue,+ type StyleInfo,+} from "../../shared/style-info";+import { Add } from "./add";+import { CollapsibleSection } from "../../shared/collapsible-section";+import { visualProperties } from "../sections";++const allPropertyNames = Object.keys(propertiesData).sort(+ Intl.Collator().compare+) as Array<StyleProperty>;++const initialPropertyNames: Array<StyleProperty> = [+ "userSelect",+ "pointerEvents",+ "mixBlendMode",+ "backdropFilter",+ "cursor",+ "opacity",+];++const usePropertyNames = (currentStyle: StyleInfo) => {+ const selectedInstanceSelector = useStore($selectedInstanceSelector);+ const styles = useInstanceStyles(selectedInstanceSelector?.[0]);+ return useMemo(() => {+ const names = new Set(initialPropertyNames);+ let property: StyleProperty;+ for (property in currentStyle) {+ if (+ hasInstanceValue(currentStyle, property) &&+ visualProperties.has(property) === false+ ) {+ names.add(property);+ }+ }+ for (const style of styles) {+ if (style.listed) {+ names.add(style.property);+ }+ }++ return Array.from(names).reverse();+ }, [styles, currentStyle]);+};++// Only here to keep the same section module interface+export const properties = [];++export const Section = ({+ currentStyle,+ setProperty,+ deleteProperty,+}: SectionProps) => {+ const [addingProp, setAddingProp] = useState<StyleProperty | "">();+ const propertyNames = usePropertyNames(currentStyle);++ return (+ <CollapsibleSection+ label="Advanced"+ currentStyle={currentStyle}+ properties={propertyNames}+ onAdd={() => {+ setAddingProp("");+ }}+ >+ {addingProp !== undefined && (+ <Add+ propertyNames={allPropertyNames.filter(+ (property) => propertyNames.includes(property) === false+ )}+ onSelect={(value) => {+ if (value in propertiesData || value.startsWith("--")) {+ const property = value as StyleProperty;+ setAddingProp(undefined);+ setProperty(property)(+ { type: "guaranteedInvalid" },+ { listed: true }+ );+ }+ }}+ />+ )}+ <Grid gap={2} css={{ gridTemplateColumns: `1fr ${theme.spacing[22]}` }}>+ {propertyNames.map((property, index) => {+ const { items } = styleConfigByName(property);+ const keywords = items.map((item) => ({+ type: "keyword" as const,+ value: item.name,+ }));+ return (+ <Fragment key={property}>+ <PropertyName+ label={styleConfigByName(property).label}+ properties={[property]}+ style={currentStyle}+ onReset={() => deleteProperty(property)}+ />+ <CssValueInputContainer+ autoFocus={addingProp !== undefined && index === 0}+ label={styleConfigByName(property).label}+ property={property}+ styleSource={getStyleSource(currentStyle[property])}+ keywords={keywords}+ value={currentStyle[property]?.value}+ setValue={(styleValue, options) => {+ setProperty(property)(styleValue, {+ ...options,+ listed: true,+ });+ }}+ deleteProperty={deleteProperty}+ />+ </Fragment>+ );+ })}+ </Grid>+ </CollapsibleSection>+ );+};diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-content.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-content.tsxindex 3b65746a5b..314a3d7ec2 100644--- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-content.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-content.tsx@@ -31,7 +31,7 @@ import {import { FloatingPanelProvider } from "~/builder/shared/floating-panel";import { useRef, useState } from "react";import { BackgroundSize } from "./background-size";-import { ToggleGroupControl } from "../../controls/toggle/toggle-control";+import { ToggleGroupControl } from "../../controls/toggle-group/toggle-group-control";import {RepeatGridIcon,RepeatColumnIcon,@@ -112,11 +112,12 @@ const Spacer = styled("div", {export const BackgroundContent = (props: BackgroundContentProps) => {const setProperty = safeSetProperty(props.setProperty);const deleteProperty = safeDeleteProperty(props.deleteProperty);+ const { currentStyle } = props;const elementRef = useRef<HTMLDivElement>(null);const [imageGradientToggle, setImageGradientToggle] = useState<"image" | "gradient"- >(() => detectImageOrGradientToggle(props.currentStyle));+ >(() => detectImageOrGradientToggle(currentStyle));return (<>@@ -157,7 +158,7 @@ export const BackgroundContent = (props: BackgroundContentProps) => {{imageGradientToggle === "image" && (<><NonResetablePropertyName- style={props.currentStyle}+ style={currentStyle}properties={["backgroundImage"]}label="Image"/>@@ -166,7 +167,7 @@ export const BackgroundContent = (props: BackgroundContentProps) => {<ImageControlsetProperty={setProperty}deleteProperty={deleteProperty}- currentStyle={props.currentStyle}+ currentStyle={currentStyle}property="backgroundImage"/></FloatingPanelProvider>@@ -176,7 +177,7 @@ export const BackgroundContent = (props: BackgroundContentProps) => {{imageGradientToggle === "gradient" && (<Flex css={{ gridColumn: "span 2" }} direction="column"><NonResetablePropertyName- style={props.currentStyle}+ style={currentStyle}description={<>Paste a CSS gradient, for example:@@ -196,14 +197,14 @@ export const BackgroundContent = (props: BackgroundContentProps) => {<BackgroundGradientsetProperty={setProperty}deleteProperty={deleteProperty}- currentStyle={props.currentStyle}+ currentStyle={currentStyle}setBackgroundColor={props.setBackgroundColor}/></Flex>)}<NonResetablePropertyName- style={props.currentStyle}+ style={currentStyle}properties={["backgroundClip"]}label="Clip"/>@@ -211,12 +212,12 @@ export const BackgroundContent = (props: BackgroundContentProps) => {<SelectControlsetProperty={setProperty}deleteProperty={deleteProperty}- currentStyle={props.currentStyle}+ currentStyle={currentStyle}property="backgroundClip"/><NonResetablePropertyName- style={props.currentStyle}+ style={currentStyle}properties={["backgroundOrigin"]}label="Origin"/>@@ -224,7 +225,7 @@ export const BackgroundContent = (props: BackgroundContentProps) => {<SelectControlsetProperty={setProperty}deleteProperty={deleteProperty}- currentStyle={props.currentStyle}+ currentStyle={currentStyle}property="backgroundOrigin"/></Grid>@@ -234,7 +235,7 @@ export const BackgroundContent = (props: BackgroundContentProps) => {<BackgroundSizesetProperty={setProperty}deleteProperty={deleteProperty}- currentStyle={props.currentStyle}+ currentStyle={currentStyle}/><Spacer />@@ -242,7 +243,7 @@ export const BackgroundContent = (props: BackgroundContentProps) => {<PositionControlsetProperty={setProperty}deleteProperty={deleteProperty}- currentStyle={props.currentStyle}+ currentStyle={currentStyle}property="backgroundPosition"/>@@ -257,22 +258,17 @@ export const BackgroundContent = (props: BackgroundContentProps) => {{imageGradientToggle === "image" && (<><NonResetablePropertyName- style={props.currentStyle}+ style={currentStyle}properties={["backgroundRepeat"]}label="Repeat"/><Flex css={{ justifySelf: "end" }}><ToggleGroupControl- style={props.currentStyle}- styleSource={"default"}- onValueChange={(value) =>- setProperty("backgroundRepeat")({- type: "keyword",- value,- })- }- value={toValue(props.currentStyle.backgroundRepeat?.value)}+ currentStyle={currentStyle}+ setProperty={setProperty}+ deleteProperty={deleteProperty}+ property="backgroundRepeat"items={[{child: <CrossSmallIcon />,@@ -313,7 +309,7 @@ export const BackgroundContent = (props: BackgroundContentProps) => {)}<NonResetablePropertyName- style={props.currentStyle}+ style={currentStyle}properties={["backgroundAttachment"]}label="Attachment"/>@@ -321,7 +317,7 @@ export const BackgroundContent = (props: BackgroundContentProps) => {<Flex css={{ justifySelf: "end" }}><ToggleGrouptype="single"- value={toValue(props.currentStyle.backgroundAttachment?.value)}+ value={toValue(currentStyle.backgroundAttachment?.value)}onValueChange={(value) => {setProperty("backgroundAttachment")({type: "keyword",@@ -339,7 +335,7 @@ export const BackgroundContent = (props: BackgroundContentProps) => {</Flex><NonResetablePropertyName- style={props.currentStyle}+ style={currentStyle}properties={["backgroundBlendMode"]}label="Blend mode"/>@@ -347,7 +343,7 @@ export const BackgroundContent = (props: BackgroundContentProps) => {<SelectControlsetProperty={setProperty}deleteProperty={deleteProperty}- currentStyle={props.currentStyle}+ currentStyle={currentStyle}property="backgroundBlendMode"/></Grid>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.tsxindex d2c6bac7b3..7648f5ac0f 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@@ -2,7 +2,7 @@ import type { InvalidValue, RgbValue } from "@webstudio-is/css-engine";import { parseCssValue, parseBackground } from "@webstudio-is/css-data";import { TextArea, textVariants } from "@webstudio-is/design-system";import { useEffect, useRef, useState } from "react";-import type { ControlProps } from "../../style-sections";+import type { ControlProps } from "../../controls";type IntermediateValue = {type: "intermediate";@@ -93,7 +93,6 @@ export const BackgroundGradient = (autoGrowmaxRows={4}name="description"- disabled={props.disabled}value={textAreaValue ?? ""}state={intermediateValue?.type === "invalid" ? "invalid" : undefined}onChange={handleChange}diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-size.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-size.tsxindex 30a4a81e03..33741b4ec7 100644--- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-size.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-size.tsx@@ -1,9 +1,7 @@import { Grid, Select, theme } from "@webstudio-is/design-system";import { toValue } from "@webstudio-is/css-engine";import { styleConfigByName } from "../../shared/configs";-import { toPascalCase } from "../../shared/keyword-utils";import { parseCssValue } from "@webstudio-is/css-data";-import type { ControlProps } from "../../style-sections";import { CssValueInputContainer } from "../../controls/position/css-value-input-container";import {type StyleValue,@@ -12,6 +10,7 @@ import {} from "@webstudio-is/css-engine";import type { SetValue } from "../../shared/use-style-data";import { NonResetablePropertyName } from "../../shared/property-name";+import type { ControlProps } from "../../controls";const StyleKeywordAuto = { type: "keyword" as const, value: "auto" };@@ -84,7 +83,6 @@ export const BackgroundSize = (// like css value input doesplaceholder=""options={selectOptions}- getLabel={toPascalCase}value={selectValue}onChange={(name: string) => {if (name === "custom") {@@ -118,6 +116,7 @@ export const BackgroundSize = (setValue(styleValue, { isEphemeral: true });}}}+ getItemProps={() => ({ text: "sentence" })}/></Grid>diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.stories.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.stories.tsxindex 88ec1cf721..c5a3b58d01 100644--- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.stories.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.stories.tsx@@ -8,7 +8,7 @@ import type {DeleteProperty,SetProperty,} from "../../shared/use-style-data";-import { BackgroundsSection } from "./backgrounds";+import { Section } from "./backgrounds";setEnv("*");@@ -107,12 +107,11 @@ export const BackgroundsCollapsible = () => {return (<Panel>- <BackgroundsSection+ <SectioncurrentStyle={styleInfo}setProperty={setProperty}deleteProperty={deleteProperty}createBatchUpdate={createBatchUpdate}- category="backgrounds"/></Panel>);@@ -129,12 +128,11 @@ export const Backgrounds = () => {return (<Panel>- <BackgroundsSection+ <SectioncurrentStyle={styleInfo}setProperty={setProperty}deleteProperty={deleteProperty}createBatchUpdate={createBatchUpdate}- category="backgrounds"/></Panel>);@@ -142,5 +140,5 @@ export const Backgrounds = () => {export default {title: "Style/Background",- component: BackgroundsSection,+ component: Section,};diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.tsxindex 58b182d85d..ea15bb44a0 100644--- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/backgrounds.tsx@@ -1,5 +1,5 @@import { useStore } from "@nanostores/react";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { styleConfigByName } from "../../shared/configs";import { FloatingPanel } from "~/builder/shared/floating-panel";import {@@ -45,7 +45,7 @@ import { getLayerName, LayerThumbnail } from "./background-thumbnail";import { useMemo } from "react";import type { RgbValue, StyleProperty } from "@webstudio-is/css-engine";import {- CollapsibleSectionBase,+ CollapsibleSectionRoot,useOpenState,} from "~/builder/shared/collapsible-section";import { getDots } from "../../shared/collapsible-section";@@ -133,7 +133,7 @@ const Layer = (props: {);};-const properties: StyleProperty[] = [+export const properties = ["backgroundAttachment","backgroundClip","backgroundColor",@@ -143,19 +143,19 @@ const properties: StyleProperty[] = ["backgroundRepeat","backgroundSize","backgroundBlendMode",-];+] satisfies Array<StyleProperty>;const BackgroundsCollapsibleSection = ({children,currentStyle,createBatchUpdate,-}: RenderCategoryProps & { children: React.ReactNode }) => {+}: SectionProps & { children: React.ReactNode }) => {const label = "Backgrounds";const [isOpen, setIsOpen] = useOpenState({ label });const layersStyleSource = getLayersStyleSource(currentStyle);return (- <CollapsibleSectionBase+ <CollapsibleSectionRootlabel={label}fullWidthisOpen={isOpen}@@ -193,11 +193,11 @@ const BackgroundsCollapsibleSection = ({}>{children}- </CollapsibleSectionBase>+ </CollapsibleSectionRoot>);};-export const BackgroundsSection = (props: RenderCategoryProps) => {+export const Section = (props: SectionProps) => {const { setProperty, deleteProperty, currentStyle, createBatchUpdate } =props;const layersCount = getLayerCount(currentStyle);@@ -226,7 +226,6 @@ export const BackgroundsSection = (props: RenderCategoryProps) => {deleteProperty={deleteProperty}createBatchUpdate={createBatchUpdate}currentStyle={currentStyle}- category={props.category}><Flex gap={1} direction="column"><CssValueListArrowFocus dragItemId={dragItemId}>diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/border-color.tsx b/apps/builder/app/builder/features/style-panel/sections/borders/border-color.tsxnew file mode 100644index 0000000000..7c8095b008--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/sections/borders/border-color.tsx@@ -0,0 +1,59 @@+import { type StyleProperty } from "@webstudio-is/css-engine";+import { Box, Grid } from "@webstudio-is/design-system";+import { PropertyName } from "../../shared/property-name";+import { ColorControl } from "../../controls";+import { styleConfigByName } from "../../shared/configs";+import type { SectionProps } from "../shared/section";+import {+ deleteAllProperties,+ setAllProperties,+ rowCss,+ isAdvancedValue,+} from "./utils";++export const properties = [+ "borderTopColor",+ "borderRightColor",+ "borderBottomColor",+ "borderLeftColor",+] satisfies Array<StyleProperty>;++// We do not use shorthand properties such as borderWidth or borderRadius in our code.+// However, in the UI, we can display a single field, and in that case, we can use any property+// from the shorthand property set and pass it instead.+const borderColorProperty = properties[0];++const { items } = styleConfigByName("borderTopColor");++export const BorderColor = (props: SectionProps) => {+ const { currentStyle, createBatchUpdate } = props;+ const deleteColorProperties = deleteAllProperties(+ properties,+ createBatchUpdate+ );++ const setAllproperties = setAllProperties(properties, createBatchUpdate);++ return (+ <Grid css={rowCss}>+ <PropertyName+ style={currentStyle}+ properties={properties}+ label={"Color"}+ description="Sets the color of the border"+ onReset={() => deleteColorProperties(borderColorProperty)}+ />++ <Box css={{ gridColumn: `span 2` }}>+ <ColorControl+ isAdvanced={isAdvancedValue(properties, currentStyle)}+ property={borderColorProperty}+ items={items}+ currentStyle={currentStyle}+ setProperty={setAllproperties}+ deleteProperty={deleteColorProperties}+ />+ </Box>+ </Grid>+ );+};diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/border-property.tsx b/apps/builder/app/builder/features/style-panel/sections/borders/border-property.tsxindex 42c451f5d3..0c022c8a81 100644--- a/apps/builder/app/builder/features/style-panel/sections/borders/border-property.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/borders/border-property.tsx@@ -1,19 +1,18 @@+import { type ReactNode } from "react";+import type { StyleProperty, UnitValue } from "@webstudio-is/css-engine";+import { toValue } from "@webstudio-is/css-engine";import {Box,Grid,NestedIconLabel,ToggleButton,- theme,} from "@webstudio-is/design-system";import { CssValueInputContainer } from "../../controls/position/css-value-input-container";import { styleConfigByName } from "../../shared/configs";import { PropertyName } from "../../shared/property-name";import { getStyleSource } from "../../shared/style-info";-import type { RenderCategoryProps } from "../../style-sections";-import { toValue } from "@webstudio-is/css-engine";-import { deleteAllProperties, setAllProperties } from "./border-utils";-import type { StyleProperty, UnitValue } from "@webstudio-is/css-engine";-import { type ReactNode } from "react";+import type { SectionProps } from "../shared/section";+import { deleteAllProperties, rowCss, setAllProperties } from "./utils";import { useSelectedInstanceKv } from "../../shared/instances-kv";const borderPropertyStyleValueDefault: UnitValue = {@@ -32,7 +31,7 @@ export const BorderProperty = ({label,description,}: Pick<- RenderCategoryProps,+ SectionProps,"currentStyle" | "setProperty" | "deleteProperty" | "createBatchUpdate"> & {individualModeIcon?: ReactNode;@@ -109,12 +108,7 @@ export const BorderProperty = ({return (<Grid gap={1}>- <Grid- css={{- gridTemplateColumns: `1fr ${theme.spacing[20]} ${theme.spacing[12]}`,- }}- gap={2}- >+ <Grid css={rowCss}><PropertyNamestyle={currentStyle}properties={borderProperties}diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/border-radius.tsx b/apps/builder/app/builder/features/style-panel/sections/borders/border-radius.tsxindex 3acf55207f..85a736c595 100644--- a/apps/builder/app/builder/features/style-panel/sections/borders/border-radius.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/borders/border-radius.tsx@@ -6,10 +6,16 @@ import {BorderRadiusTopRightIcon,BorderRadiusBottomLeftIcon,} from "@webstudio-is/icons";--import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { BorderProperty } from "./border-property";+export const properties = [+ "borderTopLeftRadius",+ "borderTopRightRadius",+ "borderBottomLeftRadius",+ "borderBottomRightRadius",+] satisfies Array<StyleProperty>;+const borderPropertyOptions = {borderTopLeftRadius: {icon: <BorderRadiusTopLeftIcon />,@@ -27,7 +33,7 @@ const borderPropertyOptions = {export const BorderRadius = (props: Pick<- RenderCategoryProps,+ SectionProps,"currentStyle" | "setProperty" | "deleteProperty" | "createBatchUpdate">) => {diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/border-style.tsx b/apps/builder/app/builder/features/style-panel/sections/borders/border-style.tsxindex 2f43de32dc..f09f65d612 100644--- a/apps/builder/app/builder/features/style-panel/sections/borders/border-style.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/borders/border-style.tsx@@ -1,104 +1,105 @@import type { StyleProperty } from "@webstudio-is/css-engine";-import { toValue } from "@webstudio-is/css-engine";-import {- Grid,- theme,- ToggleGroup,- ToggleGroupButton,- Tooltip,-} from "@webstudio-is/design-system";+import { Box, Grid } from "@webstudio-is/design-system";import {DashBorderIcon,DashedBorderIcon,DottedBorderIcon,SmallXIcon,} from "@webstudio-is/icons";-import { toPascalCase } from "../../shared/keyword-utils";import { PropertyName } from "../../shared/property-name";-import type { RenderCategoryProps } from "../../style-sections";-import { deleteAllProperties, setAllProperties } from "./border-utils";+import type { SectionProps } from "../shared/section";+import { ToggleGroupControl } from "../../controls/toggle-group/toggle-group-control";+import {+ declarationDescriptions,+ propertyDescriptions,+} from "@webstudio-is/css-data";+import {+ deleteAllProperties,+ setAllProperties,+ rowCss,+ isAdvancedValue,+} from "./utils";-const borderStyleProperties: StyleProperty[] = [+export const properties: StyleProperty[] = ["borderTopStyle","borderRightStyle","borderLeftStyle","borderBottomStyle",-];+] satisfies Array<StyleProperty>;-const borderStyleValues = [- { value: "none", Icon: SmallXIcon },- { value: "solid", Icon: DashBorderIcon },- { value: "dashed", Icon: DashedBorderIcon },- { value: "dotted", Icon: DottedBorderIcon },-] as const;+const items = [+ {+ child: <SmallXIcon />,+ title: "None",+ description: declarationDescriptions["borderBlockStyle:none"],+ value: "none",+ propertyValues: "border-style: none;",+ },+ {+ child: <DashBorderIcon />,+ title: "Solid",+ description: declarationDescriptions["borderBlockStyle:solid"],+ value: "solid",+ propertyValues: "border-style: solid;",+ },+ {+ child: <DashedBorderIcon />,+ title: "Dashed",+ description: declarationDescriptions["borderBlockStyle:dashed"],+ value: "dashed",+ propertyValues: "border-style: dashed;",+ },+ {+ child: <DottedBorderIcon />,+ title: "Dotted",+ description: declarationDescriptions["borderBlockStyle:dotted"],+ value: "dotted",+ propertyValues: "border-style: dotted;",+ },+];export const BorderStyle = (props: Pick<- RenderCategoryProps,+ SectionProps,"currentStyle" | "setProperty" | "deleteProperty" | "createBatchUpdate">) => {- /**- * We do not use shorthand properties such as borderWidth or borderRadius in our code.- * However, in the UI, we can display a single field, and in that case, we can use any property- * from the shorthand property set and pass it instead.- **/- const firstPropertyName = borderStyleProperties[0];+ // We do not use shorthand properties such as borderWidth or borderRadius in our code.+ // However, in the UI, we can display a single field, and in that case, we can use any property+ // from the shorthand property set and pass it instead.+ const firstPropertyName = properties[0];const deleteBorderProperties = deleteAllProperties(- borderStyleProperties,+ properties,props.createBatchUpdate);const setBorderProperties = setAllProperties(- borderStyleProperties,+ properties,props.createBatchUpdate)(firstPropertyName);- const firstPropertyValue = toValue(- props.currentStyle[firstPropertyName]?.value ?? {- type: "keyword",- value: "none",- }- );+ const handleDelete = () => deleteBorderProperties(firstPropertyName);return (- <Grid- css={{- gridTemplateColumns: `1fr ${theme.spacing[20]} ${theme.spacing[12]}`,- }}- gap={2}- >+ <Grid css={rowCss}><PropertyNamestyle={props.currentStyle}- properties={borderStyleProperties}- label={"Style"}- description="Sets the style of the border"- onReset={() => deleteBorderProperties(firstPropertyName)}+ properties={properties}+ label="Style"+ description={propertyDescriptions.borderBlockStyle}+ onReset={handleDelete}/>-- <ToggleGroup- css={{- gridColumn: `span 2`,- justifySelf: "end",- }}- type="single"- value={firstPropertyValue}- onValueChange={(value) => {- setBorderProperties({- type: "keyword",- value,- });- }}- >- {borderStyleValues.map(({ value, Icon }) => (- <Tooltip key={value} content={toPascalCase(value)}>- <ToggleGroupButton value={value}>- <Icon />- </ToggleGroupButton>- </Tooltip>- ))}- </ToggleGroup>+ <Box css={{ gridColumn: `span 2`, justifySelf: "end" }}>+ <ToggleGroupControl+ {...props}+ items={items}+ property={firstPropertyName}+ deleteProperty={handleDelete}+ setProperty={() => setBorderProperties}+ isAdvanced={isAdvancedValue(properties, props.currentStyle)}+ />+ </Box></Grid>);};diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/border-utils.ts b/apps/builder/app/builder/features/style-panel/sections/borders/border-utils.tsdeleted file mode 100644index 2c1d4cd9ed..0000000000--- a/apps/builder/app/builder/features/style-panel/sections/borders/border-utils.ts+++ /dev/null@@ -1,32 +0,0 @@-import type { StyleProperty } from "@webstudio-is/css-engine";-import type {- CreateBatchUpdate,- DeleteProperty,- SetProperty,-} from "../../shared/use-style-data";--export const deleteAllProperties: (- styleProperties: readonly StyleProperty[],- createBatchUpdate: CreateBatchUpdate-) => DeleteProperty =- (styleProperties, createBatchUpdate) => (_propertyName, options) => {- const batch = createBatchUpdate();- for (const property of styleProperties) {- batch.deleteProperty(property);- }- batch.publish(options);- };--export const setAllProperties: (- styleProperties: readonly StyleProperty[],- createBatchUpdate: CreateBatchUpdate-) => SetProperty =- (styleProperties, createBatchUpdate) =>- (_propertyName) =>- (value, options) => {- const batch = createBatchUpdate();- for (const property of styleProperties) {- batch.setProperty(property)(value);- }- batch.publish(options);- };diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/border-width.tsx b/apps/builder/app/builder/features/style-panel/sections/borders/border-width.tsxindex 8a9dbfd519..8ff574c936 100644--- a/apps/builder/app/builder/features/style-panel/sections/borders/border-width.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/borders/border-width.tsx@@ -7,9 +7,16 @@ import {BorderWidthLeftIcon,} from "@webstudio-is/icons";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { BorderProperty } from "./border-property";+export const properties = [+ "borderTopWidth",+ "borderRightWidth",+ "borderBottomWidth",+ "borderLeftWidth",+] satisfies Array<StyleProperty>;+const borderPropertyOptions = {borderTopWidth: {icon: <BorderWidthTopIcon />,@@ -27,7 +34,7 @@ const borderPropertyOptions = {export const BorderWidth = (props: Pick<- RenderCategoryProps,+ SectionProps,"currentStyle" | "setProperty" | "deleteProperty" | "createBatchUpdate">) => {diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/borders.stories.tsx b/apps/builder/app/builder/features/style-panel/sections/borders/borders.stories.tsxindex 6cf75c2d54..db2d33d2df 100644--- a/apps/builder/app/builder/features/style-panel/sections/borders/borders.stories.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/borders/borders.stories.tsx@@ -7,7 +7,7 @@ import type {DeleteProperty,SetProperty,} from "../../shared/use-style-data";-import { BordersSection } from "./borders";+import { Section } from "./borders";setEnv("*");const styleInfoInitial: StyleInfo = {@@ -80,12 +80,11 @@ export const Borders = () => {return (<Panel>- <BordersSection+ <SectioncurrentStyle={styleInfo}setProperty={setProperty}deleteProperty={deleteProperty}createBatchUpdate={createBatchUpdate}- category="borders"/></Panel>);@@ -93,5 +92,5 @@ export const Borders = () => {export default {title: "Style/Borders",- component: BordersSection,+ component: Section,};diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/borders.tsx b/apps/builder/app/builder/features/style-panel/sections/borders/borders.tsxindex 0cf9a61dd6..e443f0e5ac 100644--- a/apps/builder/app/builder/features/style-panel/sections/borders/borders.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/borders/borders.tsx@@ -1,123 +1,43 @@-import { Box, Flex, Grid, theme } from "@webstudio-is/design-system";+import { Flex } from "@webstudio-is/design-system";import type { StyleProperty } from "@webstudio-is/css-engine";-import { ColorControl } from "../../controls";-import { styleConfigByName } from "../../shared/configs";-import { PropertyName } from "../../shared/property-name";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { CollapsibleSection } from "../../shared/collapsible-section";-import { BorderRadius } from "./border-radius";-import { BorderStyle } from "./border-style";-import { deleteAllProperties, setAllProperties } from "./border-utils";-import { BorderWidth } from "./border-width";--const { items: borderColorItems } = styleConfigByName("borderTopColor");--const borderColorProperties: StyleProperty[] = [- "borderTopColor",- "borderRightColor",- "borderBottomColor",- "borderLeftColor",-];--const properties: StyleProperty[] = [+import {+ BorderRadius,+ properties as borderRadiusProperties,+} from "./border-radius";+import {+ BorderStyle,+ properties as borderStyleProperties,+} from "./border-style";+import {+ BorderWidth,+ properties as borderWidthProperties,+} from "./border-width";+import {+ BorderColor,+ properties as borderColorProperties,+} from "./border-color";++export const properties = [...borderColorProperties,+ ...borderRadiusProperties,+ ...borderStyleProperties,+ ...borderWidthProperties,+] satisfies Array<StyleProperty>;- "borderTopLeftRadius",- "borderTopRightRadius",- "borderBottomLeftRadius",- "borderBottomRightRadius",-- "borderTopStyle",- "borderRightStyle",- "borderBottomStyle",- "borderLeftStyle",-- "borderTopWidth",- "borderRightWidth",- "borderBottomWidth",- "borderLeftWidth",-];--export const BordersSection = (props: RenderCategoryProps) => {- const { currentStyle, setProperty, deleteProperty, createBatchUpdate } =- props;-- /**- * We do not use shorthand properties such as borderWidth or borderRadius in our code.- * However, in the UI, we can display a single field, and in that case, we can use any property- * from the shorthand property set and pass it instead.- **/- const borderColorProperty = borderColorProperties[0];-- const deleteAllBorderColorProperties = deleteAllProperties(- borderColorProperties,- createBatchUpdate- );-- const setAllBorderColorProperties = setAllProperties(- borderColorProperties,- createBatchUpdate- );-+export const Section = (props: SectionProps) => {return (<CollapsibleSectionlabel="Borders"- currentStyle={currentStyle}+ currentStyle={props.currentStyle}properties={properties}><Flex direction="column" gap={2}>- <BorderStyle- createBatchUpdate={createBatchUpdate}- currentStyle={currentStyle}- setProperty={setProperty}- deleteProperty={deleteProperty}- />-- <Grid- css={{- // Our aim is to maintain consistent styling throughout the property and align- // the input fields on the left-hand side- // See ./border-property.tsx for more details- gridTemplateColumns: `1fr ${theme.spacing[20]} ${theme.spacing[12]}`,- }}- gapX={2}- >- <PropertyName- style={currentStyle}- properties={borderColorProperties}- label={"Color"}- description="Sets the color of the border"- onReset={() => deleteAllBorderColorProperties(borderColorProperty)}- />-- <Box- css={{- gridColumn: `span 2`,- }}- >- <ColorControl- property={borderColorProperty}- items={borderColorItems}- currentStyle={currentStyle}- setProperty={setAllBorderColorProperties}- deleteProperty={deleteAllBorderColorProperties}- />- </Box>- </Grid>-- <BorderWidth- createBatchUpdate={createBatchUpdate}- currentStyle={currentStyle}- setProperty={setProperty}- deleteProperty={deleteProperty}- />-- <BorderRadius- createBatchUpdate={createBatchUpdate}- currentStyle={currentStyle}- setProperty={setProperty}- deleteProperty={deleteProperty}- />+ <BorderStyle {...props} />+ <BorderColor {...props} />+ <BorderWidth {...props} />+ <BorderRadius {...props} /></Flex></CollapsibleSection>);diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/select-group.tsx b/apps/builder/app/builder/features/style-panel/sections/borders/select-group.tsxnew file mode 100644index 0000000000..d76a6fb672--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/sections/borders/select-group.tsx@@ -0,0 +1,44 @@+import { toValue, type StyleProperty } from "@webstudio-is/css-engine";+import { Grid } from "@webstudio-is/design-system";+import { PropertyName } from "../../shared/property-name";+import { SelectControl } from "../../controls";+import { styleConfigByName } from "../../shared/configs";+import type { SectionProps } from "..";+import type { StyleInfo } from "../../shared/style-info";++export const canUseToggleGroup = (+ properties: Array<StyleProperty>,+ currentStyle: StyleInfo+) => {+ const values = properties.map((property) =>+ toValue(currentStyle[property]?.value)+ );++ // We can represent the value with a toggle group if all values are the same.+ return (+ values[0] === values[1] &&+ values[0] === values[2] &&+ values[0] === values[3]+ );+};++export const SelectGroup = ({+ properties,+ ...props+}: SectionProps & { properties: Array<StyleProperty> }) => {+ return (+ <Grid columns="2" gap="2">+ {properties.map((property) => (+ <Grid gap="1" css={{ gridTemplateColumns: "auto" }} key={property}>+ <PropertyName+ style={props.currentStyle}+ properties={[property]}+ label={styleConfigByName(property).label}+ onReset={() => props.deleteProperty(property)}+ />+ <SelectControl property={property} {...props} />+ </Grid>+ ))}+ </Grid>+ );+};diff --git a/apps/builder/app/builder/features/style-panel/sections/borders/utils.ts b/apps/builder/app/builder/features/style-panel/sections/borders/utils.tsnew file mode 100644index 0000000000..54b5326d58--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/sections/borders/utils.ts@@ -0,0 +1,58 @@+import { theme, type CSS } from "@webstudio-is/design-system";+import { toValue, type StyleProperty } from "@webstudio-is/css-engine";+import type {+ CreateBatchUpdate,+ DeleteProperty,+ SetProperty,+} from "../../shared/use-style-data";+import type { StyleInfo } from "../../shared/style-info";++export const deleteAllProperties: (+ styleProperties: readonly StyleProperty[],+ createBatchUpdate: CreateBatchUpdate+) => DeleteProperty =+ (styleProperties, createBatchUpdate) => (_propertyName, options) => {+ const batch = createBatchUpdate();+ for (const property of styleProperties) {+ batch.deleteProperty(property);+ }+ batch.publish(options);+ };++export const setAllProperties: (+ styleProperties: readonly StyleProperty[],+ createBatchUpdate: CreateBatchUpdate+) => SetProperty =+ (styleProperties, createBatchUpdate) =>+ (_propertyName) =>+ (value, options) => {+ const batch = createBatchUpdate();+ for (const property of styleProperties) {+ batch.setProperty(property)(value);+ }+ batch.publish(options);+ };++export const rowCss: CSS = {+ // Our aim is to maintain consistent styling throughout the property and align+ // the input fields on the left-hand side+ // See ./border-property.tsx for more details+ gridTemplateColumns: `1fr ${theme.spacing[20]} ${theme.spacing[12]}`,+ gap: theme.spacing[5],+};++export const isAdvancedValue = (+ properties: Array<StyleProperty>,+ currentStyle: StyleInfo+) => {+ const values = properties.map((property) =>+ toValue(currentStyle[property]?.value)+ );++ // We can represent the value with a toggle group if all values are the same.+ return (+ values[0] !== values[1] ||+ values[0] !== values[2] ||+ values[0] !== values[3]+ );+};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 b990adbb00..283bdd7c9f 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@@ -5,29 +5,31 @@ import {} from "@webstudio-is/design-system";import { PlusIcon } from "@webstudio-is/icons";import type { StyleProperty, TupleValue } from "@webstudio-is/css-engine";-import { CollapsibleSectionBase } from "~/builder/shared/collapsible-section";+import { CollapsibleSectionRoot } from "~/builder/shared/collapsible-section";import { useState } from "react";import { getDots } from "../../shared/collapsible-section";import { PropertyName } from "../../shared/property-name";import { getStyleSource } from "../../shared/style-info";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { LayersList } from "../../style-layers-list";import { BoxShadowLayer } from "./box-shadow-layer";import { addLayer } from "../../style-layer-utils";import { parseBoxShadow } from "@webstudio-is/css-data";-const property: StyleProperty = "boxShadow";+export const properties = ["boxShadow"] satisfies Array<StyleProperty>;++const property: StyleProperty = properties[0];const label = "Box Shadows";const INITIAL_BOX_SHADOW = "0px 2px 5px 0px rgba(0, 0, 0, 0.2)";-export const BoxShadowsSection = (props: RenderCategoryProps) => {+export const Section = (props: SectionProps) => {const { currentStyle, deleteProperty } = props;const [isOpen, setIsOpen] = useState(true);const layersStyleSource = getStyleSource(currentStyle[property]);const value = currentStyle[property]?.value;return (- <CollapsibleSectionBase+ <CollapsibleSectionRootfullWidthlabel={label}isOpen={isOpen}@@ -53,7 +55,7 @@ export const BoxShadowsSection = (props: RenderCategoryProps) => {<PropertyNametitle="Box Shadows"style={currentStyle}- properties={[property]}+ properties={properties}description="Adds shadow effects around an element's frame."label={<SectionTitleLabel color={layersStyleSource}>@@ -75,6 +77,6 @@ export const BoxShadowsSection = (props: RenderCategoryProps) => {)}/>)}- </CollapsibleSectionBase>+ </CollapsibleSectionRoot>);};diff --git a/apps/builder/app/builder/features/style-panel/sections/effects/effects.tsx b/apps/builder/app/builder/features/style-panel/sections/effects/effects.tsxdeleted file mode 100644index f0722341cb..0000000000--- a/apps/builder/app/builder/features/style-panel/sections/effects/effects.tsx+++ /dev/null@@ -1,117 +0,0 @@-import type { StyleProperty } from "@webstudio-is/css-engine";-import { Grid } from "@webstudio-is/design-system";-import { styleConfigByName } from "../../shared/configs";-import type { RenderCategoryProps } from "../../style-sections";-import { PropertyName } from "../../shared/property-name";-import { SelectControl, TextControl } from "../../controls";--import { CollapsibleSection } from "../../shared/collapsible-section";-import { theme } from "@webstudio-is/design-system";--const properties: StyleProperty[] = ["cursor", "opacity"];--export const EffectsSection = ({- currentStyle: style,- setProperty,- deleteProperty,-}: RenderCategoryProps) => {- return (- <CollapsibleSection- label="Effects"- currentStyle={style}- properties={properties}- >- <Grid- gap={2}- css={{- gridTemplateColumns: `1fr ${theme.spacing[22]}`,- }}- >- <PropertyName- label={styleConfigByName("opacity").label}- properties={["opacity"]}- style={style}- onReset={() => deleteProperty("opacity")}- />- <TextControl- property={"opacity"}- currentStyle={style}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- <PropertyName- label={"Blend Mode"}- properties={["mixBlendMode"]}- style={style}- onReset={() => deleteProperty("mixBlendMode")}- />- <SelectControl- property={"mixBlendMode"}- currentStyle={style}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- <PropertyName- label={styleConfigByName("cursor").label}- properties={["cursor"]}- style={style}- onReset={() => deleteProperty("cursor")}- />- <SelectControl- property={"cursor"}- currentStyle={style}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- <PropertyName- label={styleConfigByName("pointerEvents").label}- properties={["pointerEvents"]}- style={style}- onReset={() => deleteProperty("pointerEvents")}- />- <SelectControl- property={"pointerEvents"}- currentStyle={style}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- <PropertyName- label={styleConfigByName("userSelect").label}- properties={["userSelect"]}- style={style}- onReset={() => deleteProperty("userSelect")}- />- <SelectControl- property={"userSelect"}- currentStyle={style}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- <PropertyName- label={styleConfigByName("backdropFilter").label}- properties={["backdropFilter"]}- style={style}- onReset={() => deleteProperty("backdropFilter")}- />- <TextControl- property={"backdropFilter"}- currentStyle={style}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- <PropertyName- label={styleConfigByName("textUnderlineOffset").label}- properties={["textUnderlineOffset"]}- style={style}- onReset={() => deleteProperty("textUnderlineOffset")}- />- <TextControl- property={"textUnderlineOffset"}- currentStyle={style}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- </Grid>- </CollapsibleSection>- );-};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 5756a00788..04cfe2f1ed 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@@ -1,5 +1,5 @@-import { CollapsibleSectionBase } from "~/builder/shared/collapsible-section";-import type { RenderCategoryProps } from "../../style-sections";+import { CollapsibleSectionRoot } from "~/builder/shared/collapsible-section";+import type { SectionProps } from "../shared/section";import { useState } from "react";import {SectionTitle,@@ -17,18 +17,20 @@ import { FilterLayer } from "./filter-layer";import { addLayer } from "../../style-layer-utils";import { parseFilter } from "@webstudio-is/css-data";-const property: StyleProperty = "filter";+export const properties = ["filter"] satisfies Array<StyleProperty>;++const property: StyleProperty = properties[0];const label = "Filters";const INITIAL_FILTER = "blur(0px)";-export const FilterSection = (props: RenderCategoryProps) => {+export const Section = (props: SectionProps) => {const { currentStyle, deleteProperty } = props;const [isOpen, setIsOpen] = useState(true);const layerStyleSource = getStyleSource(currentStyle[property]);const value = currentStyle[property]?.value;return (- <CollapsibleSectionBase+ <CollapsibleSectionRootfullWidthlabel={label}isOpen={isOpen}@@ -56,7 +58,7 @@ export const FilterSection = (props: RenderCategoryProps) => {<PropertyNametitle={label}style={currentStyle}- properties={[property]}+ properties={properties}description="Filter effects allow you to apply graphical effects like blurring, color shifting, and more to elements."label={<SectionTitleLabel color={layerStyleSource}>@@ -78,6 +80,6 @@ export const FilterSection = (props: RenderCategoryProps) => {)}/>)}- </CollapsibleSectionBase>+ </CollapsibleSectionRoot>);};diff --git a/apps/builder/app/builder/features/style-panel/sections/flex-child/flex-child.tsx b/apps/builder/app/builder/features/style-panel/sections/flex-child/flex-child.tsxindex d1b0493c42..b60ab045bc 100644--- a/apps/builder/app/builder/features/style-panel/sections/flex-child/flex-child.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/flex-child/flex-child.tsx@@ -1,8 +1,8 @@import { Flex, Grid, theme } from "@webstudio-is/design-system";import { toValue } from "@webstudio-is/css-engine";-import type { StyleProperty } from "@webstudio-is/css-engine";-import type { RenderCategoryProps } from "../../style-sections";-import { ToggleGroupControl } from "../../controls/toggle/toggle-control";+import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";+import type { SectionProps } from "../shared/section";+import { ToggleGroupControl } from "../../controls/toggle-group/toggle-group-control";import { PropertyName } from "../../shared/property-name";import { TextControl } from "../../controls";import {@@ -21,15 +21,15 @@ import {import { FloatingPanel } from "~/builder/shared/floating-panel";import { CollapsibleSection } from "../../shared/collapsible-section";-const properties: StyleProperty[] = [+export const properties = ["flexShrink","flexGrow","flexBasis","alignSelf","order",-];+] satisfies Array<StyleProperty>;-export const FlexChildSection = (props: RenderCategoryProps) => {+export const Section = (props: SectionProps) => {return (<CollapsibleSectionlabel="Flex Child"@@ -45,23 +45,21 @@ export const FlexChildSection = (props: RenderCategoryProps) => {);};-const FlexChildSectionAlign = (props: RenderCategoryProps) => {- const { setProperty, deleteProperty, currentStyle } = props;- const setAlignSelf = setProperty("alignSelf");-+const FlexChildSectionAlign = (props: SectionProps) => {+ const { deleteProperty, currentStyle } = props;+ const property = "alignSelf";return (<Grid css={{ gridTemplateColumns: "4fr auto" }}><PropertyNamestyle={currentStyle}- properties={["alignSelf"]}+ properties={[property]}label="Align"- onReset={() => deleteProperty("alignSelf")}+ onReset={() => deleteProperty(property)}/><ToggleGroupControl- style={props.currentStyle}- onValueChange={(value) => setAlignSelf({ type: "keyword", value })}- onReset={() => deleteProperty("alignSelf")}- value={toValue(currentStyle.alignSelf?.value)}+ {...props}+ // We don't support "flex" shorthand and this control is manipulating 3 properties at once+ property={property}items={[{child: <SmallXIcon />,@@ -115,7 +113,7 @@ const FlexChildSectionAlign = (props: RenderCategoryProps) => {);};-const FlexChildSectionSizing = (props: RenderCategoryProps) => {+const FlexChildSectionSizing = (props: SectionProps) => {const { createBatchUpdate, currentStyle } = props;const setSizing = createBatchUpdate();const onReset = () => {@@ -135,53 +133,61 @@ const FlexChildSectionSizing = (props: RenderCategoryProps) => {onReset={onReset}/><ToggleGroupControl- style={props.currentStyle}- onReset={onReset}- onValueChange={(value) => {- switch (value) {- case "none": {- setSizing.setProperty("flexGrow")({- type: "unit",- value: 0,- unit: "number",- });- setSizing.setProperty("flexShrink")({- type: "unit",- value: 0,- unit: "number",- });- setSizing.publish();- break;+ {...props}+ // We don't support "flex" shorthand and this control is manipulating 3 properties at once+ property="flexGrow"+ deleteProperty={onReset}+ setProperty={() => {+ return (styleValue: StyleValue) => {+ if (styleValue.type !== "keyword") {+ // should not happen+ return;}- case "grow": {- setSizing.setProperty("flexGrow")({- type: "unit",- value: 1,- unit: "number",- });- setSizing.setProperty("flexShrink")({- type: "unit",- value: 0,- unit: "number",- });- setSizing.publish();- break;+ switch (styleValue.value) {+ case "none": {+ setSizing.setProperty("flexGrow")({+ type: "unit",+ value: 0,+ unit: "number",+ });+ setSizing.setProperty("flexShrink")({+ type: "unit",+ value: 0,+ unit: "number",+ });+ setSizing.publish();+ break;+ }+ case "grow": {+ setSizing.setProperty("flexGrow")({+ type: "unit",+ value: 1,+ unit: "number",+ });+ setSizing.setProperty("flexShrink")({+ type: "unit",+ value: 0,+ unit: "number",+ });+ setSizing.publish();+ break;+ }+ case "shrink": {+ setSizing.setProperty("flexGrow")({+ type: "unit",+ value: 0,+ unit: "number",+ });+ setSizing.setProperty("flexShrink")({+ type: "unit",+ value: 1,+ unit: "number",+ });+ setSizing.publish();+ break;+ }}- case "shrink": {- setSizing.setProperty("flexGrow")({- type: "unit",- value: 0,- unit: "number",- });- setSizing.setProperty("flexShrink")({- type: "unit",- value: 1,- unit: "number",- });- setSizing.publish();- break;- }- }+ };}}value={getSizingValue(toValue(currentStyle.flexGrow?.value),@@ -233,7 +239,7 @@ const FlexChildSectionSizingPopover = ({currentStyle,setProperty,deleteProperty,-}: RenderCategoryProps) => {+}: SectionProps) => {return (<FloatingPaneltitle="Sizing"@@ -297,31 +303,42 @@ const FlexChildSectionSizingPopover = ({);};-const FlexChildSectionOrder = (props: RenderCategoryProps) => {+const FlexChildSectionOrder = (props: SectionProps) => {const { deleteProperty, setProperty, currentStyle } = props;- const setOrder = setProperty("order");+ const property = "order";+ const setOrder = setProperty(property);return (<Grid css={{ gridTemplateColumns: "4fr auto" }}><PropertyNamestyle={currentStyle}- properties={["order"]}+ properties={[property]}label="Order"- onReset={() => deleteProperty("order")}+ onReset={() => deleteProperty(property)}/><ToggleGroupControl- style={props.currentStyle}- onValueChange={(value) => {- switch (value) {- case "0":- case "1":- case "-1": {- setOrder({ type: "unit", value: Number(value), unit: "number" });- break;+ {...props}+ property={property}+ setProperty={() => {+ return (styleValue: StyleValue) => {+ if (styleValue.type !== "keyword") {+ // should not happen+ return;+ }+ switch (styleValue.value) {+ case "0":+ case "1":+ case "-1": {+ setOrder({+ type: "unit",+ value: Number(styleValue.value),+ unit: "number",+ });+ break;+ }}- }+ };}}- value={toValue(currentStyle.order?.value)}items={[{child: <SmallXIcon />,@@ -357,7 +374,7 @@ const FlexChildSectionOrder = (props: RenderCategoryProps) => {);};-const FlexChildSectionOrderPopover = (props: RenderCategoryProps) => {+const FlexChildSectionOrderPopover = (props: SectionProps) => {const { currentStyle, setProperty, deleteProperty } = props;return (<FloatingPaneldiff --git a/apps/builder/app/builder/features/style-panel/sections/grid-child/grid-child.tsx b/apps/builder/app/builder/features/style-panel/sections/grid-child/grid-child.tsxdeleted file mode 100644index 5e3e73d6f5..0000000000--- a/apps/builder/app/builder/features/style-panel/sections/grid-child/grid-child.tsx+++ /dev/null@@ -1,24 +0,0 @@-import type { StyleProperty } from "@webstudio-is/css-engine";-import type { RenderCategoryProps } from "../../style-sections";-import { renderProperty } from "../../style-sections";-import { CollapsibleSection } from "../../shared/collapsible-section";--const properties: StyleProperty[] = [- "gridRowEnd",- "gridRowStart",- "gridColumnStart",- "gridColumnEnd",- "alignSelf",- "justifySelf",- "order",-];--export const GridChildSection = (props: RenderCategoryProps) => (- <CollapsibleSection- label="Grid Child"- currentStyle={props.currentStyle}- properties={properties}- >- {properties.map((property) => renderProperty({ ...props, property }))}- </CollapsibleSection>-);diff --git a/apps/builder/app/builder/features/style-panel/sections/index.ts b/apps/builder/app/builder/features/style-panel/sections/index.tsindex 9f75691d40..e8b6f2a73d 100644--- a/apps/builder/app/builder/features/style-panel/sections/index.ts+++ b/apps/builder/app/builder/features/style-panel/sections/index.ts@@ -1,15 +1,2 @@-export * from "./layout/layout";-export * from "./list-item";-export * from "./flex-child/flex-child";-export * from "./grid-child/grid-child";-export * from "./space/space";-export * from "./size/size";-export * from "./position/position";-export * from "./typography/typography";-export * from "./backgrounds/backgrounds";-export * from "./borders/borders";-export * from "./outline/outline";-export * from "./effects/effects";-export * from "./box-shadows/box-shadows";-export * from "./transitions/transitions";-export * from "./filter/filter";+export * from "./sections";+export type { SectionProps } from "./shared/section";diff --git a/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx b/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsxindex bcba9b1749..f039756d79 100644--- a/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx@@ -1,11 +1,10 @@-import { useState, type ReactNode } from "react";+import { useState } from "react";import {Box,EnhancedTooltip,Flex,Grid,SmallToggleButton,- ToggleButton,} from "@webstudio-is/design-system";import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";import { toValue } from "@webstudio-is/css-engine";@@ -20,11 +19,14 @@ import {ArrowLeftIcon,ArrowDownIcon,ArrowUpIcon,+ AICenterIcon,+ JCCenterIcon,+ ACCenterIcon,} from "@webstudio-is/icons";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { FlexGrid } from "./shared/flex-grid";import { MenuControl, SelectControl } from "../../controls";-import { PropertyName, PropertyTooltip } from "../../shared/property-name";+import { PropertyName } from "../../shared/property-name";import { styleConfigByName } from "../../shared/configs";import type { CreateBatchUpdate } from "../../shared/use-style-data";import { getStyleSource, type StyleInfo } from "../../shared/style-info";@@ -36,6 +38,7 @@ import {import { theme } from "@webstudio-is/design-system";import { TooltipContent } from "../../../style-panel/shared/property-name";import { isFeatureEnabled } from "@webstudio-is/feature-flags";+import { ToggleControl } from "../../controls/toggle/toggle-control";const GapLinked = ({isLinked,@@ -136,7 +139,7 @@ const FlexGap = ({}: {style: StyleInfo;createBatchUpdate: CreateBatchUpdate;- deleteProperty: RenderCategoryProps["deleteProperty"];+ deleteProperty: SectionProps["deleteProperty"];}) => {const batchUpdate = createBatchUpdate();@@ -307,63 +310,16 @@ const mapNormalTo = (return style;};-const Toggle = ({- property,- iconOn,- iconOff,- valueOn,- valueOff,- currentStyle,- setProperty,- deleteProperty,-}: {- property: StyleProperty;- iconOn: ReactNode;- iconOff: ReactNode;- valueOn: string;- valueOff: string;- currentStyle: RenderCategoryProps["currentStyle"];- setProperty: RenderCategoryProps["setProperty"];- deleteProperty: RenderCategoryProps["deleteProperty"];-}) => {- const { label } = styleConfigByName(property);- const styleValue = currentStyle[property]?.value;- const isPressed =- styleValue?.type === "keyword" && styleValue?.value === valueOn;-- return (- <PropertyTooltip- title={label}- properties={[property]}- style={currentStyle}- onReset={() => deleteProperty(property)}- >- <ToggleButton- pressed={isPressed}- onPressedChange={(isPressed) => {- setProperty(property)({- type: "keyword",- value: isPressed ? valueOn : valueOff,- });- }}- variant={getStyleSource(currentStyle[property])}- >- {isPressed ? iconOn : iconOff}- </ToggleButton>- </PropertyTooltip>- );-};-const LayoutSectionFlex = ({currentStyle,setProperty,deleteProperty,createBatchUpdate,}: {- currentStyle: RenderCategoryProps["currentStyle"];- setProperty: RenderCategoryProps["setProperty"];- deleteProperty: RenderCategoryProps["deleteProperty"];- createBatchUpdate: RenderCategoryProps["createBatchUpdate"];+ currentStyle: SectionProps["currentStyle"];+ setProperty: SectionProps["setProperty"];+ deleteProperty: SectionProps["deleteProperty"];+ createBatchUpdate: SectionProps["createBatchUpdate"];}) => {const batchUpdate = createBatchUpdate();@@ -389,16 +345,26 @@ const LayoutSectionFlex = ({column: ArrowDownIcon,"column-reverse": ArrowUpIcon,}}+ DefaultIcon={ArrowRightIcon}currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/>- <Toggle+ <ToggleControlproperty="flexWrap"- iconOn={<WrapIcon />}- iconOff={<NoWrapIcon />}- valueOn="wrap"- valueOff="nowrap"+ items={[+ {+ isPressed: true,+ Icon: WrapIcon,+ value: "wrap",+ },+ {+ isPressed: false,+ Icon: NoWrapIcon,+ value: "nowrap",+ },+ ]}+ DefaultIcon={WrapIcon}currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}@@ -410,6 +376,7 @@ const LayoutSectionFlex = ({currentStyle={mapNormalTo(currentStyle, "alignItems", "stretch")}setProperty={setProperty}deleteProperty={deleteProperty}+ DefaultIcon={AICenterIcon}/><MenuControlproperty="justifyContent"@@ -420,6 +387,7 @@ const LayoutSectionFlex = ({)}setProperty={setProperty}deleteProperty={deleteProperty}+ DefaultIcon={JCCenterIcon}/>{showAlignContent && (<MenuControl@@ -431,6 +399,7 @@ const LayoutSectionFlex = ({)}setProperty={setProperty}deleteProperty={deleteProperty}+ DefaultIcon={ACCenterIcon}/>)}</Flex>@@ -465,7 +434,7 @@ const compareDisplayValues = (a: { name: string }, b: { name: string }) => {return aIndex - bIndex;};-const properties: StyleProperty[] = [+export const properties = ["display","flexDirection","flexWrap",@@ -474,18 +443,17 @@ const properties: StyleProperty[] = ["alignContent","rowGap","columnGap",-];+] satisfies Array<StyleProperty>;-export const LayoutSection = ({+export const Section = ({currentStyle,setProperty,deleteProperty,createBatchUpdate,-}: RenderCategoryProps) => {- const displayValue = toValue(currentStyle.display?.value);+}: SectionProps) => {+ const value = toValue(currentStyle.display?.value);const { label, items } = styleConfigByName("display");-return (<CollapsibleSectionlabel="Layout"@@ -517,7 +485,7 @@ export const LayoutSection = ({/></Grid>- {(displayValue === "flex" || displayValue === "inline-flex") && (+ {(value === "flex" || value === "inline-flex") && (<LayoutSectionFlexcurrentStyle={currentStyle}setProperty={setProperty}diff --git a/apps/builder/app/builder/features/style-panel/sections/list-item.tsx b/apps/builder/app/builder/features/style-panel/sections/list-item.tsxindex e8d304fb4e..4afbe80481 100644--- a/apps/builder/app/builder/features/style-panel/sections/list-item.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/list-item.tsx@@ -1,19 +1,19 @@import type { StyleProperty } from "@webstudio-is/css-engine";import { Grid, theme } from "@webstudio-is/design-system";import { styleConfigByName } from "../shared/configs";-import type { RenderCategoryProps } from "../style-sections";+import type { SectionProps } from "./shared/section";import { PropertyName } from "../shared/property-name";import { SelectControl } from "../controls";import { CollapsibleSection } from "../shared/collapsible-section";-const properties: StyleProperty[] = ["listStyleType"];+export const properties = ["listStyleType"] satisfies Array<StyleProperty>;-export const ListItemSection = ({+export const Section = ({currentStyle: style,setProperty,deleteProperty,-}: RenderCategoryProps) => {+}: SectionProps) => {return (<CollapsibleSectionlabel="List Item"diff --git a/apps/builder/app/builder/features/style-panel/sections/outline/outline-offset.tsx b/apps/builder/app/builder/features/style-panel/sections/outline/outline-offset.tsxindex b57cf0f4ed..48a42e8c01 100644--- a/apps/builder/app/builder/features/style-panel/sections/outline/outline-offset.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/outline/outline-offset.tsx@@ -1,7 +1,7 @@import type { StyleProperty, UnitValue } from "@webstudio-is/css-engine";import { Grid, theme } from "@webstudio-is/design-system";import { CssValueInputContainer } from "../../controls/position/css-value-input-container";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { PropertyName } from "../../shared/property-name";import { styleConfigByName } from "../../shared/configs";import { getStyleSource } from "../../shared/style-info";@@ -14,10 +14,7 @@ const defaultOutlineOffsetValue: UnitValue = {};export const OutlineOffset = (- props: Pick<- RenderCategoryProps,- "currentStyle" | "setProperty" | "deleteProperty"- >+ props: Pick<SectionProps, "currentStyle" | "setProperty" | "deleteProperty">) => {const { deleteProperty, setProperty, currentStyle } = props;const outlineOffsetValue =diff --git a/apps/builder/app/builder/features/style-panel/sections/outline/outline-style.tsx b/apps/builder/app/builder/features/style-panel/sections/outline/outline-style.tsxindex 04eadf716b..ff297274ed 100644--- a/apps/builder/app/builder/features/style-panel/sections/outline/outline-style.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/outline/outline-style.tsx@@ -1,43 +1,53 @@import type { StyleProperty } from "@webstudio-is/css-engine";-import {- Grid,- theme,- ToggleGroup,- ToggleGroupButton,- Tooltip,-} from "@webstudio-is/design-system";+import { Grid, theme, Box } from "@webstudio-is/design-system";import {DashBorderIcon,DashedBorderIcon,DottedBorderIcon,SmallXIcon,} from "@webstudio-is/icons";-import type { RenderCategoryProps } from "../../style-sections";-import { toPascalCase } from "../../shared/keyword-utils";+import type { SectionProps } from "../shared/section";import { PropertyName } from "../../shared/property-name";-import { toValue } from "@webstudio-is/css-engine";+import { declarationDescriptions } from "@webstudio-is/css-data";+import { ToggleGroupControl } from "../../controls/toggle-group/toggle-group-control";const property: StyleProperty = "outlineStyle";-const outlineStyleValues = [- { value: "none", Icon: SmallXIcon },- { value: "solid", Icon: DashBorderIcon },- { value: "dashed", Icon: DashedBorderIcon },- { value: "dotted", Icon: DottedBorderIcon },++const items = [+ {+ child: <SmallXIcon />,+ title: "None",+ description: declarationDescriptions["outlineStyle:none"],+ value: "none",+ propertyValues: "outline-style: none;",+ },+ {+ child: <DashBorderIcon />,+ title: "Solid",+ description: declarationDescriptions["outlineStyle:solid"],+ value: "solid",+ propertyValues: "outline-style: solid;",+ },+ {+ child: <DashedBorderIcon />,+ title: "Dashed",+ description: declarationDescriptions["outlineStyle:dashed"],+ value: "dashed",+ propertyValues: "outline-style: dashed;",+ },+ {+ child: <DottedBorderIcon />,+ title: "Dotted",+ description: declarationDescriptions["outlineStyle:dotted"],+ value: "dotted",+ propertyValues: "outline-style: dotted;",+ },];export const OutlineStyle = (- props: Pick<- RenderCategoryProps,- "currentStyle" | "setProperty" | "deleteProperty"- >+ props: Pick<SectionProps, "currentStyle" | "setProperty" | "deleteProperty">) => {- const { currentStyle, setProperty, deleteProperty } = props;- const outlineStyleValue = toValue(- currentStyle["outlineStyle"]?.value ?? {- type: "keyword",- value: "none",- }- );+ const { deleteProperty } = props;return (<Grid@@ -52,26 +62,9 @@ export const OutlineStyle = (label={"Style"}onReset={() => deleteProperty(property)}/>-- <ToggleGroup- css={{- gridColumn: `span 2`,- justifySelf: "end",- }}- type="single"- value={outlineStyleValue}- onValueChange={(value) =>- setProperty(property)({ type: "keyword", value })- }- >- {outlineStyleValues.map(({ value, Icon }) => (- <Tooltip key={value} content={toPascalCase(value)}>- <ToggleGroupButton value={value}>- <Icon />- </ToggleGroupButton>- </Tooltip>- ))}- </ToggleGroup>+ <Box css={{ gridColumn: `span 2`, justifySelf: "end" }}>+ <ToggleGroupControl {...props} items={items} property={property} />{" "}+ </Box></Grid>);};diff --git a/apps/builder/app/builder/features/style-panel/sections/outline/outline-width.tsx b/apps/builder/app/builder/features/style-panel/sections/outline/outline-width.tsxindex 1e5a2769db..e1546d65c8 100644--- a/apps/builder/app/builder/features/style-panel/sections/outline/outline-width.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/outline/outline-width.tsx@@ -1,6 +1,6 @@import type { StyleProperty } from "@webstudio-is/css-engine";import { Grid, theme } from "@webstudio-is/design-system";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { PropertyName } from "../../shared/property-name";import { CssValueInputContainer } from "../../controls/position/css-value-input-container";import { styleConfigByName } from "../../shared/configs";@@ -9,10 +9,7 @@ import { getStyleSource } from "../../shared/style-info";const property: StyleProperty = "outlineWidth";export const OutlineWidth = (- props: Pick<- RenderCategoryProps,- "currentStyle" | "setProperty" | "deleteProperty"- >+ props: Pick<SectionProps, "currentStyle" | "setProperty" | "deleteProperty">) => {const { deleteProperty, setProperty, currentStyle } = props;const outlineWidthValue = currentStyle[property]?.value;diff --git a/apps/builder/app/builder/features/style-panel/sections/outline/outline.tsx b/apps/builder/app/builder/features/style-panel/sections/outline/outline.tsxindex 2d5e246097..6c5cf0d1da 100644--- a/apps/builder/app/builder/features/style-panel/sections/outline/outline.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/outline/outline.tsx@@ -2,21 +2,21 @@ import { Flex, Grid, theme, Box } from "@webstudio-is/design-system";import type { StyleProperty } from "@webstudio-is/css-engine";import { ColorControl } from "../../controls";import { CollapsibleSection } from "../../shared/collapsible-section";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { OutlineStyle } from "./outline-style";import { PropertyName } from "../../shared/property-name";import { OutlineWidth } from "./outline-width";import { OutlineOffset } from "./outline-offset";const property: StyleProperty = "outlineColor";-const properties: StyleProperty[] = [+export const properties = ["outlineStyle","outlineColor","outlineWidth","outlineOffset",-];+] satisfies Array<StyleProperty>;-export const OutlineSection = (props: RenderCategoryProps) => {+export const Section = (props: SectionProps) => {const { currentStyle, setProperty, deleteProperty } = props;const { outlineStyle } = currentStyle;diff --git a/apps/builder/app/builder/features/style-panel/sections/position/position-layout.stories.tsx b/apps/builder/app/builder/features/style-panel/sections/position/position-layout.stories.tsxindex 8df5cf0863..d2ca9a51cb 100644--- a/apps/builder/app/builder/features/style-panel/sections/position/position-layout.stories.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/position/position-layout.stories.tsx@@ -4,7 +4,7 @@ import { PositionLayout } from "./position-layout";import { Grid, theme, Text } from "@webstudio-is/design-system";const Cell = () => (- <Text variant={"spaceSectionValueText"}>Auto{/*1.275​rem*/}</Text>+ <Text variant={"spaceSectionValueText"}>auto{/*1.275​rem*/}</Text>);export const PositionLayoutComponent = (diff --git a/apps/builder/app/builder/features/style-panel/sections/position/position.tsx b/apps/builder/app/builder/features/style-panel/sections/position/position.tsxindex 52bb85648a..81b91745c3 100644--- a/apps/builder/app/builder/features/style-panel/sections/position/position.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/position/position.tsx@@ -1,5 +1,5 @@import type { StyleProperty } from "@webstudio-is/css-engine";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { CollapsibleSection } from "../../shared/collapsible-section";import { Grid, theme } from "@webstudio-is/design-system";import { SelectControl, TextControl } from "../../controls";@@ -8,7 +8,14 @@ import { styleConfigByName } from "../../shared/configs";import { PositionControl } from "./position-control";import { useParentStyle } from "../../parent-style";-const properties: StyleProperty[] = ["position"];+export const properties = [+ "position",+ "zIndex",+ "top",+ "right",+ "bottom",+ "left",+] satisfies Array<StyleProperty>;const positionControlVisibleProperties = ["relative",@@ -19,12 +26,12 @@ const positionControlVisibleProperties = [const zIndexParents = ["flex", "grid", "inline-flex", "inline-grid"] as const;-export const PositionSection = ({+export const Section = ({setProperty,deleteProperty,currentStyle,createBatchUpdate,-}: RenderCategoryProps) => {+}: SectionProps) => {const parentStyle = useParentStyle();const positionValue = currentStyle.position?.value;diff --git a/apps/builder/app/builder/features/style-panel/sections/sections.ts b/apps/builder/app/builder/features/style-panel/sections/sections.tsnew file mode 100644index 0000000000..1276ffa72f--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/sections/sections.ts@@ -0,0 +1,48 @@+import type { ReactNode } from "react";+import * as layout from "./layout/layout";+import * as flexChild from "./flex-child/flex-child";+import * as listItem from "./list-item";+import * as space from "./space/space";+import * as size from "./size/size";+import * as position from "./position/position";+import * as typography from "./typography/typography";+import * as backgrounds from "./backgrounds/backgrounds";+import * as borders from "./borders/borders";+import * as boxShadows from "./box-shadows/box-shadows";+import * as filter from "./filter/filter";+import * as transitions from "./transitions/transitions";+import * as outline from "./outline/outline";+import * as advanced from "./advanced/advanced";+import type { StyleProperty } from "@webstudio-is/css-engine";+import type { SectionProps } from "./shared/section";++export const sections = new Map<+ string,+ {+ properties: StyleProperty[];+ Section: (props: SectionProps) => ReactNode;+ }+>([+ ["layout", layout],+ ["flexChild", flexChild],+ ["listItem", listItem],+ ["space", space],+ ["size", size],+ ["position", position],+ ["typography", typography],+ ["backgrounds", backgrounds],+ ["borders", borders],+ ["boxShadows", boxShadows],+ ["filter", filter],+ ["transitions", transitions],+ ["outline", outline],+ ["advanced", advanced],+]);++export const visualProperties = new Set<StyleProperty>([]);++for (const { properties } of sections.values()) {+ for (const property of properties) {+ visualProperties.add(property);+ }+}diff --git a/apps/builder/app/builder/features/style-panel/sections/shared/section.tsx b/apps/builder/app/builder/features/style-panel/sections/shared/section.tsxnew file mode 100644index 0000000000..082702473f--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/sections/shared/section.tsx@@ -0,0 +1,13 @@+import type {+ SetProperty,+ DeleteProperty,+ CreateBatchUpdate,+} from "../../shared/use-style-data";+import type { StyleInfo } from "../../shared/style-info";++export type SectionProps = {+ setProperty: SetProperty;+ deleteProperty: DeleteProperty;+ createBatchUpdate: CreateBatchUpdate;+ currentStyle: StyleInfo;+};diff --git a/apps/builder/app/builder/features/style-panel/sections/shared/value-text.tsx b/apps/builder/app/builder/features/style-panel/sections/shared/value-text.tsxindex d1d0f2fd0d..7d83df2efa 100644--- a/apps/builder/app/builder/features/style-panel/sections/shared/value-text.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/shared/value-text.tsx@@ -3,7 +3,6 @@ import type { StyleValue } from "@webstudio-is/css-engine";import { useMemo, type ComponentProps } from "react";import { theme } from "@webstudio-is/design-system";import { toValue } from "@webstudio-is/css-engine";-import { toPascalCase } from "../../shared/keyword-utils";const Container = styled("button", {// fit-content is not needed for the "button" element,@@ -91,7 +90,7 @@ export const ValueText = ({return (<Text css={{}} variant="spaceSectionValueText">- {toPascalCase(toValue(value))}+ {toValue(value)}</Text>);}, [value, source]);diff --git a/apps/builder/app/builder/features/style-panel/sections/size/size.tsx b/apps/builder/app/builder/features/style-panel/sections/size/size.tsxindex 46e42f6d2b..153edfc7bd 100644--- a/apps/builder/app/builder/features/style-panel/sections/size/size.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/size/size.tsx@@ -1,13 +1,13 @@import type { StyleProperty } from "@webstudio-is/css-engine";-import { toValue } from "@webstudio-is/css-engine";import { Grid, Separator, styled } from "@webstudio-is/design-system";import { styleConfigByName } from "../../shared/configs";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { PropertyName } from "../../shared/property-name";import {SelectControl,TextControl,ObjectPositionControl,+ type ControlProps,} from "../../controls";import {EyeconOpenIcon,@@ -17,31 +17,26 @@ import {} from "@webstudio-is/icons";import { CollapsibleSection } from "../../shared/collapsible-section";import { theme } from "@webstudio-is/design-system";-import { ToggleGroupControl } from "../../controls/toggle/toggle-control";+import { ToggleGroupControl } from "../../controls/toggle-group/toggle-group-control";-const SizeField = ({+const SizeProperty = ({property,- style,+ currentStyle,setProperty,deleteProperty,-}: {- property: StyleProperty;- style: RenderCategoryProps["currentStyle"];- setProperty: RenderCategoryProps["setProperty"];- deleteProperty: RenderCategoryProps["deleteProperty"];-}) => {+}: ControlProps) => {const { label } = styleConfigByName(property);return (<Grid gap={1}><PropertyNamelabel={label}properties={[property]}- style={style}+ style={currentStyle}onReset={() => deleteProperty(property)}/><TextControlproperty={property}- currentStyle={style}+ currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/>@@ -49,7 +44,7 @@ const SizeField = ({);};-const properties: StyleProperty[] = [+export const properties = ["width","height","minWidth",@@ -60,86 +55,89 @@ const properties: StyleProperty[] = ["objectFit","objectPosition","aspectRatio",-];+] satisfies Array<StyleProperty>;-const Section = styled(Grid, {+const SectionLayout = styled(Grid, {columnGap: theme.spacing[5],rowGap: theme.spacing[5],px: theme.spacing[9],});-export const SizeSection = ({- currentStyle: style,+export const Section = ({+ currentStyle,setProperty,deleteProperty,-}: RenderCategoryProps) => {+}: SectionProps) => {return (<CollapsibleSectionlabel="Size"- currentStyle={style}+ currentStyle={currentStyle}properties={properties}fullWidth>- <Section columns={2}>- <SizeField+ <SectionLayout columns={2}>+ <SizePropertyproperty="width"- style={style}+ currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/>- <SizeField+ <SizePropertyproperty="height"- style={style}+ currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/>- <SizeField+ <SizePropertyproperty="minWidth"- style={style}+ currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/>- <SizeField+ <SizePropertyproperty="minHeight"- style={style}+ currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/>- <SizeField+ <SizePropertyproperty="maxWidth"- style={style}+ currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/>- <SizeField+ <SizePropertyproperty="maxHeight"- style={style}+ currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/><PropertyNamelabel={styleConfigByName("aspectRatio").label}properties={["aspectRatio"]}- style={style}+ style={currentStyle}onReset={() => deleteProperty("aspectRatio")}/><TextControlproperty={"aspectRatio"}- currentStyle={style}+ currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/>- </Section>+ </SectionLayout><Separator />- <Section columns={2}>+ <SectionLayout columns={2}><PropertyNamelabel={styleConfigByName("overflow").label}properties={["overflow"]}- style={style}+ style={currentStyle}onReset={() => deleteProperty("overflow")}/><ToggleGroupControl- style={style}+ property="overflow"+ currentStyle={currentStyle}+ setProperty={setProperty}+ deleteProperty={deleteProperty}items={[{child: <EyeconOpenIcon />,@@ -165,6 +163,7 @@ export const SizeSection = ({value: "scroll",propertyValues: "overflow: scroll;",},+{child: <AutoScrollIcon />,title: "Overflow",@@ -174,36 +173,32 @@ export const SizeSection = ({propertyValues: "overflow: auto;",},]}- value={toValue(style.overflow?.value)}- onValueChange={(value) =>- setProperty("overflow")({ type: "keyword", value })- }/><PropertyNamelabel={styleConfigByName("objectFit").label}properties={["objectFit"]}- style={style}+ style={currentStyle}onReset={() => deleteProperty("objectFit")}/><SelectControlproperty="objectFit"- currentStyle={style}+ currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/><PropertyNamelabel={styleConfigByName("objectPosition").label}properties={["objectPosition"]}- style={style}+ style={currentStyle}onReset={() => deleteProperty("objectPosition")}/><ObjectPositionControlproperty="objectPosition"- currentStyle={style}+ currentStyle={currentStyle}setProperty={setProperty}deleteProperty={deleteProperty}/>- </Section>+ </SectionLayout></CollapsibleSection>);};diff --git a/apps/builder/app/builder/features/style-panel/sections/space/layout.tsx b/apps/builder/app/builder/features/style-panel/sections/space/layout.tsxindex 9ca6c14905..995f5ec017 100644--- a/apps/builder/app/builder/features/style-panel/sections/space/layout.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/space/layout.tsx@@ -2,7 +2,7 @@ import { styled, useId } from "@webstudio-is/design-system";import { forwardRef } from "react";import type { ComponentProps, Ref } from "react";import type { HoverTarget, SpaceStyleProperty } from "./types";-import { spacePropertiesNames } from "./types";+import { spaceProperties } from "./properties";import { theme } from "@webstudio-is/design-system";const VALUE_WIDTH = 34;@@ -324,7 +324,7 @@ export const SpaceLayout = forwardRef(<Label>Margin</Label><Label inner>Padding</Label>- {spacePropertiesNames.map((property) => (+ {spaceProperties.map((property) => (<Cell property={property} key={property}>{renderCell({ property })}</Cell>diff --git a/apps/builder/app/builder/features/style-panel/sections/space/properties.ts b/apps/builder/app/builder/features/style-panel/sections/space/properties.tsnew file mode 100644index 0000000000..dde9091a81--- /dev/null+++ b/apps/builder/app/builder/features/style-panel/sections/space/properties.ts@@ -0,0 +1,12 @@+import type { StyleProperty } from "@webstudio-is/css-engine";++export const spaceProperties = [+ "marginTop",+ "marginRight",+ "marginBottom",+ "marginLeft",+ "paddingTop",+ "paddingRight",+ "paddingBottom",+ "paddingLeft",+] satisfies Array<StyleProperty>;diff --git a/apps/builder/app/builder/features/style-panel/sections/space/space.tsx b/apps/builder/app/builder/features/style-panel/sections/space/space.tsxindex 6edb689662..35c42ad4dd 100644--- a/apps/builder/app/builder/features/style-panel/sections/space/space.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/space/space.tsx@@ -1,9 +1,9 @@import { type ComponentProps, useState, useRef } from "react";-import type { RenderCategoryProps } from "../../style-sections";+import type { SectionProps } from "../shared/section";import { SpaceLayout } from "./layout";import { ValueText } from "../shared/value-text";import { getSpaceModifiersGroup, useScrub } from "../shared/scrub";-import { spacePropertiesNames } from "./types";+import { spaceProperties } from "./properties";import type { SpaceStyleProperty, HoverTarget } from "./types";import { InputPopover } from "../shared/input-popover";import { SpaceTooltip } from "./tooltip";@@ -29,7 +29,7 @@ const Cell = ({onHover: (target: HoverTarget | undefined) => void;property: SpaceStyleProperty;scrubStatus: ReturnType<typeof useScrub>;- currentStyle: RenderCategoryProps["currentStyle"];+ currentStyle: SectionProps["currentStyle"];createBatchUpdate: CreateBatchUpdate;}) => {const styleInfo = currentStyle[property];@@ -80,12 +80,14 @@ const Cell = ({);};-export const SpaceSection = ({+export { spaceProperties as properties };++export const Section = ({setProperty,deleteProperty,createBatchUpdate,currentStyle,-}: RenderCategoryProps) => {+}: SectionProps) => {const [hoverTarget, setHoverTarget] = useState<HoverTarget>();const scrubStatus = useScrub({@@ -97,7 +99,7 @@ export const SpaceSection = ({getModifiersGroup: getSpaceModifiersGroup,onChange: (values, options) => {const batch = createBatchUpdate();- for (const property of spacePropertiesNames) {+ for (const property of spaceProperties) {const value = values[property];if (value !== undefined) {batch.setProperty(property)(value);@@ -138,7 +140,7 @@ export const SpaceSection = ({<CollapsibleSectionlabel="Space"currentStyle={currentStyle}- properties={spacePropertiesNames}+ properties={spaceProperties}><SpaceLayoutref={layoutRef}diff --git a/apps/builder/app/builder/features/style-panel/sections/space/types.ts b/apps/builder/app/builder/features/style-panel/sections/space/types.tsindex 3b39334754..f7c451f818 100644--- a/apps/builder/app/builder/features/style-panel/sections/space/types.ts+++ b/apps/builder/app/builder/features/style-panel/sections/space/types.ts@@ -1,17 +1,6 @@-import type { StyleProperty } from "@webstudio-is/css-engine";+import type { spaceProperties } from "./properties";-export const spacePropertiesNames = [- "marginTop",- "marginRight",- "marginBottom",- "marginLeft",- "paddingTop",- "paddingRight",- "paddingBottom",- "paddingLeft",-] as const satisfies ReadonlyArray<StyleProperty>;--export type SpaceStyleProperty = (typeof spacePropertiesNames)[number];+export type SpaceStyleProperty = (typeof spaceProperties)[number];export type HoverTarget = {property: SpaceStyleProperty;diff --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 61f1673414..fa58f4ff7f 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@@ -6,7 +6,7 @@ import {import {Label,InputField,- Combobox,+ ComboboxRoot,ComboboxAnchor,useCombobox,ComboboxContent,@@ -20,9 +20,9 @@ import {Tooltip,Text,Flex,+ ComboboxScrollArea,} from "@webstudio-is/design-system";import type { KeywordValue } from "@webstudio-is/css-engine";-import { humanizeString } from "~/shared/string-utils";import { matchSorter } from "match-sorter";type AnimatableProperties = (typeof animatableProperties)[number];@@ -75,7 +75,7 @@ export const TransitionProperty = ({})),value: { name: inputValue as AnimatableProperties, label: inputValue },selectedItem: undefined,- itemToString: (value) => humanizeString(value?.label || ""),+ itemToString: (value) => value?.label || "",onItemSelect: (prop) => {if (isAnimatableProperty(prop.name) === false) {return;@@ -124,7 +124,7 @@ export const TransitionProperty = ({})}selected={item.name === inputValue}>- {humanizeString(item?.label ?? "")}+ {item?.label ?? ""}</ComboboxListboxItem>);@@ -149,7 +149,7 @@ export const TransitionProperty = ({<Label css={{ display: "inline" }}> Property </Label></Tooltip></Flex>- <Combobox open={isOpen}>+ <ComboboxRoot open={isOpen}><div {...getComboboxProps()}><ComboboxAnchor><InputField@@ -165,13 +165,14 @@ export const TransitionProperty = ({className={comboBoxStyles()}><ComboboxListbox {...getMenuProps()}>- {isOpen && (- <>- <ComboboxLabel>Common</ComboboxLabel>- {commonProperties.map(renderItem)}- <ComboboxSeparator />- {filteredProperties.map((property, index) =>- /*+ <ComboboxScrollArea>+ {isOpen && (+ <>+ <ComboboxLabel>Common</ComboboxLabel>+ {commonProperties.map(renderItem)}+ <ComboboxSeparator />+ {filteredProperties.map((property, index) =>+ /*When rendered in two different lists.We will have two indexes start at '0'. Which leads to- The same focus might be repeated when highlighted.@@ -179,14 +180,15 @@ export const TransitionProperty = ({as it searches the entire list for items.This happens because the list isn't sorted in order but is divided when rendering.*/- renderItem(property, commonProperties.length + index)- )}- </>- )}+ renderItem(property, commonProperties.length + index)+ )}+ </>+ )}+ </ComboboxScrollArea></ComboboxListbox></ComboboxContent></div>- </Combobox>+ </ComboboxRoot></>);};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 b0b7e26e7c..b9dfd4ade7 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@@ -19,7 +19,6 @@ import {type TimingFunctions,findTimingFunctionFromValue,} from "./transition-utils";-import { humanizeString } from "~/shared/string-utils";type TransitionTimingProps = {timing: KeywordValue;@@ -89,8 +88,8 @@ export const TransitionTiming = ({<SelectLabel>Default</SelectLabel>{Object.keys(defaultFunctions).map((defaultFunc) => {return (- <SelectItem key={defaultFunc} value={defaultFunc}>- {humanizeString(defaultFunc)}+ <SelectItem key={defaultFunc} value={defaultFunc} text="sentence">+ {defaultFunc}</SelectItem>);})}@@ -102,8 +101,8 @@ export const TransitionTiming = ({<SelectLabel>Ease In</SelectLabel>{Object.keys(easeInFunctions).map((easeIn) => {return (- <SelectItem key={easeIn} value={easeIn}>- {humanizeString(easeIn)}+ <SelectItem key={easeIn} value={easeIn} text="sentence">+ {easeIn}</SelectItem>);})}@@ -112,8 +111,8 @@ export const TransitionTiming = ({<SelectLabel>Ease Out</SelectLabel>{Object.keys(easeOutFunctions).map((easeOut) => {return (- <SelectItem key={easeOut} value={easeOut}>- {humanizeString(easeOut)}+ <SelectItem key={easeOut} value={easeOut} text="sentence">+ {easeOut}</SelectItem>);})}@@ -122,8 +121,8 @@ export const TransitionTiming = ({<SelectLabel>Ease In Out</SelectLabel>{Object.keys(easeInOutFunctions).map((easeInOut) => {return (- <SelectItem key={easeInOut} value={easeInOut}>- {humanizeString(easeInOut)}+ <SelectItem key={easeInOut} value={easeInOut} text="sentence">+ {easeInOut}</SelectItem>);})}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 5de4f31f51..fdd68f1936 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,6 +1,6 @@import type { StyleProperty, TupleValue } from "@webstudio-is/css-engine";-import { CollapsibleSectionBase } from "~/builder/shared/collapsible-section";-import type { RenderCategoryProps } from "../../style-sections";+import { CollapsibleSectionRoot } from "~/builder/shared/collapsible-section";+import type { SectionProps } from "../shared/section";import {SectionTitle,SectionTitleButton,@@ -19,11 +19,13 @@ import { TransitionLayer } from "./transition-layer";import { $selectedOrLastStyleSourceSelector } from "~/shared/nano-states";import { useStore } from "@nanostores/react";-const property: StyleProperty = "transition";+export const properties = ["transition"] satisfies Array<StyleProperty>;++const property: StyleProperty = properties[0];const label = "Transitions";const INITIAL_TRANSITION = "opacity 200ms ease";-export const TransitionSection = (props: RenderCategoryProps) => {+export const Section = (props: SectionProps) => {const { currentStyle, deleteProperty } = props;const [isOpen, setIsOpen] = useState(true);const layersStyleSource = getStyleSource(currentStyle[property]);@@ -38,7 +40,7 @@ export const TransitionSection = (props: RenderCategoryProps) => {selectedOrLastStyleSourceSelector.state === undefined;return (- <CollapsibleSectionBase+ <CollapsibleSectionRootfullWidthlabel={label}isOpen={isOpen}@@ -74,7 +76,7 @@ export const TransitionSection = (props: RenderCategoryProps) => {title={label}style={currentStyle}description="Animate the transition between states on this instance."- properties={[property]}+ properties={properties}label={<SectionTitleLabel color={layersStyleSource}>{label}@@ -102,6 +104,6 @@ export const TransitionSection = (props: RenderCategoryProps) => {}}/>)}- </CollapsibleSectionBase>+ </CollapsibleSectionRoot>);};diff --git a/apps/builder/app/builder/features/style-panel/sections/typography/typography.tsx b/apps/builder/app/builder/features/style-panel/sections/typography/typography.tsxindex d3fbec12cd..3a9926aec5 100644--- a/apps/builder/app/builder/features/style-panel/sections/typography/typography.tsx+++ b/apps/builder/app/builder/features/style-panel/sections/typography/typography.tsx@@ -6,9 +6,8 @@ import {IconButton,rawTheme,} from "@webstudio-is/design-system";-import { toValue } from "@webstudio-is/css-engine";-import type { StyleProperty } from "@webstudio-is/css-engine";-import type { RenderCategoryProps } from "../../style-sections";+import { toValue, type StyleProperty } from "@webstudio-is/css-engine";+import type { SectionProps } from "../shared/section";import { PropertyName } from "../../shared/property-name";import {ColorControl,@@ -35,13 +34,13 @@ import {TextUnderlineIcon,TextUppercaseIcon,} from "@webstudio-is/icons";-import { ToggleGroupControl } from "../../controls/toggle/toggle-control";+import { ToggleGroupControl } from "../../controls/toggle-group/toggle-group-control";import { FloatingPanel } from "~/builder/shared/floating-panel";-import { getStyleSource, type StyleInfo } from "../../shared/style-info";+import { type StyleInfo } from "../../shared/style-info";import { CollapsibleSection, getDots } from "../../shared/collapsible-section";import { forwardRef, type ComponentProps } from "react";-const properties: StyleProperty[] = [+export const properties = ["fontFamily","fontWeight","fontSize",@@ -56,16 +55,16 @@ const properties: StyleProperty[] = ["whiteSpace","textOverflow","hyphens",-];+] satisfies Array<StyleProperty>;-export const TypographySection = (props: RenderCategoryProps) => {+export const Section = (props: SectionProps) => {return (<CollapsibleSectionlabel="Typography"currentStyle={props.currentStyle}properties={properties}>- <Flex css={{ gap: theme.spacing[7] }} direction="column">+ <Flex gap="2" direction="column"><TypographySectionFont {...props} /><TypographySectionSizing {...props} /><TypographySectionAdvanced {...props} />@@ -74,72 +73,57 @@ export const TypographySection = (props: RenderCategoryProps) => {);};-export const TypographySectionFont = (props: RenderCategoryProps) => {+export const TypographySectionFont = (props: SectionProps) => {const { currentStyle, setProperty, deleteProperty } = props;return (- <Grid- css={{- gap: theme.spacing[5],- }}- >- <Grid css={{ gridTemplateColumns: "4fr 6fr" }} gap={2}>- <PropertyName- style={currentStyle}- label="Font"- properties={["fontFamily"]}- onReset={() => deleteProperty("fontFamily")}- />- <FontFamilyControl- property="fontFamily"- currentStyle={currentStyle}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- </Grid>- <Grid css={{ gridTemplateColumns: "4fr 6fr" }} gap={2}>- <PropertyName- style={currentStyle}- label="Weight"- properties={["fontWeight"]}- onReset={() => deleteProperty("fontWeight")}- />- <FontWeightControl- property="fontWeight"- currentStyle={currentStyle}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- </Grid>- <Grid css={{ gridTemplateColumns: "4fr 6fr" }} gap={2}>- <PropertyName- style={currentStyle}- label="Color"- properties={["color"]}- onReset={() => deleteProperty("color")}- />- <ColorControl- property="color"- currentStyle={currentStyle}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- </Grid>+ <Grid css={{ gridTemplateColumns: "4fr 6fr" }} gap={2}>+ <PropertyName+ style={currentStyle}+ label="Family"+ properties={["fontFamily"]}+ onReset={() => deleteProperty("fontFamily")}+ />+ <FontFamilyControl+ property="fontFamily"+ currentStyle={currentStyle}+ setProperty={setProperty}+ deleteProperty={deleteProperty}+ />+ <PropertyName+ style={currentStyle}+ label="Weight"+ properties={["fontWeight"]}+ onReset={() => deleteProperty("fontWeight")}+ />+ <FontWeightControl+ property="fontWeight"+ currentStyle={currentStyle}+ setProperty={setProperty}+ deleteProperty={deleteProperty}+ />+ <PropertyName+ style={currentStyle}+ label="Color"+ properties={["color"]}+ onReset={() => deleteProperty("color")}+ />+ <ColorControl+ property="color"+ currentStyle={currentStyle}+ setProperty={setProperty}+ deleteProperty={deleteProperty}+ /></Grid>);};-export const TypographySectionSizing = (props: RenderCategoryProps) => {+export const TypographySectionSizing = (props: SectionProps) => {const { currentStyle, setProperty, deleteProperty } = props;return (- <Grid- css={{- gridTemplateColumns: "1fr 1fr 1fr",- gap: theme.spacing[5],- }}- >- <Grid css={{ gridTemplateColumns: "auto", gap: theme.spacing[3] }}>+ <Grid gap="2" css={{ gridTemplateColumns: "1fr 1fr 1fr" }}>+ <Grid gap="1"><PropertyNamestyle={currentStyle}properties={["fontSize"]}@@ -153,7 +137,7 @@ export const TypographySectionSizing = (props: RenderCategoryProps) => {deleteProperty={deleteProperty}/></Grid>- <Grid css={{ gridTemplateColumns: "auto", gap: theme.spacing[3] }}>+ <Grid gap="1"><PropertyNamestyle={currentStyle}properties={["lineHeight"]}@@ -167,7 +151,7 @@ export const TypographySectionSizing = (props: RenderCategoryProps) => {deleteProperty={deleteProperty}/></Grid>- <Grid css={{ gridTemplateColumns: "auto", gap: theme.spacing[3] }}>+ <Grid gap="1"><PropertyNamestyle={currentStyle}properties={["letterSpacing"]}@@ -185,158 +169,124 @@ export const TypographySectionSizing = (props: RenderCategoryProps) => {);};-export const TypographySectionAdvanced = (props: RenderCategoryProps) => {- const { setProperty, deleteProperty, currentStyle } = props;- const setTextAlign = setProperty("textAlign");- const setTextDecorationLine = setProperty("textDecorationLine");- const setTextTransform = setProperty("textTransform");- const setFontStyle = setProperty("fontStyle");-+export const TypographySectionAdvanced = (props: SectionProps) => {+ const { currentStyle } = props;+ const textAlignValue = toValue(currentStyle.textAlign?.value);return (- <Grid- css={{- gap: theme.spacing[5],- }}- >- <Grid- css={{- gridTemplateColumns: "1fr 1fr",- gap: theme.spacing[9],- }}- >- <ToggleGroupControl- style={currentStyle}- styleSource={getStyleSource(currentStyle.textAlign)}- onValueChange={(value) => setTextAlign({ type: "keyword", value })}- onReset={() => deleteProperty("textAlign")}- value={String(getTextAlign(toValue(currentStyle.textAlign?.value)))}- properties={["textAlign"]}- items={[- {- child: <TextAlignLeftIcon />,- title: "Text Align",- description: "Aligns the text based on the writing direction.",- value: "start",- propertyValues: "text-align: left;",- },- {- child: <TextAlignCenterIcon />,- title: "Text Align",- description:- "Centers the text horizontally within its container.",- value: "center",- propertyValues: "text-align: center;",- },- {- child: <TextAlignRightIcon />,- title: "Text Align",- description: "Aligns the text based on the writing direction.",- value: "end",- propertyValues: "text-align: right;",- },- {- child: <TextAlignJustifyIcon />,- title: "Text Align",- description:- "Adjusts word spacing to align text to both the left and right edges of the container",- value: "justify",- propertyValues: "text-align: justify;",- },- ]}- />- <ToggleGroupControl- style={currentStyle}- styleSource={getStyleSource(currentStyle.textDecorationLine)}- onValueChange={(value) =>- setTextDecorationLine({ type: "keyword", value })- }- onReset={() => deleteProperty("textDecorationLine")}- properties={["textDecorationLine"]}- value={toValue(currentStyle.textDecorationLine?.value)}- items={[- {- child: <CrossSmallIcon />,- title: "Text Decoration Line",- description: "No decoration is applied to the text.",- value: "none",- propertyValues: "text-decoration-line: none;",- },- {- title: "Text Decoration Line",- child: <TextUnderlineIcon />,- description: " Adds a horizontal line underneath the text.",- value: "underline",- propertyValues: "text-decoration-line: underline;",- },- {- title: "Text Decoration Line",- child: <TextStrikethroughIcon />,- description:- "Draws a horizontal line through the middle of the text.",- value: "line-through",- propertyValues: "text-decoration-line: line-through;",- },- ]}- />- </Grid>- <Grid- css={{- gridTemplateColumns: "1fr 1fr auto",- gap: theme.spacing[9],- alignItems: "center",- }}- >- <ToggleGroupControl- style={currentStyle}- styleSource={getStyleSource(currentStyle.textTransform)}- onValueChange={(value) =>- setTextTransform({ type: "keyword", value })- }- properties={["textTransform"]}- onReset={() => deleteProperty("textTransform")}- value={toValue(currentStyle.textTransform?.value)}- items={[- {- child: <CrossSmallIcon />,- title: "Text Transform",- description:- "No transformation is applied to the text. The text appears as it is.",- value: "none",- propertyValues: "text-transform: none;",- },- {- child: <TextUppercaseIcon />,- title: "Text Transform",- description:- "Transforms the text to appear in all uppercase letters.",- value: "uppercase",- propertyValues: "text-transform: uppercase;",- },- {- child: <TextCapitalizeIcon />,- title: "Text Transform",- description:- "Transforms the first character of each word to uppercase, while the remaining characters are in lowercase.",- value: "capitalize",- propertyValues: "text-transform: capitalize;",- },- {- child: <TextLowercaseIcon />,- title: "Text Transform",- description:- " Transforms the text to appear in all lowercase letters.",- value: "lowercase",- propertyValues: "text-transform: lowercase;",- },- ]}- />+ <Grid gap="2" columns="2" align="end">+ <ToggleGroupControl+ {...props}+ property="textAlign"+ value={+ // Convert to logical props+ textAlignValue === "left"+ ? "start"+ : textAlignValue === "right"+ ? "end"+ : textAlignValue+ }+ items={[+ {+ child: <TextAlignLeftIcon />,+ title: "Text Align",+ description: "Aligns the text based on the writing direction.",+ value: "start",+ propertyValues: "text-align: start;",+ },+ {+ child: <TextAlignCenterIcon />,+ title: "Text Align",+ description: "Centers the text horizontally within its container.",+ value: "center",+ propertyValues: "text-align: center;",+ },+ {+ child: <TextAlignRightIcon />,+ title: "Text Align",+ description: "Aligns the text based on the writing direction.",+ value: "end",+ propertyValues: "text-align: end;",+ },+ {+ child: <TextAlignJustifyIcon />,+ title: "Text Align",+ description:+ "Adjusts word spacing to align text to both the left and right edges of the container",+ value: "justify",+ propertyValues: "text-align: justify;",+ },+ ]}+ />+ <ToggleGroupControl+ {...props}+ property="textDecorationLine"+ items={[+ {+ child: <CrossSmallIcon />,+ title: "Text Decoration Line",+ description: "No decoration is applied to the text.",+ value: "none",+ propertyValues: "text-decoration-line: none;",+ },+ {+ title: "Text Decoration Line",+ child: <TextUnderlineIcon />,+ description: " Adds a horizontal line underneath the text.",+ value: "underline",+ propertyValues: "text-decoration-line: underline;",+ },+ {+ title: "Text Decoration Line",+ child: <TextStrikethroughIcon />,+ description:+ "Draws a horizontal line through the middle of the text.",+ value: "line-through",+ propertyValues: "text-decoration-line: line-through;",+ },+ ]}+ />+ <ToggleGroupControl+ {...props}+ property="textTransform"+ items={[+ {+ child: <CrossSmallIcon />,+ title: "Text Transform",+ description:+ "No transformation is applied to the text. The text appears as it is.",+ value: "none",+ propertyValues: "text-transform: none;",+ },+ {+ child: <TextUppercaseIcon />,+ title: "Text Transform",+ description:+ "Transforms the text to appear in all uppercase letters.",+ value: "uppercase",+ propertyValues: "text-transform: uppercase;",+ },+ {+ child: <TextCapitalizeIcon />,+ title: "Text Transform",+ description:+ "Transforms the first character of each word to uppercase, while the remaining characters are in lowercase.",+ value: "capitalize",+ propertyValues: "text-transform: capitalize;",+ },+ {+ child: <TextLowercaseIcon />,+ title: "Text Transform",+ description:+ " Transforms the text to appear in all lowercase letters.",+ value: "lowercase",+ propertyValues: "text-transform: lowercase;",+ },+ ]}+ />+ <Grid align="end" gap="1" css={{ gridTemplateColumns: "3fr 1fr" }}><ToggleGroupControl- style={currentStyle}- styleSource={getStyleSource(currentStyle.fontStyle)}- onValueChange={(value) => setFontStyle({ type: "keyword", value })}- onReset={() => deleteProperty("fontStyle")}- properties={["fontStyle"]}- value={toValue(currentStyle.fontStyle?.value)}+ {...props}+ property="fontStyle"items={[{child: <CrossSmallIcon />,@@ -393,13 +343,8 @@ const AdvancedOptionsButton = forwardRef<});AdvancedOptionsButton.displayName = "AdvancedOptionsButton";-export const TypographySectionAdvancedPopover = (- props: RenderCategoryProps-) => {+export const TypographySectionAdvancedPopover = (props: SectionProps) => {const { deleteProperty, setProperty, currentStyle } = props;- const setDirection = setProperty("direction");- const setTextOverflow = setProperty("textOverflow");- const setHyphens = setProperty("hyphens");const properties = {whiteSpace: "whiteSpace",direction: "direction",@@ -440,11 +385,8 @@ export const TypographySectionAdvancedPopover = (onReset={() => deleteProperty(properties.direction)}/><ToggleGroupControl- style={currentStyle}- onValueChange={(value) =>- setDirection({ type: "keyword", value })- }- value={toValue(currentStyle.direction?.value)}+ {...props}+ property={properties.direction}items={[{child: <TextDirectionLTRIcon />,@@ -473,9 +415,8 @@ export const TypographySectionAdvancedPopover = (onReset={() => deleteProperty(properties.hyphens)}/><ToggleGroupControl- style={currentStyle}- onValueChange={(value) => setHyphens({ type: "keyword", value })}- value={toValue(currentStyle.hyphens?.value)}+ {...props}+ property={properties.hyphens}items={[{child: <CrossSmallIcon />,@@ -504,11 +445,8 @@ export const TypographySectionAdvancedPopover = (onReset={() => deleteProperty(properties.textOverflow)}/><ToggleGroupControl- style={currentStyle}- onValueChange={(value) =>- setTextOverflow({ type: "keyword", value })- }- value={toValue(currentStyle.textOverflow?.value)}+ {...props}+ property={properties.textOverflow}items={[{child: <CrossSmallIcon />,@@ -539,14 +477,3 @@ export const TypographySectionAdvancedPopover = (</FloatingPanel>);};--const getTextAlign = (value: string) => {- switch (value) {- case "left":- return "start";- case "right":- return "end";- default:- return value;- }-};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 3a56413bfc..20323b8570 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@@ -1,11 +1,16 @@import type { StyleProperty } from "@webstudio-is/css-engine";-import { SectionTitle, SectionTitleLabel } from "@webstudio-is/design-system";+import {+ SectionTitle,+ SectionTitleButton,+ SectionTitleLabel,+} from "@webstudio-is/design-system";import type { ReactNode } from "react";import {- CollapsibleSectionBase,+ CollapsibleSectionRoot,useOpenState,} from "~/builder/shared/collapsible-section";import { getStyleSource, type StyleInfo } from "./style-info";+import { PlusIcon } from "@webstudio-is/icons";export const getDots = (currentStyle: StyleInfo,@@ -29,23 +34,39 @@ export const CollapsibleSection = (props: {currentStyle: StyleInfo;properties: ReadonlyArray<StyleProperty>;fullWidth?: boolean;+ onAdd?: () => void;}) => {- const { label, children, currentStyle, properties, fullWidth } = props;+ const { label, children, currentStyle, properties, fullWidth, onAdd } = props;const [isOpen, setIsOpen] = useOpenState(props);return (- <CollapsibleSectionBase+ <CollapsibleSectionRootlabel={label}isOpen={isOpen}onOpenChange={setIsOpen}trigger={- <SectionTitle dots={getDots(currentStyle, properties)}>+ <SectionTitle+ dots={getDots(currentStyle, properties)}+ suffix={+ onAdd && (+ <SectionTitleButton+ prefix={<PlusIcon />}+ onClick={() => {+ if (isOpen === false) {+ setIsOpen(true);+ }+ onAdd();+ }}+ />+ )+ }+ ><SectionTitleLabel>{label}</SectionTitleLabel></SectionTitle>}fullWidth={fullWidth}>{children}- </CollapsibleSectionBase>+ </CollapsibleSectionRoot>);};diff --git a/apps/builder/app/builder/features/style-panel/shared/color-picker.tsx b/apps/builder/app/builder/features/style-panel/shared/color-picker.tsxindex e554147e7c..8b76e9b691 100644--- a/apps/builder/app/builder/features/style-panel/shared/color-picker.tsx+++ b/apps/builder/app/builder/features/style-panel/shared/color-picker.tsx@@ -97,6 +97,7 @@ type ColorPickerProps = {styleSource: StyleSource;keywords?: Array<KeywordValue>;property: StyleProperty;+ disabled?: boolean;};export const ColorPicker = ({@@ -110,6 +111,7 @@ export const ColorPicker = ({styleSource,keywords,property,+ disabled,}: ColorPickerProps) => {const [displayColorPicker, setDisplayColorPicker] = useState(false);const { enableCanvasPointerEvents, disableCanvasPointerEvents } =@@ -222,6 +224,7 @@ export const ColorPicker = ({return (<CssValueInput+ disabled={disabled}styleSource={styleSource}prefix={prefix}showSuffix={false}diff --git a/apps/builder/app/builder/features/style-panel/shared/configs.ts b/apps/builder/app/builder/features/style-panel/shared/configs.tsindex 76fc7cc5ff..8bd1530446 100644--- a/apps/builder/app/builder/features/style-panel/shared/configs.ts+++ b/apps/builder/app/builder/features/style-panel/shared/configs.ts@@ -85,7 +85,7 @@ export const styleConfigByName = (propertyName: StyleProperty): StyleConfig => {const result = {label,property,- appliesTo: properties[property].appliesTo,+ appliesTo: properties[property]?.appliesTo ?? "allElements",control: getControl(property),items: keywords.map((keyword) => ({ label: keyword, name: keyword })),};diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsxindex 67c40433ce..3b4655120f 100644--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx@@ -1,19 +1,19 @@-import { matchSorter } from "match-sorter";import {Box,useCombobox,- Combobox,+ ComboboxRoot,ComboboxContent,ComboboxAnchor,ComboboxListbox,ComboboxListboxItem,+ ComboboxItemDescription,+ ComboboxScrollArea,numericScrubControl,NestedInputButton,NestedIconLabel,InputField,handleNumericInputArrowKeys,theme,- ComboboxItemDescription,} from "@webstudio-is/design-system";import type {KeywordValue,@@ -35,7 +35,7 @@ import { parseIntermediateOrInvalidValue } from "./parse-intermediate-or-invalidimport { toValue } from "@webstudio-is/css-engine";import { useDebouncedCallback } from "use-debounce";import type { StyleSource } from "../style-info";-import { toPascalCase } from "../keyword-utils";+import { toKebabCase } from "../keyword-utils";import {declarationDescriptions,isValidDeclaration,@@ -49,6 +49,9 @@ import { convertUnits } from "./convert-units";// We need to enable scrub on properties that can have numeric value.const canBeNumber = (property: StyleProperty) => {+ if (property in properties === false) {+ return true;+ }const { unitGroups } = properties[property as keyof typeof properties];return unitGroups.length !== 0;};@@ -275,6 +278,7 @@ export type ChangeReason =| "scrub-end";type CssValueInputProps = {+ autoFocus?: boolean;styleSource: StyleSource;property: StyleProperty;value: StyleValue | undefined;@@ -305,21 +309,11 @@ const itemToString = (item: CssValueInputValue | null) => {return item === null? "": item.type === "keyword"- ? toPascalCase(toValue(item))+ ? toKebabCase(toValue(item)): item.type === "intermediate" || item.type === "unit"? String(item.value): toValue(item);};--const match = <Item,>(- search: string,- items: Array<Item>,- itemToString: (item: Item | null) => string-) =>- matchSorter(items, search, {- keys: [itemToString, (item) => itemToString(item).replace(/\s/g, "-")],- });-/*** Common:* - Free text editing@@ -352,6 +346,7 @@ const match = <Item,>(* - Evaluated math expression: "2px + 3em" (like CSS calc())*/export const CssValueInput = ({+ autoFocus,icon,prefix,showSuffix = true,@@ -421,7 +416,6 @@ export const CssValueInput = ({value,selectedItem: props.value,itemToString,- match,onInputChange: (inputValue) => {onChange(inputValue);},@@ -648,7 +642,7 @@ export const CssValueInput = ({}return (- <Combobox open={isOpen}>+ <ComboboxRoot open={isOpen}><Box {...getComboboxProps()}><ComboboxAnchor><InputField@@ -660,9 +654,10 @@ export const CssValueInput = ({inputRef.current?.select();}}}+ autoFocus={autoFocus}onBlur={handleOnBlur}onKeyDown={handleKeyDown}- containerRef={scrubRef}+ containerRef={disabled ? undefined : scrubRef}inputRef={inputRef}name={property}color={value.type === "invalid" ? "error" : undefined}@@ -674,14 +669,16 @@ export const CssValueInput = ({{isOpen && (<ComboboxContent align="start" sideOffset={2} collisionPadding={10}><ComboboxListbox {...menuProps}>- {items.map((item, index) => (- <ComboboxListboxItem- {...getItemProps({ item, index })}- key={index}- >- {itemToString(item)}- </ComboboxListboxItem>- ))}+ <ComboboxScrollArea>+ {items.map((item, index) => (+ <ComboboxListboxItem+ {...getItemProps({ item, index })}+ key={index}+ >+ {itemToString(item)}+ </ComboboxListboxItem>+ ))}+ </ComboboxScrollArea>{description && (<ComboboxItemDescription><Box css={{ width: theme.spacing[25] }}>{description}</Box>@@ -691,6 +688,6 @@ export const CssValueInput = ({</ComboboxContent>)}</Box>- </Combobox>+ </ComboboxRoot>);};diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts b/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.tsindex 77b8d45a14..87da3761a8 100644--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts@@ -16,6 +16,13 @@ export const parseIntermediateOrInvalidValue = (): StyleValue => {const value = styleValue.value.trim();+ if (property.startsWith("--")) {+ return {+ type: "unparsed",+ value,+ };+ }+// Try value with existing or fallback unitconst unit = "unit" in styleValue ? styleValue.unit ?? "px" : "px";let styleInput = parseCssValue(property, `${value}${unit}`);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 052d6221b6..e360605453 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@@ -1,5 +1,4 @@import type { CssValueInputValue } from "./css-value-input";-import { toPascalCase } from "../keyword-utils";import {keywordValues,properties,@@ -40,6 +39,10 @@ export const buildOptions = (: undefined;const options: UnitOption[] = [];++ if (property in properties === false) {+ return options;+ }const { unitGroups } = properties[property as keyof typeof properties];for (const unitGroup of unitGroups) {@@ -58,7 +61,7 @@ export const buildOptions = (options.push({id: unit,type: "unit",- label: unit.toLocaleUpperCase(),+ label: unit,});}}@@ -89,10 +92,7 @@ export const buildOptions = (options.push({id: unit,type: "unit",- label:- unit === "number"- ? nestedSelectButtonUnitless- : unit.toLocaleUpperCase(),+ label: unit === "number" ? nestedSelectButtonUnitless : unit,});}@@ -125,7 +125,7 @@ export const buildOptions = (for (const keyword of webstudioKeywords) {options.push({id: keyword,- label: toPascalCase(keyword),+ label: keyword,type: "keyword",});}@@ -136,7 +136,7 @@ export const buildOptions = () {options.push({id: value.value,- label: toPascalCase(value.value),+ label: value.value,type: "keyword",});}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 55379e1e86..d1ddaab778 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@@ -15,7 +15,7 @@ describe("Unit menu options", () => {[{"id": "px",- "label": "PX",+ "label": "px","type": "unit",},{@@ -25,27 +25,27 @@ describe("Unit menu options", () => {},{"id": "em",- "label": "EM",+ "label": "em","type": "unit",},{"id": "rem",- "label": "REM",+ "label": "rem","type": "unit",},{"id": "dvw",- "label": "DVW",+ "label": "dvw","type": "unit",},{"id": "dvh",- "label": "DVH",+ "label": "dvh","type": "unit",},{"id": "auto",- "label": "Auto",+ "label": "auto","type": "keyword",},]@@ -73,7 +73,7 @@ describe("Unit menu options", () => {[{"id": "px",- "label": "PX",+ "label": "px","type": "unit",},{@@ -83,27 +83,27 @@ describe("Unit menu options", () => {},{"id": "em",- "label": "EM",+ "label": "em","type": "unit",},{"id": "rem",- "label": "REM",+ "label": "rem","type": "unit",},{"id": "dvw",- "label": "DVW",+ "label": "dvw","type": "unit",},{"id": "dvh",- "label": "DVH",+ "label": "dvh","type": "unit",},{"id": "auto",- "label": "Auto",+ "label": "auto","type": "keyword",},]diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.tsx b/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.tsxindex 6e6f7d5f07..998615162f 100644--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.tsx+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/unit-select.tsx@@ -138,7 +138,7 @@ const UnitSelect = ({</SelectScrollUpButton><SelectViewport>{options.map(({ id, label }) => (- <SelectItem key={id} value={id}>+ <SelectItem key={id} value={id} text="sentence">{label}</SelectItem>))}diff --git a/apps/builder/app/builder/features/style-panel/shared/style-info.ts b/apps/builder/app/builder/features/style-panel/shared/style-info.tsindex 06dda0cc07..2467f9f90e 100644--- a/apps/builder/app/builder/features/style-panel/shared/style-info.ts+++ b/apps/builder/app/builder/features/style-panel/shared/style-info.ts@@ -160,7 +160,8 @@ export const getStyleSource = (return "default";};-const styleProperties = Object.keys(properties) as StyleProperty[];+const propertyNames = Object.keys(properties) as StyleProperty[];+const inheritableProperties = new Set<string>();for (const [property, value] of Object.entries(properties)) {if (value.inherited) {@@ -686,14 +687,29 @@ const useStyleInfoByInstanceAndStyleSource = (return style;}, [instanceSelector, instanceToTag]);+ const allPropertyNames = useMemo(() => {+ const [selectedInstanceId] = instanceSelector ?? [];+ const all: Set<StyleProperty> = new Set(propertyNames);+ const styles = stylesByInstanceId.get(selectedInstanceId);+ if (styles) {+ for (const styleDecl of styles) {+ if (all.has(styleDecl.property) === false) {+ all.add(styleDecl.property);+ }+ }+ }+ return Array.from(all);+ }, [instanceSelector, stylesByInstanceId]);+const styleInfoData = useMemo(() => {const styleInfoData: StyleInfo = {};- for (const property of styleProperties) {+ for (const property of allPropertyNames) {// temporary solution until we start computing all styles from dataconst htmlValue = htmlStyle?.[property];- const defaultValue =- CUSTOM_DEFAULT_VALUES[property] ??- properties[property as keyof typeof properties].initial;+ const defaultValue = CUSTOM_DEFAULT_VALUES[property] ??+ properties[property as keyof typeof properties]?.initial ?? {+ type: "guaranteedInvalid",+ };const preset = presetStyle?.[property];const inherited = inheritedInfo[property];const cascaded = cascadedInfo[property];@@ -714,6 +730,7 @@ const useStyleInfoByInstanceAndStyleSource = (htmlValue;const inheritedValue = inherited?.value;const value = ownValue ?? inheritedValue ?? defaultValue;+if (value) {if (property === "color") {const ownColor =@@ -766,6 +783,7 @@ const useStyleInfoByInstanceAndStyleSource = (nextSourceInfo,previousSourceInfo,selectedStyle,+ allPropertyNames,]);return styleInfoData;@@ -863,3 +881,22 @@ export const getPriorityStyleSource = (return "default";};++/**+ * Has any value defined on that particular instance,+ * excluding preset and inherited values.+ */+export const hasInstanceValue = (+ currentStyle: StyleInfo,+ property: StyleProperty+) => {+ const info = currentStyle[property];+ return Boolean(+ info?.cascaded ??+ info?.local ??+ info?.stateful ??+ info?.stateless ??+ info?.nextSource?.value ??+ info?.previousSource?.value+ );+};diff --git a/apps/builder/app/builder/features/style-panel/shared/use-style-data.ts b/apps/builder/app/builder/features/style-panel/shared/use-style-data.tsindex 7ac0b91300..e6e51af130 100644--- a/apps/builder/app/builder/features/style-panel/shared/use-style-data.ts+++ b/apps/builder/app/builder/features/style-panel/shared/use-style-data.ts@@ -4,6 +4,7 @@ import {type Breakpoint,type Instance,getStyleDeclKey,+ StyleDecl,} from "@webstudio-is/sdk";import type { StyleProperty, StyleValue } from "@webstudio-is/css-engine";import {@@ -36,11 +37,7 @@ type StyleUpdates = {state: undefined | string;};-type UseStyleData = {- selectedInstance: Instance;-};--export type StyleUpdateOptions = { isEphemeral: boolean };+export type StyleUpdateOptions = { isEphemeral?: boolean; listed?: boolean };export type SetValue = (style: StyleValue,@@ -60,13 +57,17 @@ export type CreateBatchUpdate = () => {publish: (options?: StyleUpdateOptions) => void;};-export const useStyleData = ({ selectedInstance }: UseStyleData) => {+export const useStyleData = (selectedInstance: Instance) => {const selectedBreakpoint = useStore($selectedBreakpoint);const currentStyle = useStyleInfo();const publishUpdates = useCallback(- (type: "update" | "preview", updates: StyleUpdates["updates"]) => {+ (+ type: "update" | "preview",+ updates: StyleUpdates["updates"],+ options: StyleUpdateOptions+ ) => {const selectedStyleSource = $selectedStyleSource.get();const styleSourceSelector = $selectedOrLastStyleSourceSelector.get();@@ -90,6 +91,7 @@ export const useStyleData = ({ selectedInstance }: UseStyleData) => {state: styleSourceSelector.state,property: update.property,value: update.value,+ listed: options.listed,});}}@@ -120,12 +122,13 @@ export const useStyleData = ({ selectedInstance }: UseStyleData) => {for (const update of updates) {if (update.operation === "set") {- const styleDecl = {+ const styleDecl: StyleDecl = {breakpointId,styleSourceId: styleSourceSelector.styleSourceId,state: styleSourceSelector.state,property: update.property,value: update.value,+ listed: options.listed,};styles.set(getStyleDeclKey(styleDecl), styleDecl);}@@ -148,12 +151,12 @@ export const useStyleData = ({ selectedInstance }: UseStyleData) => {const setProperty = useCallback<SetProperty>((property) => {- return (value, options = { isEphemeral: false }) => {+ return (value, options: StyleUpdateOptions = { isEphemeral: false }) => {if (value.type !== "invalid") {const updates = [{ operation: "set" as const, property, value }];const type = options.isEphemeral ? "preview" : "update";- publishUpdates(type, updates);+ publishUpdates(type, updates, options);}};},@@ -161,10 +164,13 @@ export const useStyleData = ({ selectedInstance }: UseStyleData) => {);const deleteProperty = useCallback(- (property: StyleProperty, options = { isEphemeral: false }) => {+ (+ property: StyleProperty,+ options: StyleUpdateOptions = { isEphemeral: false }+ ) => {const updates = [{ operation: "delete" as const, property }];const type = options.isEphemeral ? "preview" : "update";- publishUpdates(type, updates);+ publishUpdates(type, updates, options);},[publishUpdates]);@@ -187,12 +193,12 @@ export const useStyleData = ({ selectedInstance }: UseStyleData) => {updates.push({ operation: "delete", property });};- const publish = (options = { isEphemeral: false }) => {+ const publish = (options: StyleUpdateOptions = { isEphemeral: false }) => {if (!updates.length) {return;}const type = options.isEphemeral ? "preview" : "update";- publishUpdates(type, updates);+ publishUpdates(type, updates, options);updates = [];};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 0cf1507318..2c3ee85500 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@@ -3,7 +3,7 @@ import type {LayersValue,StyleProperty,} from "@webstudio-is/css-engine";-import type { RenderCategoryProps } from "./style-sections";+import type { SectionProps } from "./sections";import type { StyleInfo } from "./shared/style-info";import type { CreateBatchUpdate } from "./shared/use-style-data";@@ -11,7 +11,7 @@ export const deleteLayer = (property: StyleProperty,index: number,layers: LayersValue,- createBatchUpdate: RenderCategoryProps["createBatchUpdate"]+ createBatchUpdate: SectionProps["createBatchUpdate"]) => {const batch = createBatchUpdate();const value = layers.value[index];@@ -42,7 +42,7 @@ export const hideLayer = (property: StyleProperty,index: number,layers: LayersValue,- createBatchUpdate: RenderCategoryProps["createBatchUpdate"]+ createBatchUpdate: SectionProps["createBatchUpdate"]) => {const batch = createBatchUpdate();const value = layers.value[index];@@ -67,7 +67,7 @@ export const addLayer = (property: StyleProperty,value: LayersValue | InvalidValue,style: StyleInfo,- createBatchUpdate: RenderCategoryProps["createBatchUpdate"]+ createBatchUpdate: SectionProps["createBatchUpdate"]) => {if (value.type === "invalid") {return;@@ -91,7 +91,7 @@ export const updateLayer = (newValue: LayersValue,layers: LayersValue,index: number,- createBatchUpdate: RenderCategoryProps["createBatchUpdate"]+ createBatchUpdate: SectionProps["createBatchUpdate"]) => {const batch = createBatchUpdate();const value = layers.value[index];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.tsxindex 004ce9cde4..09f5c4431b 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@@ -4,7 +4,7 @@ import {Flex,useSortable,} from "@webstudio-is/design-system";-import type { RenderCategoryProps } from "./style-sections";+import type { SectionProps } from "./sections";import {deleteLayer,getLayerCount,@@ -31,7 +31,7 @@ export type LayerProps<T> = {deleteProperty: DeleteProperty;};-type LayerListProperties<T> = RenderCategoryProps & {+type LayerListProperties<T> = SectionProps & {disabled?: boolean;property: StyleProperty;layers: LayersValue;diff --git a/apps/builder/app/builder/features/style-panel/style-panel.tsx b/apps/builder/app/builder/features/style-panel/style-panel.tsxindex b7bf543390..b4bc9d7f31 100644--- a/apps/builder/app/builder/features/style-panel/style-panel.tsx+++ b/apps/builder/app/builder/features/style-panel/style-panel.tsx@@ -7,13 +7,46 @@ import {ScrollArea,} from "@webstudio-is/design-system";import type { Instance } from "@webstudio-is/sdk";+import { useStore } from "@nanostores/react";+import { computed } from "nanostores";+import type { htmlTags as HtmlTag } from "html-tags";import { useStyleData } from "./shared/use-style-data";-import { StyleSettings } from "./style-settings";import { StyleSourcesSection } from "./style-source-section";import { $selectedInstanceRenderState } from "~/shared/nano-states";-import { useStore } from "@nanostores/react";+import {+ $selectedInstanceIntanceToTag,+ $selectedInstanceSelector,+} from "~/shared/nano-states";+import { sections } from "./sections";+import { useParentStyle } from "./parent-style";+import type { StyleInfo } from "./shared/style-info";+import { toValue } from "@webstudio-is/css-engine";++const $selectedInstanceTag = computed(+ [$selectedInstanceSelector, $selectedInstanceIntanceToTag],+ (instanceSelector, instanceToTag) => {+ if (instanceSelector === undefined || instanceToTag === undefined) {+ return;+ }+ return instanceToTag.get(instanceSelector[0]);+ }+);++const shouldRenderCategory = (+ category: string,+ parentStyle: StyleInfo,+ tag: undefined | HtmlTag+) => {+ switch (category) {+ case "flexChild":+ return toValue(parentStyle.display?.value).includes("flex");+ case "listItem":+ return tag === "ul" || tag === "ol" || tag === "li";+ }+ return true;+};type StylePanelProps = {selectedInstance: Instance;@@ -21,11 +54,11 @@ type StylePanelProps = {export const StylePanel = ({ selectedInstance }: StylePanelProps) => {const { currentStyle, setProperty, deleteProperty, createBatchUpdate } =- useStyleData({- selectedInstance,- });+ useStyleData(selectedInstance);const selectedInstanceRenderState = useStore($selectedInstanceRenderState);+ const selectedInstanceTag = useStore($selectedInstanceTag);+ const parentStyle = useParentStyle();// If selected instance is not rendered on the canvas,// style panel will not work, because it needs the element in DOM in order to work.@@ -40,28 +73,32 @@ export const StylePanel = ({ selectedInstance }: StylePanelProps) => {);}+ const all = [];++ for (const [category, { Section }] of sections.entries()) {+ if (shouldRenderCategory(category, parentStyle, selectedInstanceTag)) {+ all.push(+ <Section+ key={category}+ setProperty={setProperty}+ deleteProperty={deleteProperty}+ createBatchUpdate={createBatchUpdate}+ currentStyle={currentStyle}+ />+ );+ }+ }+return (<>- <Box- css={{- px: theme.spacing[9],- pb: theme.spacing[9],- }}- >+ <Box css={{ px: theme.spacing[9], pb: theme.spacing[9] }}><Text css={{ py: theme.spacing[7] }} variant="titles">Style Sources</Text><StyleSourcesSection /></Box><Separator />- <ScrollArea>- <StyleSettings- currentStyle={currentStyle}- setProperty={setProperty}- deleteProperty={deleteProperty}- createBatchUpdate={createBatchUpdate}- />- </ScrollArea>+ <ScrollArea>{all}</ScrollArea></>);};diff --git a/apps/builder/app/builder/features/style-panel/style-sections.tsx b/apps/builder/app/builder/features/style-panel/style-sections.tsxdeleted file mode 100644index 0003c2c490..0000000000--- a/apps/builder/app/builder/features/style-panel/style-sections.tsx+++ /dev/null@@ -1,163 +0,0 @@-import type { htmlTags as HtmlTag } from "html-tags";-import { Grid } from "@webstudio-is/design-system";-import { toValue } from "@webstudio-is/css-engine";-import type { StyleProperty } from "@webstudio-is/css-engine";-import { styleConfigByName } from "./shared/configs";-import type {- SetProperty,- DeleteProperty,- CreateBatchUpdate,-} from "./shared/use-style-data";-import { PropertyName } from "./shared/property-name";-import type { StyleInfo } from "./shared/style-info";-import * as controls from "./controls";-import {- LayoutSection,- FlexChildSection,- GridChildSection,- SpaceSection,- SizeSection,- PositionSection,- TypographySection,- BackgroundsSection,- BordersSection,- OutlineSection,- EffectsSection,- BoxShadowsSection,- ListItemSection,- TransitionSection,- FilterSection,-} from "./sections";--export const categories = [- "layout",- "flexChild",- "gridChild",- "listItem",- "space",- "size",- "position",- "typography",- "backgrounds",- "borders",- "boxShadows",- "effects",- "outline",- "transitions",- "filter",-] as const;--export type Category = (typeof categories)[number];--export type ControlProps = {- property: StyleProperty;- items?: Array<{ label: string; name: string }>;- currentStyle: StyleInfo;- setProperty: SetProperty;- deleteProperty: DeleteProperty;- disabled?: boolean;-};--export type RenderCategoryProps = {- setProperty: SetProperty;- deleteProperty: DeleteProperty;- createBatchUpdate: CreateBatchUpdate;- currentStyle: StyleInfo;- category: Category;-};--export type RenderPropertyProps = {- property: StyleProperty;- currentStyle: StyleInfo;- setProperty: SetProperty;- deleteProperty: DeleteProperty;-};--export const renderProperty = ({- property,- currentStyle,- setProperty,- deleteProperty,-}: RenderPropertyProps) => {- const { label, control, items } = styleConfigByName(property);- const Control = controls[control];- if (!Control) {- return null;- }-- return (- <Grid key={property} css={{ gridTemplateColumns: "4fr 6fr" }} gap={2}>- <PropertyName- style={currentStyle}- properties={[property]}- label={label}- onReset={() => deleteProperty(property)}- />- <Control- property={property}- items={items}- currentStyle={currentStyle}- setProperty={setProperty}- deleteProperty={deleteProperty}- />- </Grid>- );-};--export const renderCategory = ({- setProperty,- deleteProperty,- createBatchUpdate,- currentStyle,- category,-}: RenderCategoryProps) => {- const Section = sections[category];-- return (- <Section- setProperty={setProperty}- deleteProperty={deleteProperty}- createBatchUpdate={createBatchUpdate}- currentStyle={currentStyle}- category={category}- />- );-};--export const shouldRenderCategory = (- { currentStyle, category }: RenderCategoryProps,- parentStyle: StyleInfo,- tag: undefined | HtmlTag-) => {- switch (category) {- case "flexChild":- return toValue(parentStyle.display?.value).includes("flex");- case "gridChild":- return toValue(currentStyle.display?.value).includes("grid");- case "listItem":- return tag === "ul" || tag === "ol" || tag === "li";- }-- return true;-};--export const sections: Record<- Category,- (props: RenderCategoryProps) => JSX.Element | undefined-> = {- layout: LayoutSection,- flexChild: FlexChildSection,- gridChild: GridChildSection,- listItem: ListItemSection,- space: SpaceSection,- size: SizeSection,- position: PositionSection,- typography: TypographySection,- backgrounds: BackgroundsSection,- borders: BordersSection,- outline: OutlineSection,- effects: EffectsSection,- boxShadows: BoxShadowsSection,- transitions: TransitionSection,- filter: FilterSection,-};diff --git a/apps/builder/app/builder/features/style-panel/style-settings.tsx b/apps/builder/app/builder/features/style-panel/style-settings.tsxdeleted file mode 100644index 4e8bd71ea7..0000000000--- a/apps/builder/app/builder/features/style-panel/style-settings.tsx+++ /dev/null@@ -1,63 +0,0 @@-import { Fragment } from "react";-import type { StyleProperty } from "@webstudio-is/css-engine";-import {- categories,- renderCategory,- shouldRenderCategory,- type RenderCategoryProps,-} from "./style-sections";-import type { SetProperty, CreateBatchUpdate } from "./shared/use-style-data";-import type { StyleInfo } from "./shared/style-info";-import { useStore } from "@nanostores/react";-import {- $selectedInstanceIntanceToTag,- $selectedInstanceSelector,-} from "~/shared/nano-states";-import { computed } from "nanostores";-import { useParentStyle } from "./parent-style";--export type StyleSettingsProps = {- currentStyle: StyleInfo;- setProperty: SetProperty;- deleteProperty: (property: StyleProperty) => void;- createBatchUpdate: CreateBatchUpdate;-};--const $selectedInstanceTag = computed(- [$selectedInstanceSelector, $selectedInstanceIntanceToTag],- (instanceSelector, instanceToTag) => {- if (instanceSelector === undefined || instanceToTag === undefined) {- return;- }- return instanceToTag.get(instanceSelector[0]);- }-);--export const StyleSettings = ({- setProperty,- deleteProperty,- createBatchUpdate,- currentStyle,-}: StyleSettingsProps) => {- const selectedInstanceTag = useStore($selectedInstanceTag);- const all = [];- const parentStyle = useParentStyle();-- for (const category of categories) {- const categoryProps: RenderCategoryProps = {- setProperty,- deleteProperty,- createBatchUpdate,- currentStyle,- category,- };-- if (shouldRenderCategory(categoryProps, parentStyle, selectedInstanceTag)) {- all.push(- <Fragment key={category}>{renderCategory(categoryProps)}</Fragment>- );- }- }-- return <>{all}</>;-};diff --git a/apps/builder/app/builder/features/style-panel/style-source/style-source-input.tsx b/apps/builder/app/builder/features/style-panel/style-source/style-source-input.tsxindex 158bda6636..c8678cea3a 100644--- a/apps/builder/app/builder/features/style-panel/style-source/style-source-input.tsx+++ b/apps/builder/app/builder/features/style-panel/style-source/style-source-input.tsx@@ -16,7 +16,7 @@ import {Box,ComboboxListbox,ComboboxListboxItem,- Combobox,+ ComboboxRoot,ComboboxAnchor,ComboboxContent,DeprecatedTextFieldInput,@@ -32,6 +32,7 @@ import {theme,styled,Flex,+ ComboboxScrollArea,} from "@webstudio-is/design-system";import { CheckMarkIcon, DotIcon, LocalStyleIcon } from "@webstudio-is/icons";import {@@ -476,7 +477,7 @@ export const StyleSourceInput = (const states = props.componentStates ?? [];return (- <Combobox open={isOpen}>+ <ComboboxRoot open={isOpen}><Box {...getComboboxProps()}><ComboboxAnchor><TextField@@ -512,74 +513,76 @@ export const StyleSourceInput = (</ComboboxAnchor><ComboboxContent align="start" sideOffset={5}><ComboboxListbox {...getMenuProps()}>- {isOpen &&- items.map((item, index) => {- if (item.source === "local") {- return;- }+ <ComboboxScrollArea>+ {isOpen &&+ items.map((item, index) => {+ if (item.source === "local") {+ return;+ }++ if (item.id === newItemId) {+ hasNewTokenItem = true;+ return (+ <Fragment key={index}>+ <ComboboxLabel>New Token</ComboboxLabel>+ <ComboboxListboxItem+ {...getItemProps({ item, index })}+ selectable={false}+ >+ <div>+ Create{" "}+ <StyleSourceBadge source="token">+ {item.label}+ </StyleSourceBadge>+ </div>+ </ComboboxListboxItem>+ </Fragment>+ );+ }++ let label = null;+ if (item.source === "token" && hasGlobalTokenItem === false) {+ hasGlobalTokenItem = true;+ label = (+ <>+ {hasNewTokenItem && <ComboboxSeparator />}+ <ComboboxLabel>Global Tokens</ComboboxLabel>+ </>+ );+ }- if (item.id === newItemId) {- hasNewTokenItem = true;+ if (+ item.source === "componentToken" &&+ hasComponentTokenItem === false+ ) {+ hasComponentTokenItem = true;+ label = (+ <>+ {(hasNewTokenItem || hasGlobalTokenItem) && (+ <ComboboxSeparator />+ )}+ <ComboboxLabel>Component Tokens</ComboboxLabel>+ </>+ );+ }return (<Fragment key={index}>- <ComboboxLabel>New Token</ComboboxLabel>+ {label}<ComboboxListboxItem{...getItemProps({ item, index })}selectable={false}>- <div>- Create{" "}- <StyleSourceBadge source="token">- {item.label}- </StyleSourceBadge>- </div>+ <StyleSourceBadge source={item.source}>+ {item.label}+ </StyleSourceBadge></ComboboxListboxItem></Fragment>);- }-- let label = null;- if (item.source === "token" && hasGlobalTokenItem === false) {- hasGlobalTokenItem = true;- label = (- <>- {hasNewTokenItem && <ComboboxSeparator />}- <ComboboxLabel>Global Tokens</ComboboxLabel>- </>- );- }-- if (- item.source === "componentToken" &&- hasComponentTokenItem === false- ) {- hasComponentTokenItem = true;- label = (- <>- {(hasNewTokenItem || hasGlobalTokenItem) && (- <ComboboxSeparator />- )}- <ComboboxLabel>Component Tokens</ComboboxLabel>- </>- );- }- return (- <Fragment key={index}>- {label}- <ComboboxListboxItem- {...getItemProps({ item, index })}- selectable={false}- >- <StyleSourceBadge source={item.source}>- {item.label}- </StyleSourceBadge>- </ComboboxListboxItem>- </Fragment>- );- })}+ })}+ </ComboboxScrollArea></ComboboxListbox></ComboboxContent></Box>- </Combobox>+ </ComboboxRoot>);};diff --git a/apps/builder/app/builder/features/topbar/collapsible-domain-section.tsx b/apps/builder/app/builder/features/topbar/collapsible-domain-section.tsxindex 208831b415..72da9b5485 100644--- a/apps/builder/app/builder/features/topbar/collapsible-domain-section.tsx+++ b/apps/builder/app/builder/features/topbar/collapsible-domain-section.tsx@@ -6,7 +6,7 @@ import {SectionTitle,} from "@webstudio-is/design-system";import { useEffect, useRef, useState, type ReactNode } from "react";-import { CollapsibleSectionBase } from "~/builder/shared/collapsible-section";+import { CollapsibleSectionRoot } from "~/builder/shared/collapsible-section";export const CollapsibleDomainSection = ({initiallyOpen = false,@@ -31,7 +31,7 @@ export const CollapsibleDomainSection = ({}, [open]);return (- <CollapsibleSectionBase+ <CollapsibleSectionRootlabel=""fullWidthisOpen={open}@@ -67,6 +67,6 @@ export const CollapsibleDomainSection = ({>{children}</Flex>- </CollapsibleSectionBase>+ </CollapsibleSectionRoot>);};diff --git a/apps/builder/app/builder/shared/collapsible-section.tsx b/apps/builder/app/builder/shared/collapsible-section.tsxindex a6ec1de982..54186d34ec 100644--- a/apps/builder/app/builder/shared/collapsible-section.tsx+++ b/apps/builder/app/builder/shared/collapsible-section.tsx@@ -44,7 +44,7 @@ type CollapsibleSectionBaseProps = {onOpenChange: (value: boolean) => void;};-export const CollapsibleSectionBase = ({+export const CollapsibleSectionRoot = ({label,trigger,children,@@ -90,7 +90,7 @@ export const CollapsibleSection = (props: CollapsibleSectionProps) => {const { label, trigger, children, fullWidth } = props;const [isOpen, setIsOpen] = useOpenState(props);return (- <CollapsibleSectionBase+ <CollapsibleSectionRootlabel={label}trigger={trigger}fullWidth={fullWidth}@@ -98,7 +98,7 @@ export const CollapsibleSection = (props: CollapsibleSectionProps) => {onOpenChange={setIsOpen}>{children}- </CollapsibleSectionBase>+ </CollapsibleSectionRoot>);};@@ -125,7 +125,7 @@ export const CollapsibleSectionWithAddButton = ({const isOpenFinal = isOpen && isEmpty === false;return (- <CollapsibleSectionBase+ <CollapsibleSectionRootlabel={label}fullWidth={false}isOpen={isOpenFinal}@@ -155,6 +155,6 @@ export const CollapsibleSectionWithAddButton = ({}>{children}- </CollapsibleSectionBase>+ </CollapsibleSectionRoot>);};diff --git a/apps/builder/app/canvas/stores.ts b/apps/builder/app/canvas/stores.tsindex 4ded45be36..3f8d8053c5 100644--- a/apps/builder/app/canvas/stores.ts+++ b/apps/builder/app/canvas/stores.ts@@ -3,14 +3,7 @@ import type { Instance, StyleDecl } from "@webstudio-is/sdk";import type { Params } from "@webstudio-is/react-sdk";export const $ephemeralStyles = atom<- Array<{- instanceId: Instance["id"];- breakpointId: StyleDecl["breakpointId"];- state: StyleDecl["state"];- styleSourceId: StyleDecl["styleSourceId"];- property: StyleDecl["property"];- value: StyleDecl["value"];- }>+ Array<StyleDecl & { instanceId: Instance["id"] }>>([]);export const $params = atom<undefined | Params>();diff --git a/packages/design-system/src/components/combobox.stories.tsx b/packages/design-system/src/components/combobox.stories.tsxindex 5eaf0473c9..097eaa8c69 100644--- a/packages/design-system/src/components/combobox.stories.tsx+++ b/packages/design-system/src/components/combobox.stories.tsx@@ -9,14 +9,30 @@ import {useCombobox,comboboxStateChangeTypes,ComboboxContent,- Combobox,+ ComboboxRoot,ComboboxListbox,ComboboxAnchor,ComboboxItemDescription,+ Combobox,} from "./combobox";import { Flex } from "./flex";import { InputField } from "./input-field";+export const Basic = () => {+ const [value, setValue] = useState("");+ return (+ <Combobox<string>+ value={value}+ itemToString={(item) => item ?? ""}+ items={["Apple", "Banana", "Orange"]}+ onItemSelect={setValue}+ onInputChange={(value) => {+ setValue(value ?? "");+ }}+ />+ );+};+export const Complex = () => {const [value, setValue] = useState("");@@ -77,7 +93,7 @@ export const Complex = () => {});return (- <Combobox open={isOpen}>+ <ComboboxRoot open={isOpen}><Flex {...getComboboxProps()} direction="column" gap="3"><ComboboxAnchor><InputField@@ -105,7 +121,7 @@ export const Complex = () => {</ComboboxListbox></ComboboxContent></Flex>- </Combobox>+ </ComboboxRoot>);};diff --git a/packages/design-system/src/components/combobox.tsx b/packages/design-system/src/components/combobox.tsxindex 2594323321..fc77071bf3 100644--- a/packages/design-system/src/components/combobox.tsx+++ b/packages/design-system/src/components/combobox.tsx@@ -35,9 +35,9 @@ import {MenuCheckedIcon,} from "./menu";import { ScrollArea } from "./scroll-area";-import { Flex } from "./flex";+import { Flex, InputField, NestedInputButton } from "..";-const Listbox = styled(+export const ComboboxListbox = styled("ul",{display: "flex",@@ -52,6 +52,26 @@ const Listbox = styled(menuCss);+export const ComboboxScrollArea = forwardRef(+ (+ { children, ...props }: ComponentProps<typeof ScrollArea>,+ forwardRef: Ref<HTMLDivElement>+ ) => {+ return (+ <ScrollArea css={{ order: 1 }} {...props}>+ <Flex+ ref={forwardRef}+ direction="column"+ css={{ maxHeight: theme.spacing[34] }}+ >+ {children}+ </Flex>+ </ScrollArea>+ );+ }+);+ComboboxScrollArea.displayName = "ComboboxScrollArea";+const ListboxItem = styled("li", menuItemCss);const Indicator = styled("span", menuItemIndicatorCss);@@ -79,6 +99,7 @@ const ListboxItemBase: ForwardRefRenderFunction<icon = <MenuCheckedIcon />,...rest} = props;+return (<ListboxItemref={ref}@@ -86,6 +107,7 @@ const ListboxItemBase: ForwardRefRenderFunction<{...(selected ? { "aria-current": true } : {})}{...(disabled ? {} : rest)}withIndicator={selectable}+ text={rest.text ?? "sentence"}>{selectable && selected && <Indicator>{icon}</Indicator>}{children}@@ -93,23 +115,6 @@ const ListboxItemBase: ForwardRefRenderFunction<);};-export const ComboboxListbox = forwardRef<- HTMLUListElement,- ComponentProps<typeof Listbox>->(({ children, ...props }, ref) => {- return (- <Listbox {...props} ref={ref}>- <ScrollArea>- <Flex direction="column" css={{ maxHeight: theme.spacing[34] }}>- {children}- </Flex>- </ScrollArea>- </Listbox>- );-});--ComboboxListbox.displayName = "ComboboxListbox";-export const ComboboxListboxItem = forwardRef(ListboxItemBase);export const ComboboxItemDescription = ({@@ -128,7 +133,10 @@ export const ComboboxItemDescription = ({<ListboxItem{...props}hint- style={{ ...style, order: "var(--ws-combobox-description-order)" }}+ style={{+ ...style,+ order: "var(--ws-combobox-description-order)",+ }}>{children}</ListboxItem>@@ -142,7 +150,7 @@ export const ComboboxItemDescription = ({);};-export const Combobox = (props: ComponentProps<typeof Popover>) => {+export const ComboboxRoot = (props: ComponentProps<typeof Popover>) => {return <Popover {...props} modal />;};@@ -194,13 +202,16 @@ const defaultMatch = <Item,>(keys: [itemToString],});+const defaultItemToString = <Item,>(item: Item) =>+ typeof item === "string" ? item : "";+const useFilter = <Item,>({items,- itemToString,+ itemToString = defaultItemToString,match = defaultMatch,}: {items: Array<Item>;- itemToString: (item: Item | null) => string;+ itemToString?: (item: Item | null) => string;match?: Match<Item>;}) => {const [filteredItems, setFilteredItems] = useState<Array<Item>>(items);@@ -229,11 +240,17 @@ const useFilter = <Item,>({};};+type ItemToString<Item> = (item: Item | null) => string;+type UseComboboxProps<Item> = UseDownshiftComboboxProps<Item> & {items: Array<Item>;- itemToString: (item: Item | null) => string;+ itemToString: ItemToString<Item>;+ getDescription?: (item: Item | null) => ReactNode;+ getItemProps?: (+ options: UseComboboxGetItemPropsOptions<Item>+ ) => ComponentProps<typeof ComboboxListboxItem>;value: Item | null; // This is to prevent: "downshift: A component has changed the uncontrolled prop "selectedItem" to be controlled."- selectedItem: Item | undefined;+ selectedItem?: Item;onInputChange?: (value: string | undefined) => void;onItemSelect?: (value: Item) => void;onItemHighlight?: (value: Item | null) => void;@@ -251,6 +268,7 @@ export const useCombobox = <Item,>({items,value,selectedItem,+ getItemProps,itemToString,onInputChange,onItemSelect,@@ -323,9 +341,6 @@ export const useCombobox = <Item,>({},});- const { getItemProps, highlightedIndex, getMenuProps, getInputProps } =- downshiftProps;-useEffect(() => {if (isOpen === false) {resetFilter();@@ -340,9 +355,10 @@ export const useCombobox = <Item,>({}}, [isOpen, onItemSelect]);+ const downshiftGetInputProps = downshiftProps.getInputProps;const enhancedGetInputProps = useCallback((options?: UseComboboxGetInputPropsOptions) => {- const inputProps = getInputProps(options);+ const inputProps = downshiftGetInputProps(options);return {...inputProps,onChange: (event: ChangeEvent<HTMLInputElement>) => {@@ -353,35 +369,47 @@ export const useCombobox = <Item,>({},};},- [getInputProps, onInputChange]+ [downshiftGetInputProps, onInputChange]);+ const downshiftHighlightedIndex = downshiftProps.highlightedIndex;+ const downshiftGetItemProps = downshiftProps.getItemProps;const enhancedGetItemProps = useCallback((options: UseComboboxGetItemPropsOptions<Item>) => {+ const itemOptions = {+ // We need to either deep compare objects here or use itemToString to get primitive types+ selected:+ selectedItem !== undefined &&+ itemToString(selectedItem) === itemToString(options.item),+ key: options.id,+ ...options,+ };+return {- highlighted: highlightedIndex === options.index,- ...getItemProps({- // We need to either deep compare objects here or use itemToString to get primitive types- selected:- selectedItem !== undefined &&- itemToString(selectedItem) === itemToString(options.item),- key: options.id,- ...options,- }),+ highlighted: downshiftHighlightedIndex === options.index,+ ...downshiftGetItemProps(itemOptions),+ ...getItemProps?.(itemOptions),};},- [getItemProps, highlightedIndex, itemToString, selectedItem]+ [+ downshiftHighlightedIndex,+ downshiftGetItemProps,+ itemToString,+ selectedItem,+ getItemProps,+ ]);+ const downshiftGetMenuProps = downshiftProps.getMenuProps;const enhancedGetMenuProps = useCallback(- (options?: Parameters<typeof getMenuProps>[0]) => {+ (options?: Parameters<typeof downshiftGetMenuProps>[0]) => {return {- ...getMenuProps(options, { suppressRefError: true }),+ ...downshiftGetMenuProps(options, { suppressRefError: true }),state: isOpen ? "open" : "closed",empty: filteredItems.length === 0,};},- [getMenuProps, isOpen, filteredItems.length]+ [downshiftGetMenuProps, isOpen, filteredItems.length]);return {@@ -393,3 +421,56 @@ export const useCombobox = <Item,>({resetFilter,};};++export const Combobox = <Item,>({+ autoFocus,+ getDescription,+ ...props+}: UseComboboxProps<Item> & Omit<ComponentProps<"input">, "value">) => {+ const combobox = useCombobox<Item>({+ ...props,+ onItemHighlight: (item) => {+ props.onItemHighlight?.(item);+ setDescription(getDescription?.(item));+ },+ });++ const [description, setDescription] = useState<ReactNode>(+ getDescription?.(combobox.items[props.defaultHighlightedIndex ?? -1])+ );++ return (+ <ComboboxRoot open={combobox.isOpen}>+ <div {...combobox.getComboboxProps()}>+ <ComboboxAnchor>+ <InputField+ {...combobox.getInputProps()}+ autoFocus={autoFocus}+ suffix={<NestedInputButton {...combobox.getToggleButtonProps()} />}+ />+ </ComboboxAnchor>+ <ComboboxContent>+ <ComboboxListbox {...combobox.getMenuProps()}>+ <ComboboxScrollArea>+ {combobox.isOpen &&+ combobox.items.map((item, index) => {+ return (+ <ComboboxListboxItem+ key={index}+ selectable={false}+ {...combobox.getItemProps({ item, index })}+ >+ {props.itemToString(item)}+ </ComboboxListboxItem>+ );+ })}+ </ComboboxScrollArea>+ {description && (+ <ComboboxItemDescription>{description}</ComboboxItemDescription>+ )}+ </ComboboxListbox>+ </ComboboxContent>+ </div>+ </ComboboxRoot>+ );+};diff --git a/packages/design-system/src/components/icon-button.tsx b/packages/design-system/src/components/icon-button.tsxindex cbf166f083..d453a43f33 100644--- a/packages/design-system/src/components/icon-button.tsx+++ b/packages/design-system/src/components/icon-button.tsx@@ -27,6 +27,7 @@ export const IconButton = styled("button", {width: theme.spacing[12],height: theme.spacing[12],borderRadius: theme.borderRadius[3],+ minWidth: 0,"&[data-focused=true], &:focus-visible": {outline: `2px solid ${theme.colors.borderFocus}`,diff --git a/packages/design-system/src/components/menu.stories.tsx b/packages/design-system/src/components/menu.stories.tsxindex 65c0c789b0..5b80d91476 100644--- a/packages/design-system/src/components/menu.stories.tsx+++ b/packages/design-system/src/components/menu.stories.tsx@@ -18,7 +18,7 @@ import {} from "./dropdown-menu";import {useCombobox,- Combobox,+ ComboboxRoot,ComboboxContent,ComboboxAnchor,ComboboxListbox,@@ -177,7 +177,7 @@ const ComboboxDemo = () => {const longItems = items.filter((item) => item === "Banana");return (- <Combobox open={isOpen}>+ <ComboboxRoot open={isOpen}><div {...getComboboxProps()}><ComboboxAnchor><DeprecatedTextField@@ -210,7 +210,7 @@ const ComboboxDemo = () => {</ComboboxListbox></ComboboxContent></div>- </Combobox>+ </ComboboxRoot>);};diff --git a/packages/design-system/src/components/menu.tsx b/packages/design-system/src/components/menu.tsxindex eeb430bbca..09fe57c639 100644--- a/packages/design-system/src/components/menu.tsx+++ b/packages/design-system/src/components/menu.tsx@@ -45,7 +45,7 @@ export const menuItemIndicatorCss = css({export const MenuItemIndicator = styled("span", menuItemIndicatorCss);const itemMargin = theme.spacing[3];-export const menuItemCss = css(textVariants.labelsTitleCase, {+export const menuItemCss = css({outline: "none",cursor: "default",position: "relative",@@ -65,6 +65,10 @@ export const menuItemCss = css(textVariants.labelsTitleCase, {color: theme.colors.foregroundDisabled,},variants: {+ text: {+ title: textVariants.labelsTitleCase,+ sentence: textVariants.labelsSentenceCase,+ },withIndicator: {true: {paddingLeft: `calc(${theme.spacing[3]} + ${indicatorSize} + ${theme.spacing[3]})`,@@ -94,6 +98,7 @@ export const menuItemCss = css(textVariants.labelsTitleCase, {},},},+ defaultVariants: { text: "title" },});// To use outside of any menu context, e.g. in a Popoverdiff --git a/packages/design-system/src/components/nested-input-button.tsx b/packages/design-system/src/components/nested-input-button.tsxindex 7285ba3e70..02663795a0 100644--- a/packages/design-system/src/components/nested-input-button.tsx+++ b/packages/design-system/src/components/nested-input-button.tsx@@ -71,4 +71,4 @@ export const NestedInputButton = forwardRef(</button>));-NestedInputButton.displayName = "NestedSelectButton";+NestedInputButton.displayName = "NestedInputButton";diff --git a/packages/design-system/src/components/scroll-area.tsx b/packages/design-system/src/components/scroll-area.tsxindex 77a3cbfeb5..93b788531f 100644--- a/packages/design-system/src/components/scroll-area.tsx+++ b/packages/design-system/src/components/scroll-area.tsx@@ -97,15 +97,22 @@ const viewPortStyle = css({type ScrollAreaProps = {css?: CSS;direction?: "vertical" | "horizontal" | "both";+ className?: string;} & Pick<ComponentProps<"div">, "onScroll" | "children">;export const ScrollArea = forwardRef((- { children, css, onScroll, direction = "vertical" }: ScrollAreaProps,+ {+ children,+ css,+ className,+ onScroll,+ direction = "vertical",+ }: ScrollAreaProps,ref: Ref<HTMLDivElement>) => {return (- <ScrollAreaRoot scrollHideDelay={0} css={css}>+ <ScrollAreaRoot scrollHideDelay={0} css={css} className={className}><Viewportref={ref}className={viewPortStyle({ direction })}diff --git a/packages/design-system/src/components/select-button.tsx b/packages/design-system/src/components/select-button.tsxindex b65072f38c..bb3588a267 100644--- a/packages/design-system/src/components/select-button.tsx+++ b/packages/design-system/src/components/select-button.tsx@@ -21,6 +21,7 @@ const chevronStyle = css({ color: `var(${chevronColor})` });const style = css({all: "unset", // reset <button>+ minWidth: 0,height: theme.spacing[12],boxSizing: "border-box",display: "flex",diff --git a/packages/design-system/src/components/select.tsx b/packages/design-system/src/components/select.tsxindex 92605459d7..b2d4e95557 100644--- a/packages/design-system/src/components/select.tsx+++ b/packages/design-system/src/components/select.tsx@@ -38,11 +38,7 @@ export const SelectSeparator = styled(Primitive.Separator, separatorCss);export const SelectGroup = Primitive.Group;-const StyledItem = styled(Primitive.Item, menuItemCss, {- // we don't want to transform text using CSS in case of the Select,- // we want getLabel to handle it- textTransform: "none",-});+const StyledItem = styled(Primitive.Item, menuItemCss);const StyledIndicator = styled(Primitive.ItemIndicator, menuItemIndicatorCss);diff --git a/packages/design-system/src/components/tooltip.tsx b/packages/design-system/src/components/tooltip.tsxindex 8a8b83325d..e52f3e1f0e 100644--- a/packages/design-system/src/components/tooltip.tsx+++ b/packages/design-system/src/components/tooltip.tsx@@ -1,4 +1,4 @@-import type { Ref, ComponentProps, ReactNode, ReactElement } from "react";+import type { Ref, ComponentProps, ReactNode } from "react";import { forwardRef, useEffect, useRef, useState } from "react";import {autoUpdate,@@ -19,7 +19,7 @@ export const TooltipProvider = TooltipPrimitive.TooltipProvider;export type TooltipProps = ComponentProps<typeof TooltipPrimitive.Root> &Omit<ComponentProps<typeof Content>, "content"> & {- children: ReactElement;+ children: ReactNode;content: ReactNode;delayDuration?: number;disableHoverableContent?: boolean;diff --git a/packages/feature-flags/src/flags.ts b/packages/feature-flags/src/flags.tsindex d6ff41f9b2..9643b94802 100644--- a/packages/feature-flags/src/flags.ts+++ b/packages/feature-flags/src/flags.ts@@ -5,4 +5,5 @@ export const aiRadixComponents = false;export const cms = false;export const marketplace = false;export const pageTemplates = false;+export const cssVars = false;export const filters = false;diff --git a/packages/sdk/src/schema/styles.ts b/packages/sdk/src/schema/styles.tsindex 07194cfcea..722af5820c 100644--- a/packages/sdk/src/schema/styles.ts+++ b/packages/sdk/src/schema/styles.ts@@ -9,6 +9,7 @@ const StyleDeclRaw = z.object({// @todo can't figure out how to make property to be enumproperty: z.string(),value: StyleValue,+ listed: z.boolean().optional(),});export type StyleDecl = Simplify<