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
rename ui to control
Oleg Isonen9f97f876afd0
diff --git a/app/designer/features/style-panel/render-property.tsx b/app/designer/features/style-panel/render-property.tsxindex 755e56052b..8011e39891 100644--- a/app/designer/features/style-panel/render-property.tsx+++ b/app/designer/features/style-panel/render-property.tsx@@ -1,12 +1,4 @@-import { useId } from "@radix-ui/react-id";-import {- Flex,- Grid,- ToggleGroup as ToggleGroupPrimitive,- Label,- Select as SelectPrimitive,- Text,-} from "~/shared/design-system";+import { Flex, Grid, Label, Text } from "~/shared/design-system";import type { StyleConfig } from "~/shared/style-panel-configs";import {Style,@@ -43,7 +35,7 @@ const getFinalValue = ({return currentValue;};-type RendererProps = {+type ControlProps = {setProperty: SetProperty;currentStyle: Style;inheritedStyle: InheritedStyle;@@ -55,8 +47,8 @@ const ColorField = ({inheritedStyle,setProperty,styleConfig,-}: RendererProps) => {- if (styleConfig.ui !== "ColorField") return null;+}: ControlProps) => {+ if (styleConfig.control !== "ColorField") return null;// @todo show which instance we inherited the value fromconst value = getFinalValue({currentStyle,@@ -89,8 +81,8 @@ const Spacing = ({inheritedStyle,setProperty,styleConfig,-}: RendererProps) => {- if (styleConfig.ui !== "Spacing") return null;+}: ControlProps) => {+ if (styleConfig.control !== "Spacing") return null;const styles = categories.spacing.properties.reduce((acc: SpacingStyles, property: SpacingProperty): SpacingStyles => {@@ -139,8 +131,8 @@ const TextFieldWithAutocomplete = ({inheritedStyle,setProperty,styleConfig,-}: RendererProps) => {- if (styleConfig.ui !== "TextFieldWithAutocomplete") return null;+}: ControlProps) => {+ if (styleConfig.control !== "TextFieldWithAutocomplete") return null;// @todo show which instance we inherited the value fromconst value = getFinalValue({@@ -154,7 +146,7 @@ const TextFieldWithAutocomplete = ({return (<Grid columns={2} align="center" gapX="1"><Label css={{ gridColumn: "1" }} size="1">- {styleConfig.label}1+ {styleConfig.label}</Label><Flex align="center" css={{ gridColumn: "2/4" }} gap="1"><Autocomplete@@ -175,8 +167,8 @@ const TextFieldWithAutocomplete = ({);};-const renderers: {- [key: string]: (props: RendererProps) => JSX.Element | null;+const controls: {+ [key: string]: (props: ControlProps) => JSX.Element | null;} = {ColorField,Spacing,@@ -198,10 +190,10 @@ export const renderProperty = ({styleConfig,category,}: RenderPropertyProps) => {- const Renderer = renderers[styleConfig.ui];+ const Control = controls[styleConfig.control];return (- <Renderer+ <Controlkey={category + "-" + styleConfig.property}currentStyle={currentStyle}inheritedStyle={inheritedStyle}diff --git a/app/shared/style-panel-configs/configs.ts b/app/shared/style-panel-configs/configs.tsindex 12b3eb757c..a44dfa2a69 100644--- a/app/shared/style-panel-configs/configs.ts+++ b/app/shared/style-panel-configs/configs.ts@@ -7,8 +7,7 @@ import {type Category,type StyleProperty,} from "@webstudio-is/sdk";-import type { StyleConfig } from "./types";-import { UiType } from ".";+import type { StyleConfig, Control } from "./types";const humanizeString = (string: string): string => {return snakeCase(string).split("_").map(capitalize).join(" ");@@ -16,7 +15,7 @@ const humanizeString = (string: string): string => {type Property = keyof typeof keywordValues;-const getUiType = (property: StyleProperty): UiType => {+const getControl = (property: StyleProperty): Control => {if (property.toLocaleLowerCase().includes("color")) {return "ColorField";}@@ -51,7 +50,7 @@ const createStyleConfigs = () => {label,property,appliesTo: properties[property].appliesTo,- ui: getUiType(property),+ control: getControl(property),items: keywords.map((keyword: string) => ({label: keyword,name: keyword,diff --git a/app/shared/style-panel-configs/types.ts b/app/shared/style-panel-configs/types.tsindex 5cbf1d2728..f28487122b 100644--- a/app/shared/style-panel-configs/types.ts+++ b/app/shared/style-panel-configs/types.ts@@ -6,15 +6,10 @@ type BaseStyleConfig = {appliesTo: AppliesTo;};-export type UiType =- | "Spacing"- | "Select"- | "ToggleGroup"- | "TextFieldWithAutocomplete"- | "ColorField";+export type Control = "Spacing" | "TextFieldWithAutocomplete" | "ColorField";type StyleConfigWithItems = BaseStyleConfig & {- ui: UiType;+ control: Control;items: Array<{ label: string; name: string }>;};