Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
refactor
Sultanc30e4ab647a5
diff --git a/apps/designer/app/designer/features/style-panel/controls/color-control.tsx b/apps/designer/app/designer/features/style-panel/controls/color/color-control.tsxsimilarity index 90%rename from apps/designer/app/designer/features/style-panel/controls/color-control.tsxrename to apps/designer/app/designer/features/style-panel/controls/color/color-control.tsxindex 2f827c43a2..a3d6eea93c 100644--- a/apps/designer/app/designer/features/style-panel/controls/color-control.tsx+++ b/apps/designer/app/designer/features/style-panel/controls/color/color-control.tsx@@ -9,9 +9,9 @@ import {PopoverContent,TextField,} from "@webstudio-is/design-system";-import { PropertyNameUtility } from "./property-name-utility";-import { getFinalValue } from "../shared/get-final-value";-import type { ControlProps } from "../style-sections";+import { PropertyName } from "../../shared/property-name";+import { getFinalValue } from "../../shared/get-final-value";+import type { ControlProps } from "../../style-sections";const stringifyRGBA = (color: RGBColor) => {const { r, g, b, a = 1 } = color;@@ -99,10 +99,7 @@ export const ColorControl = ({return (<Grid columns={2} align="center" gapX="1">- <PropertyNameUtility- property={styleConfig.property}- label={styleConfig.label}- />+ <PropertyName property={styleConfig.property} label={styleConfig.label} /><Flex align="center" css={{ gridColumn: "2/4" }} gap="1"><ColorPickerid={styleConfig.property}diff --git a/apps/designer/app/designer/features/style-panel/controls/index.ts b/apps/designer/app/designer/features/style-panel/controls/index.tsindex fa28e6f51e..6cc6e44055 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,5 @@-export * from "./color-control";-export * from "./combobox-control";-export * from "./grid-utility";-export * from "./icon-button-with-menu-control";-export * from "./lock-utility";-export * from "./property-name-utility";-export * from "./select-control";-export * from "./show-more-utility";-export * from "./spacing-control";+export * from "./text/text-control";+export * from "./color/color-control";+export * from "./select/select-control";+export * from "./menu/menu-control";+export * from "./spacing/spacing-control";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/menu/menu-control.tsxsimilarity index 79%rename from apps/designer/app/designer/features/style-panel/controls/icon-button-with-menu-control.tsxrename to apps/designer/app/designer/features/style-panel/controls/menu/menu-control.tsxindex fb686449f7..8055c76543 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/menu/menu-control.tsx@@ -1,12 +1,11 @@-import React from "react";import { IconButtonWithMenu } from "@webstudio-is/design-system";-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 { iconConfigs } from "../shared/configs";+import { TextControl } from "../text/text-control";+import { getFinalValue } from "../../shared/get-final-value";+import { useIsFromCurrentBreakpoint } from "../../shared/use-is-from-current-breakpoint";+import type { ControlProps } from "../../style-sections";+import { iconConfigs } from "../../shared/configs";-export const IconButtonWithMenuControl = ({+export const MenuControl = ({currentStyle,inheritedStyle,setProperty,@@ -27,9 +26,10 @@ export const IconButtonWithMenuControl = ({const setValue = setProperty(styleConfig.property);const currentValue = value.value as string;+ // @todo stop-gap measure until work on grid section is doneif (String(currentStyle.display?.value).includes("flex") !== true) {return (- <ComboboxControl+ <TextControlcurrentStyle={currentStyle}inheritedStyle={inheritedStyle}setProperty={setProperty}diff --git a/apps/designer/app/designer/features/style-panel/controls/select-control.tsx b/apps/designer/app/designer/features/style-panel/controls/select/select-control.tsxsimilarity index 83%rename from apps/designer/app/designer/features/style-panel/controls/select-control.tsxrename to apps/designer/app/designer/features/style-panel/controls/select/select-control.tsxindex 0423745f49..7efcc64198 100644--- a/apps/designer/app/designer/features/style-panel/controls/select-control.tsx+++ b/apps/designer/app/designer/features/style-panel/controls/select/select-control.tsx@@ -1,7 +1,7 @@import { Flex, Select } from "@webstudio-is/design-system";-import { getFinalValue } from "../shared/get-final-value";-import { PropertyNameUtility } from "./property-name-utility";-import type { ControlProps } from "../style-sections";+import { getFinalValue } from "../../shared/get-final-value";+import { PropertyName } from "../../shared/property-name";+import type { ControlProps } from "../../style-sections";export const SelectControl = ({currentStyle,@@ -22,7 +22,7 @@ export const SelectControl = ({return (<Flex align="center">- <PropertyNameUtility+ <PropertyNameproperty={styleConfig.property}label={styleConfig.label}css={{diff --git a/apps/designer/app/designer/features/style-panel/controls/spacing-control.tsx b/apps/designer/app/designer/features/style-panel/controls/spacing/spacing-control.tsxsimilarity index 94%rename from apps/designer/app/designer/features/style-panel/controls/spacing-control.tsxrename to apps/designer/app/designer/features/style-panel/controls/spacing/spacing-control.tsxindex fa885212f8..c7a9272d4c 100644--- a/apps/designer/app/designer/features/style-panel/controls/spacing-control.tsx+++ b/apps/designer/app/designer/features/style-panel/controls/spacing/spacing-control.tsx@@ -6,11 +6,11 @@ import {type StyleValue,} from "@webstudio-is/react-sdk";import { Box } from "@webstudio-is/design-system";-import { SetProperty } from "../shared/use-style-data";-import { useIsFromCurrentBreakpoint } from "../shared/use-is-from-current-breakpoint";-import { propertyNameColorForSelectedBreakpoint } from "../shared/constants";-import { getFinalValue } from "../shared/get-final-value";-import type { ControlProps } from "../style-sections";+import { SetProperty } from "../../shared/use-style-data";+import { useIsFromCurrentBreakpoint } from "../../shared/use-is-from-current-breakpoint";+import { propertyNameColorForSelectedBreakpoint } from "../../shared/constants";+import { getFinalValue } from "../../shared/get-final-value";+import type { ControlProps } from "../../style-sections";type SpacingSingularStyle = { [property in SpacingProperty]?: StyleValue };diff --git a/apps/designer/app/designer/features/style-panel/controls/combobox-control.tsx b/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsxsimilarity index 83%rename from apps/designer/app/designer/features/style-panel/controls/combobox-control.tsxrename to apps/designer/app/designer/features/style-panel/controls/text/text-control.tsxindex bf72d836cc..e70b9c71b3 100644--- a/apps/designer/app/designer/features/style-panel/controls/combobox-control.tsx+++ b/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx@@ -1,35 +1,20 @@import { ChangeEvent } from "react";-import type { StyleValue } from "@webstudio-is/react-sdk";import {Flex,Grid,- Text,Combobox,IconButton,TextField,Tooltip,} from "@webstudio-is/design-system";-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";+import { PropertyName } from "../../shared/property-name";+import { getFinalValue } from "../../shared/get-final-value";+import { useIsFromCurrentBreakpoint } from "../../shared/use-is-from-current-breakpoint";+import { ControlProps } from "../../style-sections";import { RowGapIcon, ColumnGapIcon } from "@webstudio-is/icons";+import { Unit } from "../../shared/unit";-const Unit = ({ value }: { value: StyleValue }) => {- if (value.type !== "unit" || value.unit === "number") return null;- return (- <Text- css={{- fontSize: "$1",- cursor: "default",- }}- >- {value.unit}- </Text>- );-};--export const ComboboxControl = ({+export const TextControl = ({currentStyle,inheritedStyle,setProperty,@@ -118,10 +103,7 @@ export const ComboboxControl = ({return (<Grid columns={2} align="center" gapX="1">{/* @todo needs icon variant */}- <PropertyNameUtility- property={styleConfig.property}- label={styleConfig.label}- />+ <PropertyName property={styleConfig.property} label={styleConfig.label} /><Flex align="center" css={{ gridColumn: "2/4" }} gap="1"><Comboboxname={styleConfig.property}diff --git a/apps/designer/app/designer/features/style-panel/sections/index.ts b/apps/designer/app/designer/features/style-panel/sections/index.tsindex eec9d1e67d..407995882f 100644--- a/apps/designer/app/designer/features/style-panel/sections/index.ts+++ b/apps/designer/app/designer/features/style-panel/sections/index.ts@@ -1 +1 @@-export * from "./layout";+export * from "./layout/layout";diff --git a/apps/designer/app/designer/features/style-panel/sections/layout.tsx b/apps/designer/app/designer/features/style-panel/sections/layout/layout.tsxsimilarity index 89%rename from apps/designer/app/designer/features/style-panel/sections/layout.tsxrename to apps/designer/app/designer/features/style-panel/sections/layout/layout.tsxindex 3c5005b078..11324821b4 100644--- a/apps/designer/app/designer/features/style-panel/sections/layout.tsx+++ b/apps/designer/app/designer/features/style-panel/sections/layout/layout.tsx@@ -1,6 +1,8 @@import { Grid } from "@webstudio-is/design-system";-import type { RenderCategoryProps } from "../style-sections";-import { GridUtility, LockUtility, ShowMoreUtility } from "../controls";+import type { RenderCategoryProps } from "../../style-sections";+import { FlexGrid } from "../../shared/flex-grid";+import { Lock } from "../../shared/lock";+import { ShowMore } from "../../shared/show-more";const CSSLayoutSection = {alignItems: "center",@@ -40,7 +42,7 @@ const LayoutSectionFlex = ({return (<Grid css={CSSLayoutSectionFlex}>{styleConfigsByCategory}- <LockUtility+ <Lockname="lock"pairedKeys={["columnGap", "rowGap"]}currentStyle={{@@ -49,7 +51,7 @@ const LayoutSectionFlex = ({}}batchUpdate={batchUpdate}/>- <GridUtility+ <FlexGridname="grid"currentStyle={currentStyle}batchUpdate={batchUpdate}@@ -83,7 +85,7 @@ export const LayoutSection = ({return (<>- <ShowMoreUtility styleConfigs={moreStyleConfigsByCategory} />+ <ShowMore styleConfigs={moreStyleConfigsByCategory} />{styleConfigsByCategory}</>);diff --git a/apps/designer/app/designer/features/style-panel/shared/configs.ts b/apps/designer/app/designer/features/style-panel/shared/configs.tsindex 661ada08d5..034d92abb7 100644--- a/apps/designer/app/designer/features/style-panel/shared/configs.ts+++ b/apps/designer/app/designer/features/style-panel/shared/configs.ts@@ -45,9 +45,9 @@ type BaseStyleConfig = {export type Control =| "Spacing"- | "Combobox"+ | "Text"| "Color"- | "IconButtonWithMenu"+ | "Menu"| "Select"| "Empty";@@ -81,14 +81,14 @@ const getControl = (property: StyleProperty): Control => {case "justifyItems":case "justifyContent":case "alignContent": {- return "IconButtonWithMenu";+ return "Menu";}case "placeContent": {return "Empty";}}- return "Combobox";+ return "Text";};const createStyleConfigs = () => {diff --git a/apps/designer/app/designer/features/style-panel/controls/grid-utility.tsx b/apps/designer/app/designer/features/style-panel/shared/flex-grid.tsxsimilarity index 95%rename from apps/designer/app/designer/features/style-panel/controls/grid-utility.tsxrename to apps/designer/app/designer/features/style-panel/shared/flex-grid.tsxindex 02b0313a4e..c4b75050c1 100644--- a/apps/designer/app/designer/features/style-panel/controls/grid-utility.tsx+++ b/apps/designer/app/designer/features/style-panel/shared/flex-grid.tsx@@ -1,10 +1,10 @@import { Flex, Grid, IconButton } from "@webstudio-is/design-system";import { DotFilledIcon } from "@webstudio-is/icons";-import { useIsFromCurrentBreakpoint } from "../shared/use-is-from-current-breakpoint";+import { useIsFromCurrentBreakpoint } from "./use-is-from-current-breakpoint";import type { Style } from "@webstudio-is/react-sdk";-import type { CreateBatchUpdate } from "../shared/use-style-data";+import type { CreateBatchUpdate } from "./use-style-data";-export const GridUtility = ({+export const FlexGrid = ({name,currentStyle,batchUpdate,diff --git a/apps/designer/app/designer/features/style-panel/controls/lock-utility.tsx b/apps/designer/app/designer/features/style-panel/shared/lock.tsxsimilarity index 91%rename from apps/designer/app/designer/features/style-panel/controls/lock-utility.tsxrename to apps/designer/app/designer/features/style-panel/shared/lock.tsxindex 9ee6a822bb..cc8e0de9cf 100644--- a/apps/designer/app/designer/features/style-panel/controls/lock-utility.tsx+++ b/apps/designer/app/designer/features/style-panel/shared/lock.tsx@@ -2,9 +2,9 @@ import { useState, useEffect } from "react";import { IconButton } from "@webstudio-is/design-system";import { LockOpenIcon, LockCloseIcon } from "@webstudio-is/icons";import type { Style } from "@webstudio-is/react-sdk";-import type { CreateBatchUpdate } from "../shared/use-style-data";+import type { CreateBatchUpdate } from "./use-style-data";-export const LockUtility = ({+export const Lock = ({name,pairedKeys,currentStyle,diff --git a/apps/designer/app/designer/features/style-panel/controls/property-name-utility.tsx b/apps/designer/app/designer/features/style-panel/shared/property-name.tsxsimilarity index 73%rename from apps/designer/app/designer/features/style-panel/controls/property-name-utility.tsxrename to apps/designer/app/designer/features/style-panel/shared/property-name.tsxindex 373ec6f65e..93d6ab6dd7 100644--- a/apps/designer/app/designer/features/style-panel/controls/property-name-utility.tsx+++ b/apps/designer/app/designer/features/style-panel/shared/property-name.tsx@@ -1,13 +1,9 @@import { Label } from "@webstudio-is/design-system";-import { useIsFromCurrentBreakpoint } from "../shared/use-is-from-current-breakpoint";-import { propertyNameColorForSelectedBreakpoint } from "../shared/constants";+import { useIsFromCurrentBreakpoint } from "./use-is-from-current-breakpoint";+import { propertyNameColorForSelectedBreakpoint } from "./constants";import type { PropertyProps } from "../style-sections";-export const PropertyNameUtility = ({- property,- label,- css,-}: PropertyProps) => {+export const PropertyName = ({ property, label, css }: PropertyProps) => {const isCurrentBreakpoint = useIsFromCurrentBreakpoint(property);return (diff --git a/apps/designer/app/designer/features/style-panel/controls/show-more-utility.tsx b/apps/designer/app/designer/features/style-panel/shared/show-more.tsxsimilarity index 96%rename from apps/designer/app/designer/features/style-panel/controls/show-more-utility.tsxrename to apps/designer/app/designer/features/style-panel/shared/show-more.tsxindex 6bef96b829..5ac054ccd3 100644--- a/apps/designer/app/designer/features/style-panel/controls/show-more-utility.tsx+++ b/apps/designer/app/designer/features/style-panel/shared/show-more.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";-export const ShowMoreUtility = ({+export const ShowMore = ({styleConfigs,}: {styleConfigs: Array<JSX.Element | null>;diff --git a/apps/designer/app/designer/features/style-panel/shared/unit.tsx b/apps/designer/app/designer/features/style-panel/shared/unit.tsxnew file mode 100644index 0000000000..c85ac9d4a4--- /dev/null+++ b/apps/designer/app/designer/features/style-panel/shared/unit.tsx@@ -0,0 +1,16 @@+import type { StyleValue } from "@webstudio-is/react-sdk";+import { Text } from "@webstudio-is/design-system";++export const Unit = ({ value }: { value: StyleValue }) => {+ if (value.type !== "unit" || value.unit === "number") return null;+ return (+ <Text+ css={{+ fontSize: "$1",+ cursor: "default",+ }}+ >+ {value.unit}+ </Text>+ );+};diff --git a/apps/designer/app/designer/features/style-panel/style-sections.tsx b/apps/designer/app/designer/features/style-panel/style-sections.tsxindex b1fc70b007..0ebc04cccb 100644--- a/apps/designer/app/designer/features/style-panel/style-sections.tsx+++ b/apps/designer/app/designer/features/style-panel/style-sections.tsx@@ -11,11 +11,11 @@ import type { InheritedStyle } from "./shared/get-inherited-style";import {ColorControl,SpacingControl,- ComboboxControl,+ TextControl,SelectControl,- IconButtonWithMenuControl,- ShowMoreUtility,+ MenuControl,} from "./controls";+import { ShowMore } from "./shared/show-more";import { LayoutSection } from "./sections";export type PropertyProps = {@@ -90,7 +90,7 @@ export const renderCategory = ({return (<>{styleConfigsByCategory}- <ShowMoreUtility styleConfigs={moreStyleConfigsByCategory} />+ <ShowMore styleConfigs={moreStyleConfigsByCategory} /></>);}@@ -115,9 +115,9 @@ const sections: {const controls: {[key: string]: (props: ControlProps) => JSX.Element | null;} = {+ Menu: MenuControl,+ Text: TextControl,Color: ColorControl,- Spacing: SpacingControl,- Combobox: ComboboxControl,- IconButtonWithMenu: IconButtonWithMenuControl,Select: SelectControl,+ Spacing: SpacingControl,};