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.tsx similarity index 96% rename from apps/designer/app/designer/features/style-panel/controls/background-image/background-image-control.tsx rename to apps/designer/app/designer/features/style-panel/controls/image/image-control.tsx index 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.ts index 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/sections/layout/layout.tsx b/apps/designer/app/designer/features/style-panel/sections/layout/layout.tsx index ee75ef1c87..7529e48ee3 100644 --- a/apps/designer/app/designer/features/style-panel/sections/layout/layout.tsx +++ b/apps/designer/app/designer/features/style-panel/sections/layout/layout.tsx @@ -23,56 +23,77 @@ const LayoutSectionFlex = ({ rowGap, } = sectionStyle; const batchUpdate = createBatchUpdate(); + const hasMenuItems = [ + flexDirection, + flexWrap, + alignItems, + justifyContent, + alignContent, + ].some((config) => config !== undefined); + return ( - - - - - + + + + )} + {hasMenuItems && ( + - - - - - - - - - - - - - - - - {alignContent && ( - - + alignItems: "center", + }} + > + + - )} - + {flexDirection?.styleConfig && ( + + + + )} + {flexWrap?.styleConfig && ( + + + + )} + {alignItems?.styleConfig && ( + + + + )} + {justifyContent?.styleConfig && ( + + + + )} + {alignContent && ( + + + + )} + + )} + - - - - - - - - - + {columnGap?.styleConfig && ( + + + + )} + {rowGap?.styleConfig && columnGap?.styleConfig && ( + + + + )} + {rowGap?.styleConfig && ( + + + + )} ); 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 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 controls export 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.tsx index 265a52184d..7501ca59fe 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 = { @@ -39,7 +32,7 @@ export type RenderCategoryProps = { createBatchUpdate: CreateBatchUpdate; currentStyle: Style; sectionStyle: { - [Property in keyof Style]-?: RenderPropertyProps; + [Property in keyof Style]: RenderPropertyProps; }; inheritedStyle: InheritedStyle; category: Category; @@ -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, -};