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.

review changes/refactor

Sultan2c7bfd937115
diff --git a/apps/designer/app/designer/features/style-panel/controls/color-control.tsx b/apps/designer/app/designer/features/style-panel/controls/color-control.tsx
index fa5a8b9ba6..2f827c43a2 100644
--- a/apps/designer/app/designer/features/style-panel/controls/color-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/color-control.tsx
@@ -9,7 +9,7 @@ import {
PopoverContent,
TextField,
} from "@webstudio-is/design-system";
-import { PropertyName } from "./property-name";
+import { PropertyNameUtility } from "./property-name-utility";
import { getFinalValue } from "../shared/get-final-value";
import type { ControlProps } from "../style-sections";
@@ -83,7 +83,7 @@ const ColorPicker = ({
);
};
-const ColorControl = ({
+export const ColorControl = ({
currentStyle,
inheritedStyle,
setProperty,
@@ -99,7 +99,10 @@ const ColorControl = ({
return (
<Grid columns={2} align="center" gapX="1">
- <PropertyName property={styleConfig.property} label={styleConfig.label} />
+ <PropertyNameUtility
+ property={styleConfig.property}
+ label={styleConfig.label}
+ />
<Flex align="center" css={{ gridColumn: "2/4" }} gap="1">
<ColorPicker
id={styleConfig.property}
@@ -113,5 +116,3 @@ const ColorControl = ({
</Grid>
);
};
-
-export { ColorControl };
diff --git a/apps/designer/app/designer/features/style-panel/controls/combobox-control.tsx b/apps/designer/app/designer/features/style-panel/controls/combobox-control.tsx
index 6143000fee..dd05dac2b1 100644
--- a/apps/designer/app/designer/features/style-panel/controls/combobox-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/combobox-control.tsx
@@ -9,7 +9,7 @@ import {
TextField,
Tooltip,
} from "@webstudio-is/design-system";
-import { PropertyName } from "./property-name";
+import { PropertyNameUtility } from "./property-name-utility";
import { getFinalValue } from "../shared/get-final-value";
import { useIsFromCurrentBreakpoint } from "../shared/use-is-from-current-breakpoint";
import { ControlProps } from "../style-sections";
@@ -29,7 +29,7 @@ const Unit = ({ value }: { value: StyleValue }) => {
);
};
-const ComboboxControl = ({
+export const ComboboxControl = ({
currentStyle,
inheritedStyle,
setProperty,
@@ -118,7 +118,10 @@ const ComboboxControl = ({
return (
<Grid columns={2} align="center" gapX="1">
{/* @todo needs icon variant */}
- <PropertyName property={styleConfig.property} label={styleConfig.label} />
+ <PropertyNameUtility
+ property={styleConfig.property}
+ label={styleConfig.label}
+ />
<Flex align="center" css={{ gridColumn: "2/4" }} gap="1">
<Combobox
name={styleConfig.property}
@@ -141,5 +144,3 @@ const ComboboxControl = ({
</Grid>
);
};
-
-export { ComboboxControl };
diff --git a/apps/designer/app/designer/features/style-panel/controls/grid-control.tsx b/apps/designer/app/designer/features/style-panel/controls/grid-utility.tsx
similarity index 98%
rename from apps/designer/app/designer/features/style-panel/controls/grid-control.tsx
rename to apps/designer/app/designer/features/style-panel/controls/grid-utility.tsx
index 33b6fb107a..02b0313a4e 100644
--- a/apps/designer/app/designer/features/style-panel/controls/grid-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/grid-utility.tsx
@@ -4,7 +4,7 @@ import { useIsFromCurrentBreakpoint } from "../shared/use-is-from-current-breakp
import type { Style } from "@webstudio-is/react-sdk";
import type { CreateBatchUpdate } from "../shared/use-style-data";
-const GridControl = ({
+export const GridUtility = ({
name,
currentStyle,
batchUpdate,
@@ -150,5 +150,3 @@ const GridControl = ({
</Grid>
);
};
-
-export { GridControl };
diff --git a/apps/designer/app/designer/features/style-panel/controls/icon-button-with-menu-control.tsx b/apps/designer/app/designer/features/style-panel/controls/icon-button-with-menu-control.tsx
index fef8db0189..fb686449f7 100644
--- a/apps/designer/app/designer/features/style-panel/controls/icon-button-with-menu-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/icon-button-with-menu-control.tsx
@@ -4,84 +4,9 @@ import { ComboboxControl } from "./combobox-control";
import { getFinalValue } from "../shared/get-final-value";
import { useIsFromCurrentBreakpoint } from "../shared/use-is-from-current-breakpoint";
import type { ControlProps } from "../style-sections";
-import {
- AlignContentStart,
- AlignContentEnd,
- AlignContentCenter,
- AlignContentStretch,
- AlignContentSpaceAround,
- AlignContentSpaceBetween,
- AlignItemsStart,
- AlignItemsEnd,
- AlignItemsCenter,
- AlignItemsBaseline,
- AlignItemsStretch,
- FlexDirectionRow,
- FlexDirectionColumn,
- FlexDirectionRowReverse,
- FlexDirectionColumnReverse,
- FlexWrapNowrap,
- FlexWrapWrap,
- FlexWrapWrapReverse,
- JustifyContentStart,
- JustifyContentEnd,
- JustifyContentCenter,
- JustifyContentSpaceBetween,
- JustifyContentSpaceAround,
- JustifyItemsStart,
- JustifyItemsEnd,
- JustifyItemsCenter,
- IconRecords,
-} from "@webstudio-is/icons";
+import { iconConfigs } from "../shared/configs";
-const icons: IconRecords = {
- alignContent: {
- normal: AlignContentStart,
- start: AlignContentStart,
- end: AlignContentEnd,
- center: AlignContentCenter,
- stretch: AlignContentStretch,
- "space-around": AlignContentSpaceAround,
- "space-between": AlignContentSpaceBetween,
- },
- alignItems: {
- normal: AlignItemsStart,
- start: AlignItemsStart,
- end: AlignItemsEnd,
- center: AlignItemsCenter,
- baseline: AlignItemsBaseline,
- stretch: AlignItemsStretch,
- },
- flexDirection: {
- normal: FlexDirectionRow,
- row: FlexDirectionRow,
- column: FlexDirectionColumn,
- "row-reverse": FlexDirectionRowReverse,
- "column-reverse": FlexDirectionColumnReverse,
- },
- flexWrap: {
- normal: FlexWrapNowrap,
- nowrap: FlexWrapNowrap,
- wrap: FlexWrapWrap,
- "wrap-reverse": FlexWrapWrapReverse,
- },
- justifyContent: {
- normal: JustifyContentStart,
- start: JustifyContentStart,
- end: JustifyContentEnd,
- center: JustifyContentCenter,
- "space-between": JustifyContentSpaceBetween,
- "space-around": JustifyContentSpaceAround,
- },
- justifyItems: {
- normal: JustifyItemsStart,
- start: JustifyItemsStart,
- end: JustifyItemsEnd,
- center: JustifyItemsCenter,
- },
-};
-
-const IconButtonWithMenuControl = ({
+export const IconButtonWithMenuControl = ({
currentStyle,
inheritedStyle,
setProperty,
@@ -114,7 +39,7 @@ const IconButtonWithMenuControl = ({
);
}
- const iconProps = icons[styleConfig.property];
+ const iconProps = iconConfigs[styleConfig.property];
const iconStyle =
styleConfig.property === "flexDirection"
? {}
@@ -144,5 +69,3 @@ const IconButtonWithMenuControl = ({
></IconButtonWithMenu>
);
};
-
-export { IconButtonWithMenuControl };
diff --git a/apps/designer/app/designer/features/style-panel/controls/index.ts b/apps/designer/app/designer/features/style-panel/controls/index.ts
index eb1343d030..fa28e6f51e 100644
--- a/apps/designer/app/designer/features/style-panel/controls/index.ts
+++ b/apps/designer/app/designer/features/style-panel/controls/index.ts
@@ -1,9 +1,9 @@
export * from "./color-control";
export * from "./combobox-control";
-export * from "./grid-control";
+export * from "./grid-utility";
export * from "./icon-button-with-menu-control";
-export * from "./lock-control";
-export * from "./property-name";
+export * from "./lock-utility";
+export * from "./property-name-utility";
export * from "./select-control";
-export * from "./show-more";
+export * from "./show-more-utility";
export * from "./spacing-control";
diff --git a/apps/designer/app/designer/features/style-panel/controls/lock-control.tsx b/apps/designer/app/designer/features/style-panel/controls/lock-utility.tsx
similarity index 90%
rename from apps/designer/app/designer/features/style-panel/controls/lock-control.tsx
rename to apps/designer/app/designer/features/style-panel/controls/lock-utility.tsx
index 49b05ed0c0..161eeef205 100644
--- a/apps/designer/app/designer/features/style-panel/controls/lock-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/lock-utility.tsx
@@ -3,7 +3,7 @@ import { LockOpened } from "@webstudio-is/icons";
import type { Style } from "@webstudio-is/react-sdk";
import type { CreateBatchUpdate } from "../shared/use-style-data";
-const LockControl = ({
+export const LockUtility = ({
name,
}: {
name: string;
@@ -16,5 +16,3 @@ const LockControl = ({
</IconButton>
);
};
-
-export { LockControl };
diff --git a/apps/designer/app/designer/features/style-panel/controls/property-name.tsx b/apps/designer/app/designer/features/style-panel/controls/property-name-utility.tsx
similarity index 90%
rename from apps/designer/app/designer/features/style-panel/controls/property-name.tsx
rename to apps/designer/app/designer/features/style-panel/controls/property-name-utility.tsx
index 203e9e13b8..373ec6f65e 100644
--- a/apps/designer/app/designer/features/style-panel/controls/property-name.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/property-name-utility.tsx
@@ -3,7 +3,11 @@ import { useIsFromCurrentBreakpoint } from "../shared/use-is-from-current-breakp
import { propertyNameColorForSelectedBreakpoint } from "../shared/constants";
import type { PropertyProps } from "../style-sections";
-const PropertyName = ({ property, label, css }: PropertyProps) => {
+export const PropertyNameUtility = ({
+ property,
+ label,
+ css,
+}: PropertyProps) => {
const isCurrentBreakpoint = useIsFromCurrentBreakpoint(property);
return (
@@ -30,5 +34,3 @@ const PropertyName = ({ property, label, css }: PropertyProps) => {
</Label>
);
};
-
-export { PropertyName };
diff --git a/apps/designer/app/designer/features/style-panel/controls/select-control.tsx b/apps/designer/app/designer/features/style-panel/controls/select-control.tsx
index 9bf4752a2e..0423745f49 100644
--- a/apps/designer/app/designer/features/style-panel/controls/select-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/select-control.tsx
@@ -1,9 +1,9 @@
import { Flex, Select } from "@webstudio-is/design-system";
import { getFinalValue } from "../shared/get-final-value";
-import { PropertyName } from "./property-name";
+import { PropertyNameUtility } from "./property-name-utility";
import type { ControlProps } from "../style-sections";
-const SelectControl = ({
+export const SelectControl = ({
currentStyle,
inheritedStyle,
setProperty,
@@ -22,7 +22,7 @@ const SelectControl = ({
return (
<Flex align="center">
- <PropertyName
+ <PropertyNameUtility
property={styleConfig.property}
label={styleConfig.label}
css={{
@@ -46,5 +46,3 @@ const SelectControl = ({
</Flex>
);
};
-
-export { SelectControl };
diff --git a/apps/designer/app/designer/features/style-panel/controls/show-more.tsx b/apps/designer/app/designer/features/style-panel/controls/show-more-utility.tsx
similarity index 95%
rename from apps/designer/app/designer/features/style-panel/controls/show-more.tsx
rename to apps/designer/app/designer/features/style-panel/controls/show-more-utility.tsx
index b7291c1868..6bef96b829 100644
--- a/apps/designer/app/designer/features/style-panel/controls/show-more.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/show-more-utility.tsx
@@ -2,7 +2,7 @@ import { useState } from "react";
import { Flex, Button, Collapsible } from "@webstudio-is/design-system";
import { TriangleDownIcon, TriangleRightIcon } from "@webstudio-is/icons";
-const ShowMore = ({
+export const ShowMoreUtility = ({
styleConfigs,
}: {
styleConfigs: Array<JSX.Element | null>;
@@ -26,5 +26,3 @@ const ShowMore = ({
</Collapsible.Root>
);
};
-
-export { ShowMore };
diff --git a/apps/designer/app/designer/features/style-panel/controls/spacing-control.tsx b/apps/designer/app/designer/features/style-panel/controls/spacing-control.tsx
index 9598acd7be..fa885212f8 100644
--- a/apps/designer/app/designer/features/style-panel/controls/spacing-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/spacing-control.tsx
@@ -243,7 +243,7 @@ const SpacingWidget = ({ setProperty, values }: SpacingWidgetProps) => {
);
};
-const SpacingControl = ({
+export const SpacingControl = ({
currentStyle,
inheritedStyle,
setProperty,
@@ -273,5 +273,3 @@ const SpacingControl = ({
return <SpacingWidget setProperty={setProperty} values={styles} />;
};
-
-export { SpacingControl };
diff --git a/apps/designer/app/designer/features/style-panel/sections/layout.tsx b/apps/designer/app/designer/features/style-panel/sections/layout.tsx
index bc0b391a78..1cc582e296 100644
--- a/apps/designer/app/designer/features/style-panel/sections/layout.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/layout.tsx
@@ -1,6 +1,6 @@
import { Grid } from "@webstudio-is/design-system";
import type { RenderCategoryProps } from "../style-sections";
-import { GridControl, LockControl, ShowMore } from "../controls";
+import { GridUtility, LockUtility, ShowMoreUtility } from "../controls";
const CSSLayoutSection = {
alignItems: "center",
@@ -40,7 +40,7 @@ const LayoutSectionFlex = ({
return (
<Grid css={CSSLayoutSectionFlex}>
{styleConfigsByCategory}
- <LockControl
+ <LockUtility
name="lock"
currentStyle={{
columnGap: currentStyle.columnGap,
@@ -48,7 +48,7 @@ const LayoutSectionFlex = ({
}}
batchUpdate={batchUpdate}
/>
- <GridControl
+ <GridUtility
name="grid"
currentStyle={currentStyle}
batchUpdate={batchUpdate}
@@ -57,7 +57,7 @@ const LayoutSectionFlex = ({
);
};
-const LayoutSection = ({
+export const LayoutSection = ({
setProperty,
createBatchUpdate,
currentStyle,
@@ -82,7 +82,7 @@ const LayoutSection = ({
return (
<>
- <ShowMore styleConfigs={moreStyleConfigsByCategory} />
+ <ShowMoreUtility styleConfigs={moreStyleConfigsByCategory} />
{styleConfigsByCategory}
</>
);
@@ -97,5 +97,3 @@ const layouts = new Map([
["grid", null],
["inline-grid", null],
]);
-
-export { LayoutSection };
diff --git a/apps/designer/app/designer/features/style-panel/shared/configs.ts b/apps/designer/app/designer/features/style-panel/shared/configs.ts
index ad0fe1e975..19e4469d1f 100644
--- a/apps/designer/app/designer/features/style-panel/shared/configs.ts
+++ b/apps/designer/app/designer/features/style-panel/shared/configs.ts
@@ -7,6 +7,35 @@ import {
type AppliesTo,
} from "@webstudio-is/react-sdk";
import { humanizeString } from "~/shared/string-utils";
+import {
+ AlignContentStart,
+ AlignContentEnd,
+ AlignContentCenter,
+ AlignContentStretch,
+ AlignContentSpaceAround,
+ AlignContentSpaceBetween,
+ AlignItemsStart,
+ AlignItemsEnd,
+ AlignItemsCenter,
+ AlignItemsBaseline,
+ AlignItemsStretch,
+ FlexDirectionRow,
+ FlexDirectionColumn,
+ FlexDirectionRowReverse,
+ FlexDirectionColumnReverse,
+ FlexWrapNowrap,
+ FlexWrapWrap,
+ FlexWrapWrapReverse,
+ JustifyContentStart,
+ JustifyContentEnd,
+ JustifyContentCenter,
+ JustifyContentSpaceBetween,
+ JustifyContentSpaceAround,
+ JustifyItemsStart,
+ JustifyItemsEnd,
+ JustifyItemsCenter,
+ IconRecords,
+} from "@webstudio-is/icons";
type BaseStyleConfig = {
label: string;
@@ -94,3 +123,50 @@ const createStyleConfigs = () => {
};
export const styleConfigs: Array<StyleConfig> = createStyleConfigs();
+
+export const iconConfigs: IconRecords = {
+ alignContent: {
+ normal: AlignContentStart,
+ start: AlignContentStart,
+ end: AlignContentEnd,
+ center: AlignContentCenter,
+ stretch: AlignContentStretch,
+ "space-around": AlignContentSpaceAround,
+ "space-between": AlignContentSpaceBetween,
+ },
+ alignItems: {
+ normal: AlignItemsStart,
+ start: AlignItemsStart,
+ end: AlignItemsEnd,
+ center: AlignItemsCenter,
+ baseline: AlignItemsBaseline,
+ stretch: AlignItemsStretch,
+ },
+ flexDirection: {
+ normal: FlexDirectionRow,
+ row: FlexDirectionRow,
+ column: FlexDirectionColumn,
+ "row-reverse": FlexDirectionRowReverse,
+ "column-reverse": FlexDirectionColumnReverse,
+ },
+ flexWrap: {
+ normal: FlexWrapNowrap,
+ nowrap: FlexWrapNowrap,
+ wrap: FlexWrapWrap,
+ "wrap-reverse": FlexWrapWrapReverse,
+ },
+ justifyContent: {
+ normal: JustifyContentStart,
+ start: JustifyContentStart,
+ end: JustifyContentEnd,
+ center: JustifyContentCenter,
+ "space-between": JustifyContentSpaceBetween,
+ "space-around": JustifyContentSpaceAround,
+ },
+ justifyItems: {
+ normal: JustifyItemsStart,
+ start: JustifyItemsStart,
+ end: JustifyItemsEnd,
+ center: JustifyItemsCenter,
+ },
+};
diff --git a/apps/designer/app/designer/features/style-panel/shared/get-final-value.ts b/apps/designer/app/designer/features/style-panel/shared/get-final-value.ts
index 67b3c5db0c..1a542561d4 100644
--- a/apps/designer/app/designer/features/style-panel/shared/get-final-value.ts
+++ b/apps/designer/app/designer/features/style-panel/shared/get-final-value.ts
@@ -2,7 +2,7 @@ import type { Style, StyleValue, StyleProperty } from "@webstudio-is/react-sdk";
import type { InheritedStyle } from "./get-inherited-style";
// @todo expose which instance we inherited the value from
-const getFinalValue = ({
+export const getFinalValue = ({
currentStyle,
inheritedStyle,
property,
@@ -19,5 +19,3 @@ const getFinalValue = ({
}
return currentValue;
};
-
-export { getFinalValue };
diff --git a/apps/designer/app/designer/features/style-panel/style-panel.tsx b/apps/designer/app/designer/features/style-panel/style-panel.tsx
index 48871cc673..d8a4bfb79c 100644
--- a/apps/designer/app/designer/features/style-panel/style-panel.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-panel.tsx
@@ -17,7 +17,10 @@ type StylePanelProps = {
selectedInstanceData?: SelectedInstanceData;
};
-const StylePanel = ({ selectedInstanceData, publish }: StylePanelProps) => {
+export const StylePanel = ({
+ selectedInstanceData,
+ publish,
+}: StylePanelProps) => {
const { currentStyle, inheritedStyle, setProperty, createBatchUpdate } =
useStyleData({
selectedInstanceData,
@@ -72,5 +75,3 @@ const StylePanel = ({ selectedInstanceData, publish }: StylePanelProps) => {
</>
);
};
-
-export { StylePanel };
diff --git a/apps/designer/app/designer/features/style-panel/style-sections.tsx b/apps/designer/app/designer/features/style-panel/style-sections.tsx
index c72d375523..b1fc70b007 100644
--- a/apps/designer/app/designer/features/style-panel/style-sections.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-sections.tsx
@@ -14,17 +14,17 @@ import {
ComboboxControl,
SelectControl,
IconButtonWithMenuControl,
- ShowMore,
+ ShowMoreUtility,
} from "./controls";
import { LayoutSection } from "./sections";
-type PropertyProps = {
+export type PropertyProps = {
property: StyleProperty;
label: string;
css?: CSS;
};
-type ControlProps = {
+export type ControlProps = {
setProperty: SetProperty;
currentStyle: Style;
inheritedStyle: InheritedStyle;
@@ -32,7 +32,7 @@ type ControlProps = {
category: Category;
};
-type RenderCategoryProps = {
+export type RenderCategoryProps = {
setProperty: SetProperty;
createBatchUpdate: CreateBatchUpdate;
currentStyle: Style;
@@ -41,7 +41,7 @@ type RenderCategoryProps = {
moreStyleConfigsByCategory: Array<JSX.Element | null>;
};
-type RenderPropertyProps = {
+export type RenderPropertyProps = {
setProperty: SetProperty;
currentStyle: Style;
inheritedStyle: InheritedStyle;
@@ -49,7 +49,7 @@ type RenderPropertyProps = {
category: Category;
};
-const renderProperty = ({
+export const renderProperty = ({
currentStyle,
inheritedStyle,
setProperty,
@@ -77,7 +77,7 @@ const renderProperty = ({
);
};
-const renderCategory = ({
+export const renderCategory = ({
setProperty,
createBatchUpdate,
currentStyle,
@@ -90,7 +90,7 @@ const renderCategory = ({
return (
<>
{styleConfigsByCategory}
- <ShowMore styleConfigs={moreStyleConfigsByCategory} />
+ <ShowMoreUtility styleConfigs={moreStyleConfigsByCategory} />
</>
);
}
@@ -121,11 +121,3 @@ const controls: {
IconButtonWithMenu: IconButtonWithMenuControl,
Select: SelectControl,
};
-
-export { renderCategory, renderProperty };
-export type {
- PropertyProps,
- ControlProps,
- RenderCategoryProps,
- RenderPropertyProps,
-};
diff --git a/apps/designer/app/designer/features/style-panel/style-settings.tsx b/apps/designer/app/designer/features/style-panel/style-settings.tsx
index 9728fbcb52..5604e04aa2 100644
--- a/apps/designer/app/designer/features/style-panel/style-settings.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-settings.tsx
@@ -77,7 +77,7 @@ type StyleSettingsProps = {
search: string;
};
-const StyleSettings = ({
+export const StyleSettings = ({
setProperty,
createBatchUpdate,
currentStyle,
@@ -152,5 +152,3 @@ const StyleSettings = ({
}
return <>{all}</>;
};
-
-export { StyleSettings };