Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Dots that represent items inside closed sections; Fix pages scroll (#1309)

Roman Pominov1cf864c4288a
diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/pages.tsx b/apps/builder/app/builder/features/sidebar-left/panels/pages/pages.tsx
index 7bb6559a3a..e43ee7436b 100644
--- a/apps/builder/app/builder/features/sidebar-left/panels/pages/pages.tsx
+++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/pages.tsx
@@ -179,7 +179,7 @@ const PagesPanel = ({
}
return (
- <Box
+ <Flex
css={{
position: "relative",
height: "100%",
@@ -188,6 +188,7 @@ const PagesPanel = ({
flexGrow: 1,
background: theme.colors.loContrast,
}}
+ direction="column"
>
<Header
title="Pages"
@@ -207,21 +208,23 @@ const PagesPanel = ({
</>
}
/>
- <TreeNode<PagesTreeNode>
- selectedItemSelector={[selectedPageId, pagesTree.id]}
- onSelect={selectTreeNode}
- itemData={pagesTree}
- renderItem={renderItem}
- getItemChildren={(nodeId) => {
- if (nodeId === pagesTree.id && pagesTree.type === "folder") {
- return pagesTree.children;
- }
- return [];
- }}
- isItemHidden={(itemId) => itemId === pagesTree.id}
- getIsExpanded={() => true}
- />
- </Box>
+ <Box css={{ overflowY: "auto", flexBasis: 0, flexGrow: 1 }}>
+ <TreeNode<PagesTreeNode>
+ selectedItemSelector={[selectedPageId, pagesTree.id]}
+ onSelect={selectTreeNode}
+ itemData={pagesTree}
+ renderItem={renderItem}
+ getItemChildren={(nodeId) => {
+ if (nodeId === pagesTree.id && pagesTree.type === "folder") {
+ return pagesTree.children;
+ }
+ return [];
+ }}
+ isItemHidden={(itemId) => itemId === pagesTree.id}
+ getIsExpanded={() => true}
+ />
+ </Box>
+ </Flex>
);
};
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.tsx
index be257bace8..c6b7000e7b 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
@@ -20,7 +20,7 @@ export const ColorControl = ({
const [intermediateValue, setIntermediateValue] =
useState<CssColorPickerValueInput>();
- const { items: defaultItems } = styleConfigByName[property];
+ const { items: defaultItems } = styleConfigByName(property);
const styleInfo = currentStyle[property];
let value = currentStyle[property]?.value ?? {
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.tsx
index 485dd91b8a..5ae1a28676 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
@@ -10,7 +10,7 @@ export const MenuControl = ({
currentStyle,
setProperty,
}: ControlProps) => {
- const { label, items: defaultItems } = styleConfigByName[property];
+ const { label, items: defaultItems } = styleConfigByName(property);
const value = currentStyle[property]?.value;
const styleSource = getStyleSource(currentStyle[property]);
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.tsx
index 36e7c6bf3c..ca491764f5 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
@@ -44,7 +44,7 @@ export const PositionControl = ({
setProperty,
deleteProperty,
}: ControlProps) => {
- const { label, items } = styleConfigByName[property];
+ const { label, items } = styleConfigByName(property);
const styleInfo = currentStyle[property];
const value = toTuple(styleInfo?.value);
const styleSource = getStyleSource(styleInfo);
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.tsx
index 80b69357f0..712a43c7f8 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
@@ -11,7 +11,7 @@ export const SelectControl = ({
setProperty,
items,
}: ControlProps) => {
- const { items: defaultItems } = styleConfigByName[property];
+ const { items: defaultItems } = styleConfigByName(property);
const value = currentStyle[property]?.value;
const setValue = setProperty(property);
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.tsx
index 21c6070987..13b1446301 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
@@ -18,7 +18,7 @@ export const TextControl = ({
icon,
disabled,
}: ControlProps & { icon?: JSX.Element }) => {
- const { label, items: defaultItems } = styleConfigByName[property];
+ const { label, items: defaultItems } = styleConfigByName(property);
const styleInfo = currentStyle[property];
const value = styleInfo?.value;
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.tsx
index f0474f52b4..95714878d7 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
@@ -36,7 +36,7 @@ export const BackgroundSize = (
const styleInfo = props.currentStyle[property];
const styleValue = styleInfo?.value;
const styleSource = "default";
- const { items: defaultItems } = styleConfigByName[property];
+ const { items: defaultItems } = styleConfigByName(property);
const selectOptions = [
...defaultItems,
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.tsx
index 0df7cbe7ae..a945afcc2c 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
@@ -112,10 +112,7 @@ export const BackgroundsCollapsible = () => {
setProperty={setProperty}
deleteProperty={deleteProperty}
createBatchUpdate={createBatchUpdate}
- category={"backgrounds"}
- styleConfigsByCategory={[]}
- moreStyleConfigsByCategory={[]}
- label="Backgrounds"
+ category="backgrounds"
/>
</Panel>
);
@@ -137,10 +134,7 @@ export const Backgrounds = () => {
setProperty={setProperty}
deleteProperty={deleteProperty}
createBatchUpdate={createBatchUpdate}
- category={"backgrounds"}
- styleConfigsByCategory={[]}
- moreStyleConfigsByCategory={[]}
- label="Backgrounds"
+ category="backgrounds"
/>
</Panel>
);
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.tsx
index 37958e0038..58b48ba9ec 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
@@ -40,11 +40,12 @@ import { BackgroundContent } from "./background-content";
import { getLayerName, LayerThumbnail } from "./background-thumbnail";
import { useSortable } from "./use-sortable";
import { useMemo } from "react";
-import type { RgbValue } from "@webstudio-is/css-data";
+import type { RgbValue, StyleProperty } from "@webstudio-is/css-data";
import {
CollapsibleSectionBase,
useOpenState,
} from "~/builder/shared/collapsible-section";
+import { getDots } from "../../shared/collapsible-section";
const Layer = (props: {
id: string;
@@ -124,18 +125,26 @@ const Layer = (props: {
);
};
-const BackgroundsCollapsibleSection = (
- props: RenderCategoryProps & { children: React.ReactNode }
-) => {
- const { label, children } = props;
- const [isOpen, setIsOpen] = useOpenState(props);
+const properties: StyleProperty[] = [
+ "backgroundAttachment",
+ "backgroundClip",
+ "backgroundColor",
+ "backgroundImage",
+ "backgroundOrigin",
+ "backgroundPosition",
+ "backgroundRepeat",
+ "backgroundSize",
+ "backgroundBlendMode",
+];
- const layersStyleSource = getLayersStyleSource(props.currentStyle);
- const dots: ("local" | "remote")[] = [];
-
- if (layersStyleSource === "local" || layersStyleSource === "remote") {
- dots.push(layersStyleSource);
- }
+const BackgroundsCollapsibleSection = ({
+ children,
+ currentStyle,
+ createBatchUpdate,
+}: RenderCategoryProps & { children: React.ReactNode }) => {
+ const label = "Backgrounds";
+ const [isOpen, setIsOpen] = useOpenState({ label });
+ const layersStyleSource = getLayersStyleSource(currentStyle);
return (
<CollapsibleSectionBase
@@ -147,12 +156,11 @@ const BackgroundsCollapsibleSection = (
}}
trigger={
<SectionTitle
- dots={dots}
+ dots={getDots(currentStyle, properties)}
suffix={
<SectionTitleButton
prefix={<PlusIcon />}
onClick={() => {
- const { currentStyle, createBatchUpdate } = props;
addLayer(currentStyle, createBatchUpdate);
setIsOpen(true);
}}
@@ -160,15 +168,14 @@ const BackgroundsCollapsibleSection = (
}
>
<PropertyName
- style={props.currentStyle}
+ style={currentStyle}
property={layeredBackgroundProps}
label={
<SectionTitleLabel color={layersStyleSource}>
- {props.label}
+ {label}
</SectionTitleLabel>
}
onReset={() => {
- const { createBatchUpdate } = props;
deleteLayers(createBatchUpdate);
}}
/>
@@ -185,7 +192,7 @@ export const BackgroundsSection = (props: RenderCategoryProps) => {
props;
const layersCount = getLayerCount(currentStyle);
- const { items } = styleConfigByName["backgroundColor"];
+ const { items } = styleConfigByName("backgroundColor");
const layers = useMemo(
() =>
@@ -210,10 +217,6 @@ export const BackgroundsSection = (props: RenderCategoryProps) => {
createBatchUpdate={createBatchUpdate}
currentStyle={currentStyle}
category={props.category}
- styleConfigsByCategory={props.styleConfigsByCategory}
- moreStyleConfigsByCategory={props.moreStyleConfigsByCategory}
- label={props.label}
- isOpen={props.isOpen}
>
<Flex gap={1} direction="column">
<Flex
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.tsx
index 54eff80533..8262a8888b 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
@@ -65,7 +65,7 @@ export const BorderProperty = ({
**/
const firstPropertyName = borderProperties[0];
- const { items: borderPropertyItems } = styleConfigByName[firstPropertyName];
+ const { items: borderPropertyItems } = styleConfigByName(firstPropertyName);
const borderWidthKeywords = borderPropertyItems.map((item) => ({
type: "keyword" as const,
@@ -156,7 +156,7 @@ export const BorderProperty = ({
</NestedIconLabel>
}
key={property}
- label={styleConfigByName[property].label ?? ""}
+ label={styleConfigByName(property).label ?? ""}
property={property}
styleSource={getStyleSource(currentStyle[property])}
keywords={borderWidthKeywords}
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.tsx
index 9064991066..6cf75c2d54 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
@@ -85,10 +85,7 @@ export const Borders = () => {
setProperty={setProperty}
deleteProperty={deleteProperty}
createBatchUpdate={createBatchUpdate}
- category={"borders"}
- label={"Borders"}
- styleConfigsByCategory={[]}
- moreStyleConfigsByCategory={[]}
+ category="borders"
/>
</Panel>
);
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.tsx
index 1a2ccc8528..5604bb3b6a 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,15 +1,16 @@
import { Box, Flex, Grid, theme } from "@webstudio-is/design-system";
-import { CollapsibleSection } from "~/builder/shared/collapsible-section";
+import type { StyleProperty } from "@webstudio-is/css-data";
import { ColorControl } from "../../controls";
import { styleConfigByName } from "../../shared/configs";
import { PropertyName } from "../../shared/property-name";
import type { RenderCategoryProps } from "../../style-sections";
+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 { items: borderColorItems } = styleConfigByName("borderTopColor");
const borderColorProperties = [
"borderTopColor",
@@ -18,6 +19,25 @@ const borderColorProperties = [
"borderLeftColor",
] as const;
+const properties: StyleProperty[] = [
+ ...borderColorProperties,
+
+ "borderTopLeftRadius",
+ "borderTopRightRadius",
+ "borderBottomLeftRadius",
+ "borderBottomRightRadius",
+
+ "borderTopStyle",
+ "borderRightStyle",
+ "borderBottomStyle",
+ "borderLeftStyle",
+
+ "borderTopWidth",
+ "borderRightWidth",
+ "borderBottomWidth",
+ "borderLeftWidth",
+];
+
export const BordersSection = (props: RenderCategoryProps) => {
const { currentStyle, setProperty, deleteProperty, createBatchUpdate } =
props;
@@ -40,7 +60,11 @@ export const BordersSection = (props: RenderCategoryProps) => {
);
return (
- <CollapsibleSection label={props.label} isOpen={props.isOpen}>
+ <CollapsibleSection
+ label="Borders"
+ currentStyle={currentStyle}
+ properties={properties}
+ >
<Flex direction="column" gap={2}>
<BorderStyle
createBatchUpdate={createBatchUpdate}
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.tsx
index 9c8fc97836..7b36fbae70 100644
--- a/apps/builder/app/builder/features/style-panel/sections/effects/effects.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/effects/effects.tsx
@@ -1,22 +1,51 @@
+import type { StyleProperty } from "@webstudio-is/css-data";
import type { RenderCategoryProps } from "../../style-sections";
import { ShowMore } from "../../shared/show-more";
import { renderProperty } from "../../style-sections";
-import { CollapsibleSection } from "~/builder/shared/collapsible-section";
+import { CollapsibleSection } from "../../shared/collapsible-section";
-export const EffectsSection = ({
- styleConfigsByCategory,
- moreStyleConfigsByCategory,
- label,
- isOpen,
-}: RenderCategoryProps) => {
- return (
- <CollapsibleSection label={label} isOpen={isOpen}>
- {styleConfigsByCategory.map((entry) => renderProperty(entry))}
- <ShowMore
- styleConfigs={moreStyleConfigsByCategory.map((entry) =>
- renderProperty(entry)
- )}
- />
- </CollapsibleSection>
- );
-};
+const properties: StyleProperty[] = [
+ "mixBlendMode",
+ "opacity",
+ "outlineColor",
+ "outlineOffset",
+ "outlineStyle",
+ "outlineWidth",
+ "boxShadow",
+ "transform",
+ "filter",
+ "backdropFilter",
+ "cursor",
+];
+
+const moreProperties: StyleProperty[] = [
+ "animationDelay",
+ "animationDirection",
+ "animationDuration",
+ "animationFillMode",
+ "animationIterationCount",
+ "animationName",
+ "animationPlayState",
+ "animationTimingFunction",
+ "transitionDelay",
+ "transitionDuration",
+ "transitionProperty",
+ "transitionTimingFunction",
+];
+
+const allProperties = [...properties, ...moreProperties];
+
+export const EffectsSection = (props: RenderCategoryProps) => (
+ <CollapsibleSection
+ label="Effects"
+ currentStyle={props.currentStyle}
+ properties={allProperties}
+ >
+ {properties.map((property) => renderProperty({ ...props, property }))}
+ <ShowMore
+ styleConfigs={moreProperties.map((property) =>
+ renderProperty({ ...props, property })
+ )}
+ />
+ </CollapsibleSection>
+);
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.tsx
index 39bdf4536f..6344ce95bd 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,5 +1,6 @@
-import { Flex, Grid } from "@webstudio-is/design-system";
+import { Flex, Grid, theme } from "@webstudio-is/design-system";
import { toValue } from "@webstudio-is/css-engine";
+import type { StyleProperty } from "@webstudio-is/css-data";
import type { RenderCategoryProps } from "../../style-sections";
import { ToggleGroupControl } from "../../controls/toggle/toggle-control";
import { PropertyName } from "../../shared/property-name";
@@ -19,12 +20,23 @@ import {
} from "@webstudio-is/icons";
import { FloatingPanel } from "~/builder/shared/floating-panel";
import { getStyleSource } from "../../shared/style-info";
-import { theme } from "@webstudio-is/design-system";
-import { CollapsibleSection } from "~/builder/shared/collapsible-section";
+import { CollapsibleSection } from "../../shared/collapsible-section";
+
+const properties: StyleProperty[] = [
+ "flexShrink",
+ "flexGrow",
+ "flexBasis",
+ "alignSelf",
+ "order",
+];
export const FlexChildSection = (props: RenderCategoryProps) => {
return (
- <CollapsibleSection label={props.label} isOpen={props.isOpen}>
+ <CollapsibleSection
+ label="Flex Child"
+ currentStyle={props.currentStyle}
+ properties={properties}
+ >
<Flex css={{ flexDirection: "column", gap: theme.spacing[5] }}>
<FlexChildSectionAlign {...props} />
<FlexChildSectionSizing {...props} />
diff --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.tsx
index 8585917311..a02bec9b54 100644
--- 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.tsx
@@ -1,22 +1,24 @@
+import type { StyleProperty } from "@webstudio-is/css-data";
import type { RenderCategoryProps } from "../../style-sections";
-import { ShowMore } from "../../shared/show-more";
import { renderProperty } from "../../style-sections";
-import { CollapsibleSection } from "~/builder/shared/collapsible-section";
+import { CollapsibleSection } from "../../shared/collapsible-section";
-export const GridChildSection = ({
- styleConfigsByCategory,
- moreStyleConfigsByCategory,
- label,
- isOpen,
-}: RenderCategoryProps) => {
- return (
- <CollapsibleSection label={label} isOpen={isOpen}>
- {styleConfigsByCategory.map((entry) => renderProperty(entry))}
- <ShowMore
- styleConfigs={moreStyleConfigsByCategory.map((entry) =>
- renderProperty(entry)
- )}
- />
- </CollapsibleSection>
- );
-};
+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/layout/layout.tsx b/apps/builder/app/builder/features/style-panel/sections/layout/layout.tsx
index d947dc2cac..f3edb63f73 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
@@ -17,18 +17,17 @@ import {
} from "@webstudio-is/icons";
import type { RenderCategoryProps } from "../../style-sections";
import { FlexGrid } from "./shared/flex-grid";
-import { renderProperty } from "../../style-sections";
import { MenuControl, SelectControl } from "../../controls";
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";
+import { CollapsibleSection } from "../../shared/collapsible-section";
import {
type IntermediateStyleValue,
CssValueInput,
} from "../../shared/css-value-input";
import { theme } from "@webstudio-is/design-system";
-import { CollapsibleSection } from "~/builder/shared/collapsible-section";
import { isFeatureEnabled } from "@webstudio-is/feature-flags";
const GapLinked = ({
@@ -75,7 +74,7 @@ const GapInput = ({
onPreviewChange: (value?: StyleValue) => void;
onChange: (value: StyleValue) => void;
}) => {
- const { label, items } = styleConfigByName[property];
+ const { label, items } = styleConfigByName(property);
return (
<EnhancedTooltip content={label}>
<Box>
@@ -343,21 +342,33 @@ const compareDisplayValues = (a: { name: string }, b: { name: string }) => {
return aIndex - bIndex;
};
+const properties: StyleProperty[] = [
+ "display",
+ "flexDirection",
+ "flexWrap",
+ "alignItems",
+ "justifyContent",
+ "alignContent",
+ "rowGap",
+ "columnGap",
+];
+
export const LayoutSection = ({
currentStyle,
setProperty,
deleteProperty,
createBatchUpdate,
- styleConfigsByCategory,
- label: sectionLabel,
- isOpen,
}: RenderCategoryProps) => {
const displayValue = toValue(currentStyle.display?.value);
- const { label, items } = styleConfigByName.display;
+ const { label, items } = styleConfigByName("display");
return (
- <CollapsibleSection label={sectionLabel} isOpen={isOpen}>
+ <CollapsibleSection
+ label="Layout"
+ currentStyle={currentStyle}
+ properties={properties}
+ >
<>
<Grid css={{ gridTemplateColumns: "4fr 6fr" }}>
<PropertyName
@@ -378,18 +389,13 @@ export const LayoutSection = ({
/>
</Grid>
- {displayValue === "flex" || displayValue === "inline-flex" ? (
+ {(displayValue === "flex" || displayValue === "inline-flex") && (
<LayoutSectionFlex
currentStyle={currentStyle}
setProperty={setProperty}
deleteProperty={deleteProperty}
createBatchUpdate={createBatchUpdate}
/>
- ) : (
- styleConfigsByCategory.map((entry) =>
- // exclude display already rendered above
- entry.property === "display" ? null : renderProperty(entry)
- )
)}
</>
</CollapsibleSection>
diff --git a/apps/builder/app/builder/features/style-panel/sections/other/other.tsx b/apps/builder/app/builder/features/style-panel/sections/other/other.tsx
index 0f61e3bed7..6639781921 100644
--- a/apps/builder/app/builder/features/style-panel/sections/other/other.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/other/other.tsx
@@ -1,22 +1,33 @@
+import type { StyleProperty } from "@webstudio-is/css-data";
import type { RenderCategoryProps } from "../../style-sections";
-import { ShowMore } from "../../shared/show-more";
import { renderProperty } from "../../style-sections";
-import { CollapsibleSection } from "~/builder/shared/collapsible-section";
+import { CollapsibleSection } from "../../shared/collapsible-section";
-export const OtherSection = ({
- styleConfigsByCategory,
- moreStyleConfigsByCategory,
- label,
- isOpen,
-}: RenderCategoryProps) => {
- return (
- <CollapsibleSection label={label} isOpen={isOpen}>
- {styleConfigsByCategory.map((entry) => renderProperty(entry))}
- <ShowMore
- styleConfigs={moreStyleConfigsByCategory.map((entry) =>
- renderProperty(entry)
- )}
- />
- </CollapsibleSection>
- );
-};
+const properties: StyleProperty[] = [
+ "resize",
+ "clip",
+ "visibility",
+ "boxSizing",
+ "content",
+ "quotes",
+ "counterReset",
+ "counterIncrement",
+ "inlineSize",
+ "blockSize",
+ "minInlineSize",
+ "minBlockSize",
+ "maxInlineSize",
+ "maxBlockSize",
+ "userSelect",
+ "pointerEvents",
+];
+
+export const OtherSection = (props: RenderCategoryProps) => (
+ <CollapsibleSection
+ label="Other"
+ currentStyle={props.currentStyle}
+ properties={properties}
+ >
+ {properties.map((property) => renderProperty({ ...props, property }))}
+ </CollapsibleSection>
+);
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.tsx
index 2e01548d93..5aa56daeb1 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,22 +1,25 @@
+import type { StyleProperty } from "@webstudio-is/css-data";
import type { RenderCategoryProps } from "../../style-sections";
-import { ShowMore } from "../../shared/show-more";
import { renderProperty } from "../../style-sections";
-import { CollapsibleSection } from "~/builder/shared/collapsible-section";
+import { CollapsibleSection } from "../../shared/collapsible-section";
-export const PositionSection = ({
- styleConfigsByCategory,
- moreStyleConfigsByCategory,
- label,
- isOpen,
-}: RenderCategoryProps) => {
- return (
- <CollapsibleSection label={label} isOpen={isOpen}>
- {styleConfigsByCategory.map((entry) => renderProperty(entry))}
- <ShowMore
- styleConfigs={moreStyleConfigsByCategory.map((entry) =>
- renderProperty(entry)
- )}
- />
- </CollapsibleSection>
- );
-};
+const properties: StyleProperty[] = [
+ "position",
+ "top",
+ "right",
+ "bottom",
+ "left",
+ "zIndex",
+ "float",
+ "clear",
+];
+
+export const PositionSection = (props: RenderCategoryProps) => (
+ <CollapsibleSection
+ label="Position"
+ currentStyle={props.currentStyle}
+ properties={properties}
+ >
+ {properties.map((property) => renderProperty({ ...props, property }))}
+ </CollapsibleSection>
+);
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.tsx
index 2bde571e1d..994b3f4ce2 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
@@ -16,9 +16,9 @@ import {
AutoScrollIcon,
} from "@webstudio-is/icons";
import { getStyleSource } from "../../shared/style-info";
+import { CollapsibleSection } from "../../shared/collapsible-section";
import { theme } from "@webstudio-is/design-system";
import { ToggleGroupControl } from "../../controls/toggle/toggle-control";
-import { CollapsibleSection } from "~/builder/shared/collapsible-section";
const SizeField = ({
property,
@@ -31,7 +31,7 @@ const SizeField = ({
setProperty: RenderCategoryProps["setProperty"];
deleteProperty: RenderCategoryProps["deleteProperty"];
}) => {
- const { label } = styleConfigByName[property];
+ const { label } = styleConfigByName(property);
return (
<Grid gap={1}>
<PropertyName
@@ -50,15 +50,30 @@ const SizeField = ({
);
};
+const properties: StyleProperty[] = [
+ "width",
+ "height",
+ "minWidth",
+ "minHeight",
+ "maxWidth",
+ "maxHeight",
+ "overflow",
+ "objectFit",
+ "objectPosition",
+ "aspectRatio",
+];
+
export const SizeSection = ({
currentStyle: style,
setProperty,
deleteProperty,
- label,
- isOpen,
}: RenderCategoryProps) => {
return (
- <CollapsibleSection label={label} isOpen={isOpen}>
+ <CollapsibleSection
+ label="Size"
+ currentStyle={style}
+ properties={properties}
+ >
<Grid
columns={2}
css={{ columnGap: theme.spacing[5], rowGap: theme.spacing[7] }}
@@ -100,7 +115,7 @@ export const SizeSection = ({
deleteProperty={deleteProperty}
/>
<PropertyName
- label={styleConfigByName.aspectRatio.label}
+ label={styleConfigByName("aspectRatio").label}
property="aspectRatio"
style={style}
onReset={() => deleteProperty("aspectRatio")}
@@ -112,7 +127,7 @@ export const SizeSection = ({
deleteProperty={deleteProperty}
/>
<PropertyName
- label={styleConfigByName.overflow.label}
+ label={styleConfigByName("overflow").label}
property="overflow"
style={style}
onReset={() => deleteProperty("overflow")}
@@ -147,7 +162,7 @@ export const SizeSection = ({
}
/>
<PropertyName
- label={styleConfigByName.objectFit.label}
+ label={styleConfigByName("objectFit").label}
property="objectFit"
style={style}
onReset={() => deleteProperty("objectFit")}
@@ -161,7 +176,7 @@ export const SizeSection = ({
</Grid>
<Flex justify="between">
<PropertyName
- label={styleConfigByName.objectPosition.label}
+ label={styleConfigByName("objectPosition").label}
property="objectPosition"
style={style}
onReset={() => deleteProperty("objectPosition")}
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.tsx
index 0e9507ff5b..861362017e 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
@@ -8,8 +8,8 @@ import type { SpaceStyleProperty, HoverTagret } from "./types";
import { InputPopover } from "./input-popover";
import { SpaceTooltip } from "./tooltip";
import { getStyleSource } from "../../shared/style-info";
+import { CollapsibleSection } from "../../shared/collapsible-section";
import { useKeyboardNavigation } from "./keyboard";
-import { CollapsibleSection } from "~/builder/shared/collapsible-section";
const Cell = ({
isPopoverOpen,
@@ -91,8 +91,6 @@ export const SpaceSection = ({
deleteProperty,
createBatchUpdate,
currentStyle,
- label,
- isOpen,
}: RenderCategoryProps) => {
const [hoverTarget, setHoverTarget] = useState<HoverTagret>();
@@ -141,7 +139,11 @@ export const SpaceSection = ({
};
return (
- <CollapsibleSection label={label} isOpen={isOpen}>
+ <CollapsibleSection
+ label="Space"
+ currentStyle={currentStyle}
+ properties={spacePropertiesNames}
+ >
<SpaceLayout
ref={layoutRef}
onClick={() => setOpenProperty(hoverTarget?.property)}
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.ts
index ae7bac00af..15699d7fb8 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,6 +1,15 @@
-import { categories } from "@webstudio-is/react-sdk";
+import type { StyleProperty } from "@webstudio-is/css-data";
-export const spacePropertiesNames = categories.space.properties;
+export const spacePropertiesNames = [
+ "marginTop",
+ "marginRight",
+ "marginBottom",
+ "marginLeft",
+ "paddingTop",
+ "paddingRight",
+ "paddingBottom",
+ "paddingLeft",
+] as const satisfies ReadonlyArray<StyleProperty>;
export type SpaceStyleProperty = (typeof spacePropertiesNames)[number];
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.tsx
index a71f1ff9c2..dbeb80576a 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
@@ -1,11 +1,13 @@
-import type { RenderCategoryProps } from "../../style-sections";
import {
Flex,
Grid,
DeprecatedIconButton,
Tooltip,
+ theme,
} from "@webstudio-is/design-system";
import { toValue } from "@webstudio-is/css-engine";
+import type { StyleProperty } from "@webstudio-is/css-data";
+import type { RenderCategoryProps } from "../../style-sections";
import { PropertyName } from "../../shared/property-name";
import {
ColorControl,
@@ -35,12 +37,32 @@ import {
import { ToggleGroupControl } from "../../controls/toggle/toggle-control";
import { FloatingPanel } from "~/builder/shared/floating-panel";
import { getStyleSource } from "../../shared/style-info";
-import { theme } from "@webstudio-is/design-system";
-import { CollapsibleSection } from "~/builder/shared/collapsible-section";
+import { CollapsibleSection } from "../../shared/collapsible-section";
+
+const properties: StyleProperty[] = [
+ "fontFamily",
+ "fontWeight",
+ "fontSize",
+ "lineHeight",
+ "color",
+ "textAlign",
+ "fontStyle",
+ "textDecorationLine",
+ "letterSpacing",
+ "textTransform",
+ "direction",
+ "whiteSpace",
+ "textOverflow",
+ "hyphens",
+];
export const TypographySection = (props: RenderCategoryProps) => {
return (
- <CollapsibleSection label={props.label} isOpen={props.isOpen}>
+ <CollapsibleSection
+ label="Typography"
+ currentStyle={props.currentStyle}
+ properties={properties}
+ >
<Flex css={{ gap: theme.spacing[7] }} direction="column">
<TypographySectionFont {...props} />
<TypographySectionSizing {...props} />
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.tsx
new file mode 100644
index 0000000000..b8900058e2
--- /dev/null
+++ b/apps/builder/app/builder/features/style-panel/shared/collapsible-section.tsx
@@ -0,0 +1,49 @@
+import type { StyleProperty } from "@webstudio-is/css-data";
+import { SectionTitle, SectionTitleLabel } from "@webstudio-is/design-system";
+import type { ReactNode } from "react";
+import {
+ CollapsibleSectionBase,
+ useOpenState,
+} from "~/builder/shared/collapsible-section";
+import { getStyleSource, type StyleInfo } from "./style-info";
+
+export const getDots = (
+ currentStyle: StyleInfo,
+ properties: ReadonlyArray<StyleProperty>
+) => {
+ const dots = new Set<"local" | "remote">();
+
+ for (const property of properties) {
+ const source = getStyleSource(currentStyle[property]);
+ if (source === "local" || source === "remote") {
+ dots.add(source);
+ }
+ }
+
+ return Array.from(dots);
+};
+
+export const CollapsibleSection = (props: {
+ label: string;
+ children: ReactNode;
+ currentStyle: StyleInfo;
+ properties: ReadonlyArray<StyleProperty>;
+}) => {
+ const { label, children, currentStyle, properties } = props;
+ const [isOpen, setIsOpen] = useOpenState(props);
+
+ return (
+ <CollapsibleSectionBase
+ label={label}
+ isOpen={isOpen}
+ onOpenChange={setIsOpen}
+ trigger={
+ <SectionTitle dots={getDots(currentStyle, properties)}>
+ <SectionTitleLabel>{label}</SectionTitleLabel>
+ </SectionTitle>
+ }
+ >
+ {children}
+ </CollapsibleSectionBase>
+ );
+};
diff --git a/apps/builder/app/builder/features/style-panel/shared/configs.ts b/apps/builder/app/builder/features/style-panel/shared/configs.ts
index 7ee2871f2a..f39d394aaa 100644
--- a/apps/builder/app/builder/features/style-panel/shared/configs.ts
+++ b/apps/builder/app/builder/features/style-panel/shared/configs.ts
@@ -1,4 +1,3 @@
-import { categories, type Category } from "@webstudio-is/react-sdk";
import type { StyleProperty, AppliesTo } from "@webstudio-is/css-data";
import { keywordValues, properties } from "@webstudio-is/css-data";
import { humanizeString } from "~/shared/string-utils";
@@ -71,38 +70,34 @@ const getControl = (property: StyleProperty): Control => {
return "TextControl";
};
-const createStyleConfigs = () => {
- // We have same properties in different categories: alignSelf is in grid children and flex children
- // but this list has to contain only unique props
- const styleConfigByName = {} as { [prop in StyleProperty]: StyleConfig };
+const styleConfigCache = new Map<StyleProperty, StyleConfig>();
- let category: Category;
+export const styleConfigByName = (propertyName: StyleProperty): StyleConfig => {
+ const fromCache = styleConfigCache.get(propertyName);
- for (category in categories) {
- for (const prop of categories[category].properties) {
- // @todo prop is more narrow, only the props
- // in that category, we are widening the type to include all properties
- const property = prop as Property;
- const keywords = keywordValues[property] || [];
- const label = humanizeString(property);
-
- styleConfigByName[property] = {
- label,
- property,
- appliesTo: properties[property].appliesTo,
- control: getControl(property),
- items: keywords.map((keyword) => ({
- label: keyword,
- name: keyword,
- })),
- };
- }
+ if (fromCache) {
+ return fromCache;
}
- return { styleConfigs: Object.values(styleConfigByName), styleConfigByName };
-};
+ // @todo propertyName is more narrow, only the props
+ // in that category, we are widening the type to include all properties
+ const property = propertyName as Property;
+
+ const keywords = keywordValues[property] || [];
+ const label = humanizeString(property);
-export const { styleConfigs, styleConfigByName } = createStyleConfigs();
+ const result = {
+ label,
+ property,
+ appliesTo: properties[property].appliesTo,
+ control: getControl(property),
+ items: keywords.map((keyword) => ({ label: keyword, name: keyword })),
+ };
+
+ styleConfigCache.set(propertyName, result);
+
+ return result;
+};
export const iconConfigs: IconRecords = {
// layout
diff --git a/apps/builder/app/builder/features/style-panel/style-panel.tsx b/apps/builder/app/builder/features/style-panel/style-panel.tsx
index 758dbf4160..92b68734f0 100644
--- a/apps/builder/app/builder/features/style-panel/style-panel.tsx
+++ b/apps/builder/app/builder/features/style-panel/style-panel.tsx
@@ -69,7 +69,6 @@ export const StylePanel = ({ selectedInstance, publish }: StylePanelProps) => {
}}
>
<StyleSettings
- search=""
currentStyle={currentStyle}
setProperty={setProperty}
deleteProperty={deleteProperty}
diff --git a/apps/builder/app/builder/features/style-panel/style-sections.tsx b/apps/builder/app/builder/features/style-panel/style-sections.tsx
index a6f4e80be8..a8609ca848 100644
--- a/apps/builder/app/builder/features/style-panel/style-sections.tsx
+++ b/apps/builder/app/builder/features/style-panel/style-sections.tsx
@@ -1,7 +1,6 @@
import { Grid } from "@webstudio-is/design-system";
import { toValue } from "@webstudio-is/css-engine";
import { styleConfigByName } from "./shared/configs";
-import type { Category } from "@webstudio-is/react-sdk";
import type { Style, StyleProperty } from "@webstudio-is/css-data";
import type {
SetProperty,
@@ -25,6 +24,22 @@ import {
OtherSection,
} from "./sections";
+export const categories = [
+ "layout",
+ "flexChild",
+ "gridChild",
+ "space",
+ "size",
+ "position",
+ "typography",
+ "backgrounds",
+ "borders",
+ "effects",
+ "other",
+];
+
+export type Category = (typeof categories)[number];
+
export type ControlProps = {
property: StyleProperty;
items?: Array<{ label: string; name: string }>;
@@ -40,10 +55,6 @@ export type RenderCategoryProps = {
createBatchUpdate: CreateBatchUpdate;
currentStyle: StyleInfo;
category: Category;
- styleConfigsByCategory: Array<RenderPropertyProps>;
- moreStyleConfigsByCategory: Array<RenderPropertyProps>;
- label: string;
- isOpen?: boolean | undefined;
};
export type RenderPropertyProps = {
@@ -51,7 +62,6 @@ export type RenderPropertyProps = {
currentStyle: StyleInfo;
setProperty: SetProperty;
deleteProperty: DeleteProperty;
- category: Category;
};
export const renderProperty = ({
@@ -59,16 +69,15 @@ export const renderProperty = ({
currentStyle,
setProperty,
deleteProperty,
- category,
}: RenderPropertyProps) => {
- const { label, control, items } = styleConfigByName[property];
+ const { label, control, items } = styleConfigByName(property);
const Control = controls[control];
if (!Control) {
return null;
}
return (
- <Grid key={category + property} css={{ gridTemplateColumns: "4fr 6fr" }}>
+ <Grid key={property} css={{ gridTemplateColumns: "4fr 6fr" }}>
<PropertyName
style={currentStyle}
property={property}
@@ -92,10 +101,6 @@ export const renderCategory = ({
createBatchUpdate,
currentStyle,
category,
- styleConfigsByCategory,
- moreStyleConfigsByCategory,
- label,
- isOpen,
}: RenderCategoryProps) => {
const Section = sections[category];
@@ -106,10 +111,6 @@ export const renderCategory = ({
createBatchUpdate={createBatchUpdate}
currentStyle={currentStyle}
category={category}
- styleConfigsByCategory={styleConfigsByCategory}
- moreStyleConfigsByCategory={moreStyleConfigsByCategory}
- label={label}
- isOpen={isOpen}
/>
);
};
diff --git a/apps/builder/app/builder/features/style-panel/style-settings.tsx b/apps/builder/app/builder/features/style-panel/style-settings.tsx
index eb76fe3a25..a5f8db9958 100644
--- a/apps/builder/app/builder/features/style-panel/style-settings.tsx
+++ b/apps/builder/app/builder/features/style-panel/style-settings.tsx
@@ -1,101 +1,22 @@
-import hyphenate from "hyphenate-style-name";
-import { categories, type Category } from "@webstudio-is/react-sdk";
import type { StyleProperty } from "@webstudio-is/css-data";
-import { toValue } from "@webstudio-is/css-engine";
-import {
- type StyleConfig,
- styleConfigs,
- styleConfigByName,
-} from "./shared/configs";
import {
+ categories,
renderCategory,
shouldRenderCategory,
type RenderCategoryProps,
} from "./style-sections";
-import { dependencies } from "./shared/dependencies";
import type { SetProperty, CreateBatchUpdate } from "./shared/use-style-data";
import type { StyleInfo } from "./shared/style-info";
-import type { RenderPropertyProps } from "./style-sections";
import { useStore } from "@nanostores/react";
import { selectedInstanceSelectorStore } from "~/shared/nano-states";
import { useInstanceStyleData } from "./shared/style-info";
import React from "react";
-// Finds a property/value by using any available form: property, label, value
-const filterProperties = (
- properties: ReadonlyArray<StyleProperty>,
- search: string
-) => {
- const searchParts = search.split(" ").map((part) => part.trim());
- const includes = (property: string) => {
- if (property.toLowerCase().includes(search)) {
- return true;
- }
- if (hyphenate(property).includes(search)) {
- return true;
- }
- // Enables "ba co" to match "background color"
- return searchParts.every((searchPart) =>
- property.toLowerCase().includes(searchPart)
- );
- };
- return properties.filter((property) => {
- const { label, items } = styleConfigByName[property];
- if (includes(property)) {
- return true;
- }
- if (includes(label)) {
- return true;
- }
- for (const item of items) {
- if (includes(item.name) || includes(item.label)) {
- return true;
- }
- }
- return false;
- });
-};
-
-const appliesTo = (
- styleConfig: StyleConfig,
- currentStyle: StyleInfo
-): boolean => {
- const { appliesTo } = styleConfig;
-
- if (appliesTo in dependencies) {
- const dependency = dependencies[appliesTo];
- if (dependency === undefined) {
- return false;
- }
- const currentValue = toValue(currentStyle[dependency.property]?.value);
- if (currentValue === undefined) {
- return false;
- }
- if (Array.isArray(dependency.values)) {
- return dependency.values.includes(String(currentValue));
- }
- if (Array.isArray(dependency.notValues)) {
- return dependency.notValues.includes(String(currentValue)) === false;
- }
- }
-
- return true;
-};
-
-const didRender = (category: Category, property: StyleProperty): boolean => {
- // We only want to render the first thing in space since the widget will be the way to set all margin and padding
- if (category === "space" && property !== categories.space.properties[0]) {
- return true;
- }
- return false;
-};
-
export type StyleSettingsProps = {
currentStyle: StyleInfo;
setProperty: SetProperty;
deleteProperty: (property: StyleProperty) => void;
createBatchUpdate: CreateBatchUpdate;
- search: string;
};
const useParentStyle = () => {
@@ -114,69 +35,17 @@ export const StyleSettings = ({
deleteProperty,
createBatchUpdate,
currentStyle,
- search,
}: StyleSettingsProps) => {
- const isSearchMode = search.length !== 0;
const all = [];
- let category: Category;
-
const parentStyle = useParentStyle();
- for (category in categories) {
- // @todo seems like properties are the exact strings and styleConfig.property is not?
- const categoryProperties = filterProperties(
- categories[category].properties,
- search
- );
- const { moreFrom } = categories[category];
- const styleConfigsByCategory: Array<RenderPropertyProps> = [];
- const moreStyleConfigsByCategory: Array<RenderPropertyProps> = [];
-
- for (const styleConfig of styleConfigs) {
- const { property } = styleConfig;
- const isInCategory = categoryProperties.includes(property);
- // We don't want to filter out inapplicable styles if user wants to apply them anyway
- const isApplicable = isSearchMode
- ? true
- : appliesTo(styleConfig, currentStyle);
- const isRendered = didRender(category, property);
- const element = {
- property,
- setProperty,
- deleteProperty,
- currentStyle,
- category,
- };
-
- // @todo remove isRendered once space section is converted to a section
- if (isInCategory && isApplicable && isRendered === false) {
- // We are making a separate array of properties which come after the "moreFrom"
- // so we can make them collapsable
- if (
- (property === moreFrom || moreStyleConfigsByCategory.length !== 0) &&
- isSearchMode === false
- ) {
- moreStyleConfigsByCategory.push(element);
- continue;
- }
-
- styleConfigsByCategory.push(element);
- }
- }
-
- if (styleConfigsByCategory.length === 0) {
- continue;
- }
+ for (const category of categories) {
const categoryProps: RenderCategoryProps = {
setProperty,
deleteProperty,
createBatchUpdate,
currentStyle,
category,
- styleConfigsByCategory,
- moreStyleConfigsByCategory,
- label: categories[category].label,
- isOpen: isSearchMode ? true : undefined,
};
if (shouldRenderCategory(categoryProps, parentStyle)) {
@@ -187,5 +56,6 @@ export const StyleSettings = ({
);
}
}
+
return <>{all}</>;
};
diff --git a/packages/react-sdk/src/css/categories.ts b/packages/react-sdk/src/css/categories.ts
deleted file mode 100644
index 65446a517d..0000000000
--- a/packages/react-sdk/src/css/categories.ts
+++ /dev/null
@@ -1,254 +0,0 @@
-import type { StyleProperty } from "@webstudio-is/css-data";
-
-const layout = [
- "display",
- // Flex
- "flexDirection",
- "flexWrap",
- // Flex or grid
- "alignItems",
- "justifyContent",
- "alignContent",
- // Grid
- "justifyItems",
- "rowGap",
- "columnGap",
- "gridAutoFlow",
- "gridAutoRows",
- "gridAutoColumns",
- "gridTemplateColumns",
- "gridTemplateRows",
- "gridTemplateAreas",
-] as const;
-
-const flexChild = [
- "flexShrink",
- "flexGrow",
- "flexBasis",
- "alignSelf",
- "order",
-] as const;
-
-const gridChild = [
- "gridRowEnd",
- "gridRowStart",
- "gridColumnStart",
- "gridColumnEnd",
- "alignSelf",
- "justifySelf",
- "order",
-] as const;
-
-const space = [
- "marginTop",
- "marginRight",
- "marginBottom",
- "marginLeft",
- "paddingTop",
- "paddingRight",
- "paddingBottom",
- "paddingLeft",
-] as const;
-
-const size = [
- "width",
- "height",
- "minWidth",
- "minHeight",
- "maxWidth",
- "maxHeight",
- "overflow",
- "objectFit",
- "objectPosition",
- "aspectRatio",
-] as const;
-
-const position = [
- "position",
- "top",
- "right",
- "bottom",
- "left",
- "zIndex",
- "float",
- "clear",
-] as const;
-
-const typography = [
- "fontFamily",
- "fontWeight",
- "fontSize",
- "lineHeight",
- "color",
- "textAlign",
- "fontStyle",
- "textDecorationColor",
- "textDecorationLine",
- "textDecorationStyle",
-
- "letterSpacing",
- "textIndent",
-
- "columnCount",
- "columnGap",
- "columnRuleStyle",
- "columnRuleWidth",
- "columnRuleColor",
-
- "textTransform",
- "direction",
- "whiteSpace",
- "textShadow",
-
- // More
- "fontSizeAdjust",
- "fontStretch",
- "fontVariant",
- "textAlignLast",
- "textJustify",
- "textOverflow",
- "textSizeAdjust",
- "verticalAlign",
- "wordSpacing",
- "wordBreak",
- "wordWrap",
-] as const;
-
-const backgrounds = [
- "backgroundAttachment",
- "backgroundClip",
- "backgroundColor",
- "backgroundImage",
- "backgroundOrigin",
- "backgroundPosition",
- "backgroundRepeat",
- "backgroundSize",
- "backgroundBlendMode",
-] as const;
-
-const borders = [
- "borderTopLeftRadius",
- "borderTopRightRadius",
- "borderBottomLeftRadius",
- "borderBottomRightRadius",
-
- "borderTopStyle",
- "borderRightStyle",
- "borderBottomStyle",
- "borderLeftStyle",
-
- "borderTopColor",
- "borderRightColor",
- "borderBottomColor",
- "borderLeftColor",
-
- "borderTopWidth",
- "borderRightWidth",
- "borderBottomWidth",
- "borderLeftWidth",
-
- // More
- "borderImageSlice",
- "borderImageWidth",
- "borderImageOutset",
- "borderImageRepeat",
- "borderImageSource",
-] as const;
-
-const effects = [
- "mixBlendMode",
- "opacity",
- "outlineColor",
- "outlineOffset",
- "outlineStyle",
- "outlineWidth",
- "boxShadow",
- "transform",
- "filter",
- "backdropFilter",
- "cursor",
- // More
- "animationDelay",
- "animationDirection",
- "animationDuration",
- "animationFillMode",
- "animationIterationCount",
- "animationName",
- "animationPlayState",
- "animationTimingFunction",
- "transitionDelay",
- "transitionDuration",
- "transitionProperty",
- "transitionTimingFunction",
-] as const;
-
-const other = [
- "resize",
- "clip",
- "visibility",
- "boxSizing",
- "content",
- "quotes",
- "counterReset",
- "counterIncrement",
- "inlineSize",
- "blockSize",
- "minInlineSize",
- "minBlockSize",
- "maxInlineSize",
- "maxBlockSize",
- "userSelect",
- "pointerEvents",
-] as const;
-
-export const categories = {
- layout: {
- label: "Layout",
- properties: layout,
- moreFrom: "",
- },
- flexChild: {
- label: "Flex Child",
- properties: flexChild,
- moreFrom: "",
- },
- gridChild: {
- label: "Grid Child",
- properties: gridChild,
- moreFrom: "",
- },
- space: { label: "Space", properties: space, moreFrom: "" },
- size: { label: "Size", properties: size, moreFrom: "" },
- position: { label: "Position", properties: position, moreFrom: "" },
- typography: {
- label: "Typography",
- properties: typography,
- moreFrom: "fontSizeAdjust",
- },
- backgrounds: { label: "Backgrounds", properties: backgrounds, moreFrom: "" },
- borders: {
- label: "Borders",
- properties: borders,
- moreFrom: "borderImageSlice",
- },
- effects: {
- label: "Effects",
- properties: effects,
- moreFrom: "animationDelay",
- },
- other: { label: "Other", properties: other, moreFrom: "" },
-};
-
-export const propertyCategoryMap = {} as {
- [property in StyleProperty]: Category;
-};
-
-let category: Category;
-for (category in categories) {
- for (const property of categories[category].properties) {
- // We are widening the type here
- propertyCategoryMap[property as StyleProperty] = category;
- }
-}
-
-export type Category = keyof typeof categories;
diff --git a/packages/react-sdk/src/css/index.ts b/packages/react-sdk/src/css/index.ts
index 8c0502a3e1..70258bd336 100644
--- a/packages/react-sdk/src/css/index.ts
+++ b/packages/react-sdk/src/css/index.ts
@@ -1,2 +1 @@
export * from "./get-browser-style";
-export * from "./categories";