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.

refactor spacing control to spacing section

Sultan4603778b5f75
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 81f0a3306e..23066cea02 100644
--- a/apps/designer/app/designer/features/style-panel/controls/index.ts
+++ b/apps/designer/app/designer/features/style-panel/controls/index.ts
@@ -2,5 +2,4 @@ export * from "./text/text-control";
export * from "./color/color-control";
export * from "./select/select-control";
export * from "./menu/menu-control";
-export * from "./spacing/spacing-control";
export * from "./font-family/font-family-control";
diff --git a/apps/designer/app/designer/features/style-panel/sections/index.ts b/apps/designer/app/designer/features/style-panel/sections/index.ts
index 407995882f..ceb46300a7 100644
--- a/apps/designer/app/designer/features/style-panel/sections/index.ts
+++ b/apps/designer/app/designer/features/style-panel/sections/index.ts
@@ -1 +1,2 @@
export * from "./layout/layout";
+export * from "./spacing/spacing";
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 3186d706bd..af3a651107 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
@@ -135,6 +135,7 @@ export const LayoutSection = ({
createBatchUpdate,
currentStyle,
sectionStyle,
+ inheritedStyle,
category,
styleConfigsByCategory,
moreStyleConfigsByCategory,
@@ -147,8 +148,9 @@ export const LayoutSection = ({
setProperty={setProperty}
createBatchUpdate={createBatchUpdate}
currentStyle={currentStyle}
- category={category}
sectionStyle={sectionStyle}
+ inheritedStyle={inheritedStyle}
+ category={category}
styleConfigsByCategory={styleConfigsByCategory}
moreStyleConfigsByCategory={moreStyleConfigsByCategory}
/>
diff --git a/apps/designer/app/designer/features/style-panel/controls/spacing/spacing-control.tsx b/apps/designer/app/designer/features/style-panel/sections/spacing/spacing.tsx
similarity index 96%
rename from apps/designer/app/designer/features/style-panel/controls/spacing/spacing-control.tsx
rename to apps/designer/app/designer/features/style-panel/sections/spacing/spacing.tsx
index 5a6eb62029..4e9e750c77 100644
--- a/apps/designer/app/designer/features/style-panel/controls/spacing/spacing-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/spacing/spacing.tsx
@@ -10,7 +10,7 @@ import { SetProperty } from "../../shared/use-style-data";
import { useIsFromCurrentBreakpoint } from "../../shared/use-is-from-current-breakpoint";
import { propertyNameColorForSelectedBreakpoint } from "../../shared/constants";
import { getFinalValue } from "../../shared/get-final-value";
-import type { ControlProps } from "../../style-sections";
+import type { RenderCategoryProps } from "../../style-sections";
type SpacingSingularStyle = { [property in SpacingProperty]?: StyleValue };
@@ -62,6 +62,7 @@ const styles = {
display: "block",
background: "transparent",
color: "$hiContrast",
+ zIndex: 99,
margin: "auto",
// @todo need to fit more chars
width: 40,
@@ -242,15 +243,11 @@ const SpacingWidget = ({ setProperty, values }: SpacingWidgetProps) => {
);
};
-// @todo convert to section, they way it does atm is a "hack"
-export const SpacingControl = ({
+export const SpacingSection = ({
currentStyle,
inheritedStyle,
setProperty,
- styleConfig,
-}: ControlProps) => {
- if (styleConfig.control !== "Spacing") return null;
-
+}: RenderCategoryProps) => {
const styles = categories.spacing.properties.reduce(
(acc: SpacingStyles, property: SpacingProperty): SpacingStyles => {
const value = getFinalValue({
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 355019e9ac..fbe936e3e5 100644
--- a/apps/designer/app/designer/features/style-panel/style-sections.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-sections.tsx
@@ -10,14 +10,13 @@ import type { SetProperty, CreateBatchUpdate } from "./shared/use-style-data";
import type { InheritedStyle } from "./shared/get-inherited-style";
import {
ColorControl,
- SpacingControl,
TextControl,
SelectControl,
MenuControl,
FontFamilyControl,
} from "./controls";
import { ShowMore } from "./shared/show-more";
-import { LayoutSection } from "./sections";
+import { LayoutSection, SpacingSection } from "./sections";
import { PropertyName } from "./shared/property-name";
export type PropertyProps = {
@@ -39,6 +38,7 @@ export type RenderCategoryProps = {
createBatchUpdate: CreateBatchUpdate;
currentStyle: Style;
sectionStyle: Style;
+ inheritedStyle: InheritedStyle;
category: Category;
styleConfigsByCategory: Array<RenderPropertyProps>;
moreStyleConfigsByCategory: Array<RenderPropertyProps>;
@@ -82,6 +82,7 @@ export const renderCategory = ({
createBatchUpdate,
currentStyle,
sectionStyle,
+ inheritedStyle,
category,
styleConfigsByCategory,
moreStyleConfigsByCategory,
@@ -106,6 +107,7 @@ export const renderCategory = ({
createBatchUpdate={createBatchUpdate}
currentStyle={currentStyle}
sectionStyle={sectionStyle}
+ inheritedStyle={inheritedStyle}
category={category}
styleConfigsByCategory={styleConfigsByCategory}
moreStyleConfigsByCategory={moreStyleConfigsByCategory}
@@ -131,7 +133,7 @@ const sections: {
[key: string]: (props: RenderCategoryProps) => JSX.Element | null;
} = {
layout: LayoutSection,
- // spacing: SpacingSection,
+ spacing: SpacingSection,
};
const controls: {
@@ -141,6 +143,5 @@ const controls: {
Text: TextControl,
Color: ColorControl,
Select: SelectControl,
- Spacing: SpacingControl,
FontFamily: FontFamilyControl,
};
diff --git a/apps/designer/app/designer/features/style-panel/style-settings.tsx b/apps/designer/app/designer/features/style-panel/style-settings.tsx
index bebac83466..47b7614a38 100644
--- a/apps/designer/app/designer/features/style-panel/style-settings.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-settings.tsx
@@ -140,6 +140,7 @@ export const StyleSettings = ({
if (styleConfigsByCategory.length === 0) continue;
const categoryProps = {
+ ...rest,
setProperty,
createBatchUpdate,
currentStyle,