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.

genericly render other layout display sections

Sultan586a551728ef
diff --git a/apps/designer/app/designer/features/style-panel/lib/configs.ts b/apps/designer/app/designer/features/style-panel/lib/configs.ts
index f7745dbce0..3750e0cb33 100644
--- a/apps/designer/app/designer/features/style-panel/lib/configs.ts
+++ b/apps/designer/app/designer/features/style-panel/lib/configs.ts
@@ -14,7 +14,13 @@ type BaseStyleConfig = {
appliesTo: AppliesTo;
};
-export type Control = "Spacing" | "Combobox" | "Color" | "Comboicon" | "Select";
+export type Control =
+ | "Spacing"
+ | "Combobox"
+ | "Color"
+ | "Comboicon"
+ | "Select"
+ | "Empty";
type StyleConfigWithItems = BaseStyleConfig & {
control: Control;
@@ -50,6 +56,9 @@ const getControl = (property: StyleProperty): Control => {
case "alignContent": {
return "Comboicon";
}
+ case "placeContent": {
+ return "Empty";
+ }
}
return "Combobox";
diff --git a/apps/designer/app/designer/features/style-panel/style-section.tsx b/apps/designer/app/designer/features/style-panel/style-section.tsx
index 61b276d380..e0d7da52e3 100644
--- a/apps/designer/app/designer/features/style-panel/style-section.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-section.tsx
@@ -367,11 +367,13 @@ const ComboiconControl = ({
}
css={{
...(styleConfig.property !== "flexDirection" && {
- transform: `rotate(${
- currentStyle.flexDirection?.value === "column"
- ? 90 * (styleConfig.property === "alignItems" ? -1 : 1)
- : 0
- }deg)`,
+ "& svg": {
+ transform: `rotate(${
+ currentStyle.flexDirection?.value === "column"
+ ? 90 * (styleConfig.property === "alignItems" ? -1 : 1)
+ : 0
+ }deg)`,
+ },
}),
...(isCurrentBreakpoint && {
color: "$colors$blue11",
@@ -568,6 +570,7 @@ export const renderProperty = ({
const Control = controls[styleConfig.control];
const { property } = styleConfig;
const key = category + "-" + property;
+ if (!Control) return null;
return (
<Box
key={key}
@@ -605,34 +608,38 @@ export const renderCategory = ({
}: RenderCategoryProps) => {
switch (category) {
case "layout": {
+ const css = {
+ alignItems: "center",
+ gap: "8px",
+ "& > [data-type=comboicon]": {
+ display: "flex",
+ justifyContent: "center",
+ alignItems: "center",
+ height: "100%",
+ },
+ };
switch (currentStyle.display?.value) {
case "flex": {
return (
<>
<Grid
css={{
- alignItems: "center",
+ ...css,
gridTemplateColumns: "repeat(12, 1fr)",
gridTemplateRows: "auto 0px auto auto 0px auto",
gridTemplateAreas: `
- "display display display display display display display display display display display display"
- "grid grid grid grid grid . . . . . . ."
- "grid grid grid grid grid flexDirection flexDirection flexWrap flexWrap justifyItems justifyItems ."
- "grid grid grid grid grid alignItems alignItems justifyContent justifyContent alignContent alignContent ."
- "grid grid grid grid grid . . . . . . ."
- "columnGap columnGap columnGap columnGap columnGap lock lock rowGap rowGap rowGap rowGap rowGap"
- `,
- gap: "8px",
- "& > [data-type=comboicon]": {
- display: "flex",
- justifyContent: "center",
- alignItems: "center",
- height: "100%",
- },
- // @todo placeContent is shorthand prop for other properties, thus a duplicate
- "& > [data-property=placeContent]": {
- display: "none",
- },
+ "${"display ".repeat(12)}"
+ "${"grid ".repeat(5)} . . . . . . ."
+ "${"grid ".repeat(
+ 5
+ )} flexDirection flexDirection flexWrap flexWrap justifyItems justifyItems ."
+ "${"grid ".repeat(
+ 5
+ )} alignItems alignItems justifyContent justifyContent alignContent alignContent ."
+ "${"grid ".repeat(5)} . . . . . . ."
+ "${"columnGap ".repeat(5)} lock lock ${"rowGap ".repeat(5)}"
+ `,
+ // @todo justify icons are using justifycontent icons atm
"& > [data-property=justifyItems]": {
display: "none",
},
@@ -657,8 +664,40 @@ export const renderCategory = ({
</>
);
}
- default: {
- styleConfigsByCategory = [styleConfigsByCategory[0]];
+ case "grid": {
+ return (
+ <>
+ <Grid
+ css={{
+ ...css,
+ gridTemplateColumns: "repeat(12, 1fr)",
+ gridTemplateRows: "repeat(11, auto)",
+ gridTemplateAreas: `
+ "${"display ".repeat(12)}"
+ "${"gridTemplateAreas ".repeat(12)}"
+ "${"gridAutoRows ".repeat(12)}"
+ "${"gridAutoColumns ".repeat(12)}"
+ "${"gridTemplateColumns ".repeat(12)}"
+ "${"gridTemplateRows ".repeat(12)}"
+ "${"gridAutoFlow ".repeat(12)}"
+ "${"alignItems ".repeat(12)}"
+ "${"justifyItems ".repeat(12)}"
+ "${"alignContent ".repeat(12)}"
+ "${"columnGap ".repeat(5)} lock lock ${"rowGap ".repeat(5)}"
+ `,
+ }}
+ >
+ {styleConfigsByCategory}
+ <LockControl
+ data-property="lock"
+ css={{ gridArea: "lock" }}
+ currentStyle={currentStyle}
+ setProperty={setProperty}
+ />
+ </Grid>
+ <ShowMore styleConfigs={moreStyleConfigsByCategory} />
+ </>
+ );
}
}
}
@@ -673,8 +712,9 @@ export const renderCategory = ({
};
const controls: {
- [key: string]: (props: ControlProps) => JSX.Element | null;
+ [key: string]: ((props: ControlProps) => JSX.Element | null) | null;
} = {
+ Empty: null,
Color: ColorControl,
Spacing: SpacingControl,
Combobox: ComboboxControl,
diff --git a/packages/icons/src/index.ts b/packages/icons/src/index.ts
index be4aaf6036..5b5c8e23e6 100644
--- a/packages/icons/src/index.ts
+++ b/packages/icons/src/index.ts
@@ -13,6 +13,7 @@ export * from "./align-content";
export * from "./align-items";
export * from "./flex-direction";
export * from "./flex-wrap";
-export * from "./gap";
export * from "./justify-content";
+export * from "./justify-items";
+export * from "./gap";
export * from "./lock";
diff --git a/packages/icons/src/justify-items.tsx b/packages/icons/src/justify-items.tsx
new file mode 100644
index 0000000000..cf12ea357a
--- /dev/null
+++ b/packages/icons/src/justify-items.tsx
@@ -0,0 +1,128 @@
+import * as React from "react";
+import { IconProps } from "./types";
+
+// @todo this is just a copy of justifyContent icons for now
+export const JustifyItemsStart = React.forwardRef<SVGSVGElement, IconProps>(
+ (props, forwardedRef) => {
+ return (
+ <svg
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ ref={forwardedRef}
+ >
+ <path
+ d="M10.9999 7.19999H8.79995V4.79999H7.19995V19.2H8.79995V16.8H10.9999V7.19999Z"
+ fill="#11181C"
+ />
+ <path d="M16.8 7.19999H13.6V16.8H16.8V7.19999Z" fill="#11181C" />
+ </svg>
+ );
+ }
+);
+JustifyItemsStart.displayName = "JustifyItemsStart";
+
+export const JustifyItemsCenter = React.forwardRef<SVGSVGElement, IconProps>(
+ (props, forwardedRef) => {
+ return (
+ <svg
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ ref={forwardedRef}
+ >
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M12.7999 4.79999V19.2H11.1999V4.79999H12.7999ZM16.5999 15.8H14.3999V8.19999H16.5999V15.8ZM7.3999 15.8H9.5999V8.19999H7.3999V15.8Z"
+ fill="#11181C"
+ />
+ </svg>
+ );
+ }
+);
+JustifyItemsCenter.displayName = "JustifyItemsCenter";
+
+export const JustifyItemsEnd = React.forwardRef<SVGSVGElement, IconProps>(
+ (props, forwardedRef) => {
+ return (
+ <svg
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ ref={forwardedRef}
+ >
+ <path
+ d="M12 16.8H15.2V19.2H16.8V4.79999H15.2V7.19999H12V16.8Z"
+ fill="#11181C"
+ />
+ <path d="M7.19995 16.8H10.4V7.19999H7.19995V16.8Z" fill="#11181C" />
+ </svg>
+ );
+ }
+);
+JustifyItemsEnd.displayName = "JustifyItemsEnd";
+
+export const JustifyItemsSpaceBetween = React.forwardRef<
+ SVGSVGElement,
+ IconProps
+>((props, forwardedRef) => {
+ return (
+ <svg
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ ref={forwardedRef}
+ >
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M11.1999 7.19999H7.9999V4.79999H6.3999V19.2H7.9999V16.8H11.1999V7.19999ZM12.7999 16.8H15.9999V19.2H17.5999V4.79999H15.9999V7.19999H12.7999V16.8Z"
+ fill="#11181C"
+ />
+ </svg>
+ );
+});
+JustifyItemsSpaceBetween.displayName = "JustifyItemsSpaceBetween";
+
+export const JustifyItemsSpaceAround = React.forwardRef<
+ SVGSVGElement,
+ IconProps
+>((props, forwardedRef) => {
+ return (
+ <svg
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ ref={forwardedRef}
+ >
+ <path d="M7.9999 19.2V4.79999H6.3999V19.2H7.9999Z" fill="#11181C" />
+ <path d="M17.5999 19.2V4.79999H15.9999V19.2H17.5999Z" fill="#11181C" />
+ <path d="M15.1999 16.8H12.7999V7.19999H15.1999V16.8Z" fill="#11181C" />
+ <path d="M8.7999 16.8H11.1999V7.19999H8.7999V16.8Z" fill="#11181C" />
+ </svg>
+ );
+});
+JustifyItemsSpaceAround.displayName = "JustifyItemsSpaceAround";
+
+export const justifyItems = {
+ normal: JustifyItemsStart,
+ start: JustifyItemsStart,
+ end: JustifyItemsEnd,
+ center: JustifyItemsCenter,
+};