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.

add category to StyleConfig

Sultan5ac89c61af21
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 3750e0cb33..27f13e8e66 100644
--- a/apps/designer/app/designer/features/style-panel/shared/configs.ts
+++ b/apps/designer/app/designer/features/style-panel/shared/configs.ts
@@ -23,6 +23,7 @@ export type Control =
| "Empty";
type StyleConfigWithItems = BaseStyleConfig & {
+ category: Category;
control: Control;
items: Array<{ label: string; name: string }>;
};
@@ -83,6 +84,7 @@ const createStyleConfigs = () => {
label,
property,
appliesTo: properties[property].appliesTo,
+ category: category,
control: getControl(property),
items: keywords.map((keyword: string) => ({
label: keyword,
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 60e7d33184..e5241d72f8 100644
--- a/apps/designer/app/designer/features/style-panel/style-section.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-section.tsx
@@ -203,61 +203,63 @@ const ComboboxControl = ({
switch (styleConfig.property) {
case "rowGap":
case "columnGap": {
- console.log(currentStyle, styleConfig);
- const Icon = (
- icons as unknown as {
- gap: Record<string, (props: unknown) => JSX.Element>;
- }
- ).gap[styleConfig.property];
- return (
- <Grid
- css={{
- gridTemplateColumns: "repeat(4, 1fr)",
- gridTemplateRows: "repeat(1, 1fr)",
- }}
- >
- <IconButton
- variant="ghost"
- size="1"
- css={{
- zIndex: 1,
- gridArea: "1 / 1 / 2 / 2",
- marginLeft: 2,
- marginTop: 2,
- borderRadius: 1,
- height: "calc($sizes$5 - 4px)",
- width: "calc($sizes$5 - 4px)",
- "&:focus": {
- boxShadow: "none",
- },
- ...(isCurrentBreakpoint && {
- bc: "$colors$blue4",
- "& svg *": {
- fill: "$colors$blue11",
- },
- }),
- }}
- >
- <Icon />
- </IconButton>
- <TextField
- type="number"
- defaultValue={parseFloat(String(value.value)) || 0}
- // @todo looses input state and focus
- // onChange={(event: ChangeEvent<HTMLInputElement>) => setValue(event.target.value + "px")
- onKeyDown={(event: KeyboardEvent<HTMLInputElement>) =>
- event.key === "Enter" &&
- setValue(event.currentTarget.value + "px")
+ switch (styleConfig.category) {
+ case "layout":
+ const Icon = (
+ icons as unknown as {
+ gap: Record<string, (props: unknown) => JSX.Element>;
}
- css={{
- fontWeight: "500",
- paddingLeft: "calc($5 + 6px)",
- gridArea: "1 / 1 / -1 / -1",
- cursor: "default",
- }}
- />
- </Grid>
- );
+ ).gap[styleConfig.property];
+ return (
+ <Grid
+ css={{
+ gridTemplateColumns: "repeat(4, 1fr)",
+ gridTemplateRows: "repeat(1, 1fr)",
+ }}
+ >
+ <IconButton
+ variant="ghost"
+ size="1"
+ css={{
+ zIndex: 1,
+ gridArea: "1 / 1 / 2 / 2",
+ marginLeft: 2,
+ marginTop: 2,
+ borderRadius: 1,
+ height: "calc($sizes$5 - 4px)",
+ width: "calc($sizes$5 - 4px)",
+ "&:focus": {
+ boxShadow: "none",
+ },
+ ...(isCurrentBreakpoint && {
+ bc: "$colors$blue4",
+ "& svg *": {
+ fill: "$colors$blue11",
+ },
+ }),
+ }}
+ >
+ <Icon />
+ </IconButton>
+ <TextField
+ type="number"
+ defaultValue={parseFloat(String(value.value)) || 0}
+ // @todo looses input state and focus
+ // onChange={(event: ChangeEvent<HTMLInputElement>) => setValue(event.target.value + "px")
+ onKeyDown={(event: KeyboardEvent<HTMLInputElement>) =>
+ event.key === "Enter" &&
+ setValue(event.currentTarget.value + "px")
+ }
+ css={{
+ fontWeight: "500",
+ paddingLeft: "calc($5 + 6px)",
+ gridArea: "1 / 1 / -1 / -1",
+ cursor: "default",
+ }}
+ />
+ </Grid>
+ );
+ }
}
}
diff --git a/packages/react-sdk/src/css/categories.ts b/packages/react-sdk/src/css/categories.ts
index 59fc14d144..2b1e46467e 100644
--- a/packages/react-sdk/src/css/categories.ts
+++ b/packages/react-sdk/src/css/categories.ts
@@ -89,6 +89,7 @@ const typography = [
"textIndent",
"columnCount",
+ "columnGap",
"columnRuleStyle",
"columnRuleWidth",
"columnRuleColor",