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
make controls automatically map from exports
Oleg Isonen7f35c0df7d9c
diff --git a/apps/designer/app/designer/features/style-panel/controls/background-image/background-image-control.tsx b/apps/designer/app/designer/features/style-panel/controls/image/image-control.tsxsimilarity index 96%rename from apps/designer/app/designer/features/style-panel/controls/background-image/background-image-control.tsxrename to apps/designer/app/designer/features/style-panel/controls/image/image-control.tsxindex d213201d2c..49daf2d4b3 100644--- a/apps/designer/app/designer/features/style-panel/controls/background-image/background-image-control.tsx+++ b/apps/designer/app/designer/features/style-panel/controls/image/image-control.tsx@@ -5,7 +5,7 @@ import { ValuePickerPopover } from "../../shared/value-picker-popover";import { ImageManager } from "~/designer/shared/image-manager";import { useAssets } from "~/designer/shared/assets";-export const BackgroundImageControl = ({+export const ImageControl = ({currentStyle,inheritedStyle,setProperty,diff --git a/apps/designer/app/designer/features/style-panel/controls/index.ts b/apps/designer/app/designer/features/style-panel/controls/index.tsindex 23066cea02..f6e4b98bb3 100644--- a/apps/designer/app/designer/features/style-panel/controls/index.ts+++ b/apps/designer/app/designer/features/style-panel/controls/index.ts@@ -3,3 +3,4 @@ export * from "./color/color-control";export * from "./select/select-control";export * from "./menu/menu-control";export * from "./font-family/font-family-control";+export * from "./image/image-control";diff --git a/apps/designer/app/designer/features/style-panel/shared/configs.ts b/apps/designer/app/designer/features/style-panel/shared/configs.tsindex ca8fcfa658..503142a654 100644--- a/apps/designer/app/designer/features/style-panel/shared/configs.ts+++ b/apps/designer/app/designer/features/style-panel/shared/configs.ts@@ -48,12 +48,12 @@ type BaseStyleConfig = {// @todo make it use actual list of controlsexport type Control =- | "Text"- | "Color"- | "Menu"- | "Select"- | "FontFamily"- | "Image";+ | "TextControl"+ | "ColorControl"+ | "MenuControl"+ | "SelectControl"+ | "FontFamilyControl"+ | "ImageControl";export type StyleConfig = BaseStyleConfig & {control: Control;@@ -64,19 +64,19 @@ type Property = keyof typeof keywordValues;const getControl = (property: StyleProperty): Control => {if (property.toLocaleLowerCase().includes("color")) {- return "Color";+ return "ColorControl";}switch (property) {case "fontFamily": {- return isFeatureEnabled("fonts") ? "FontFamily" : "Text";+ return isFeatureEnabled("fonts") ? "FontFamilyControl" : "TextControl";}case "backgroundImage": {- return isFeatureEnabled("assets") ? "Image" : "Text";+ return isFeatureEnabled("assets") ? "ImageControl" : "TextControl";}}- return "Text";+ return "TextControl";};const createStyleConfigs = () => {diff --git a/apps/designer/app/designer/features/style-panel/style-sections.tsx b/apps/designer/app/designer/features/style-panel/style-sections.tsxindex 265a52184d..bed67a15b8 100644--- a/apps/designer/app/designer/features/style-panel/style-sections.tsx+++ b/apps/designer/app/designer/features/style-panel/style-sections.tsx@@ -8,16 +8,9 @@ import {} from "@webstudio-is/react-sdk";import type { SetProperty, CreateBatchUpdate } from "./shared/use-style-data";import type { InheritedStyle } from "./shared/get-inherited-style";-import {- ColorControl,- TextControl,- SelectControl,- MenuControl,- FontFamilyControl,-} from "./controls";+import * as controls from "./controls";import { ShowMore } from "./shared/show-more";import { LayoutSection, SpacingSection } from "./sections";-import { BackgroundImageControl } from "./controls/background-image/background-image-control";import { PropertyName } from "./shared/property-name";export type PropertyProps = {@@ -138,14 +131,3 @@ const sections: {layout: LayoutSection,spacing: SpacingSection,};--const controls: {- [key: string]: (props: ControlProps) => JSX.Element | null;-} = {- Menu: MenuControl,- Text: TextControl,- Color: ColorControl,- Select: SelectControl,- FontFamily: FontFamilyControl,- Image: BackgroundImageControl,-};