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.

rename Spacing to Space (#745)

Roman Pominov91e209e974d5
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 6e82bdbb6e..323f0f8357 100644
--- a/apps/designer/app/designer/features/style-panel/sections/index.ts
+++ b/apps/designer/app/designer/features/style-panel/sections/index.ts
@@ -1,7 +1,7 @@
export * from "./layout/layout";
export * from "./flex-child/flex-child";
export * from "./grid-child/grid-child";
-export * from "./spacing/spacing";
+export * from "./space/space";
export * from "./size/size";
export * from "./position/position";
export * from "./typography/typography";
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/input-popover.tsx b/apps/designer/app/designer/features/style-panel/sections/space/input-popover.tsx
similarity index 100%
rename from apps/designer/app/designer/features/style-panel/sections/spacing/input-popover.tsx
rename to apps/designer/app/designer/features/style-panel/sections/space/input-popover.tsx
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/keyboard.ts b/apps/designer/app/designer/features/style-panel/sections/space/keyboard.ts
similarity index 92%
rename from apps/designer/app/designer/features/style-panel/sections/spacing/keyboard.ts
rename to apps/designer/app/designer/features/style-panel/sections/space/keyboard.ts
index 5d7818dc36..0590993ade 100644
--- a/apps/designer/app/designer/features/style-panel/sections/spacing/keyboard.ts
+++ b/apps/designer/app/designer/features/style-panel/sections/space/keyboard.ts
@@ -1,6 +1,6 @@
import { useState } from "react";
import type { FocusEvent, KeyboardEvent, MouseEvent } from "react";
-import type { SpacingStyleProperty } from "./types";
+import type { SpaceStyleProperty } from "./types";
const movementKeys = [
"ArrowUp",
@@ -23,10 +23,10 @@ const movementMap = {
export const useKeyboardNavigation = ({
onOpen,
}: {
- onOpen: (property: SpacingStyleProperty) => void;
+ onOpen: (property: SpaceStyleProperty) => void;
}) => {
const [activeProperty, setActiveProperty] =
- useState<SpacingStyleProperty>("marginTop");
+ useState<SpaceStyleProperty>("marginTop");
const [isActive, setIsActive] = useState(false);
@@ -40,7 +40,7 @@ export const useKeyboardNavigation = ({
setIsActive(false);
};
- const handleHover = (property: SpacingStyleProperty | undefined) => {
+ const handleHover = (property: SpaceStyleProperty | undefined) => {
// switch to mouse navigation if user starts to use mouse
setIsActive(false);
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/layout.stories.tsx b/apps/designer/app/designer/features/style-panel/sections/space/layout.stories.tsx
similarity index 63%
rename from apps/designer/app/designer/features/style-panel/sections/spacing/layout.stories.tsx
rename to apps/designer/app/designer/features/style-panel/sections/space/layout.stories.tsx
index ac460511f8..07f2d61d29 100644
--- a/apps/designer/app/designer/features/style-panel/sections/spacing/layout.stories.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/space/layout.stories.tsx
@@ -1,17 +1,17 @@
import type { ComponentMeta } from "@storybook/react";
import React from "react";
-import { SpacingLayout } from "./layout";
+import { SpaceLayout } from "./layout";
export const Layout = (
- args: Omit<React.ComponentProps<typeof SpacingLayout>, "renderCell">
+ args: Omit<React.ComponentProps<typeof SpaceLayout>, "renderCell">
) => (
- <SpacingLayout
+ <SpaceLayout
renderCell={() => <div style={{ color: "red" }}>·</div>}
{...args}
/>
);
export default {
- title: "Spacing/Layout",
+ title: "Space/Layout",
component: Layout,
} as ComponentMeta<typeof Layout>;
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/layout.tsx b/apps/designer/app/designer/features/style-panel/sections/space/layout.tsx
similarity index 93%
rename from apps/designer/app/designer/features/style-panel/sections/spacing/layout.tsx
rename to apps/designer/app/designer/features/style-panel/sections/space/layout.tsx
index 389417f950..9432d8c292 100644
--- a/apps/designer/app/designer/features/style-panel/sections/spacing/layout.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/space/layout.tsx
@@ -1,8 +1,8 @@
import { styled, useId } from "@webstudio-is/design-system";
import { forwardRef } from "react";
import type { ComponentProps, Ref } from "react";
-import type { HoverTagret, SpacingStyleProperty } from "./types";
-import { spacingPropertiesNames } from "./types";
+import type { HoverTagret, SpaceStyleProperty } from "./types";
+import { spacePropertiesNames } from "./types";
const VALUE_WIDTH = 34;
const VALUE_HEIGHT = 24;
@@ -187,7 +187,7 @@ const Label = styled("div", {
},
});
-const getSide = (property: SpacingStyleProperty) => {
+const getSide = (property: SpaceStyleProperty) => {
switch (property) {
case "marginTop":
case "paddingTop":
@@ -204,7 +204,7 @@ const getSide = (property: SpacingStyleProperty) => {
}
};
-const getPath = (property: SpacingStyleProperty) => {
+const getPath = (property: SpaceStyleProperty) => {
const width = TOTAL_WIDTH;
const height = TOTAL_HEIGHT;
// distance between LeftValueArea's and RightValueArea's tips in the middle
@@ -236,11 +236,11 @@ type LayoutProps = {
onClick?: ComponentProps<"div">["onClick"];
onMouseLeave?: ComponentProps<"div">["onMouseLeave"];
onHover: (hoverTarget: HoverTagret | undefined) => void;
- activeProperties?: ReadonlyArray<SpacingStyleProperty>;
- renderCell: (args: { property: SpacingStyleProperty }) => React.ReactNode;
+ activeProperties?: ReadonlyArray<SpaceStyleProperty>;
+ renderCell: (args: { property: SpaceStyleProperty }) => React.ReactNode;
};
-export const SpacingLayout = forwardRef(
+export const SpaceLayout = forwardRef(
(
{
onFocus,
@@ -257,7 +257,7 @@ export const SpacingLayout = forwardRef(
const outerClipId = useId();
const innerClipId = useId();
- const renderValueArea = (property: SpacingStyleProperty) => (
+ const renderValueArea = (property: SpaceStyleProperty) => (
<ValueArea
side={getSide(property)}
d={getPath(property)}
@@ -319,7 +319,7 @@ export const SpacingLayout = forwardRef(
<Label>Margin</Label>
<Label inner>Padding</Label>
- {spacingPropertiesNames.map((property) => (
+ {spacePropertiesNames.map((property) => (
<Cell property={property} key={property}>
{renderCell({ property })}
</Cell>
@@ -329,4 +329,4 @@ export const SpacingLayout = forwardRef(
);
}
);
-SpacingLayout.displayName = "SpacingLayout";
+SpaceLayout.displayName = "SpaceLayout";
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/scrub.tsx b/apps/designer/app/designer/features/style-panel/sections/space/scrub.tsx
similarity index 93%
rename from apps/designer/app/designer/features/style-panel/sections/spacing/scrub.tsx
rename to apps/designer/app/designer/features/style-panel/sections/space/scrub.tsx
index 7ea0f8aac4..2de3f22827 100644
--- a/apps/designer/app/designer/features/style-panel/sections/spacing/scrub.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/space/scrub.tsx
@@ -3,16 +3,16 @@ import { numericScrubControl } from "@webstudio-is/design-system";
import { useState, useEffect, useRef } from "react";
import { useModifierKeys } from "../../shared/modifier-keys";
import type { StyleUpdateOptions } from "../../shared/use-style-data";
-import type { SpacingStyleProperty, HoverTagret } from "./types";
+import type { SpaceStyleProperty, HoverTagret } from "./types";
-type Values = Partial<Record<SpacingStyleProperty, StyleValue>>;
+type Values = Partial<Record<SpaceStyleProperty, StyleValue>>;
type ScrubStatus = {
isActive: boolean;
// Properties that should be affected on the next pointer move.
// We keep track of these properties even when scrub is not active.
- properties: ReadonlyArray<SpacingStyleProperty>;
+ properties: ReadonlyArray<SpaceStyleProperty>;
// When scrub is active, this contains ephemeral values for all properties
// that have been affected during current scrub.
@@ -127,10 +127,10 @@ const circleGroups = [
] as const;
const getModifiersGroup = (
- property: SpacingStyleProperty,
+ property: SpaceStyleProperty,
modifiers: { shiftKey: boolean; altKey: boolean }
) => {
- let groups: ReadonlyArray<ReadonlyArray<SpacingStyleProperty>> = [];
+ let groups: ReadonlyArray<ReadonlyArray<SpaceStyleProperty>> = [];
if (modifiers.shiftKey) {
groups = circleGroups;
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/spacing.tsx b/apps/designer/app/designer/features/style-panel/sections/space/space.tsx
similarity index 89%
rename from apps/designer/app/designer/features/style-panel/sections/spacing/spacing.tsx
rename to apps/designer/app/designer/features/style-panel/sections/space/space.tsx
index d1eba052a0..54b1a8c01a 100644
--- a/apps/designer/app/designer/features/style-panel/sections/spacing/spacing.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/space/space.tsx
@@ -1,12 +1,12 @@
import { type ComponentProps, useState, useRef } from "react";
import type { RenderCategoryProps } from "../../style-sections";
-import { SpacingLayout } from "./layout";
+import { SpaceLayout } from "./layout";
import { ValueText } from "./value-text";
import { useScrub } from "./scrub";
-import { spacingPropertiesNames } from "./types";
-import type { SpacingStyleProperty, HoverTagret } from "./types";
+import { spacePropertiesNames } from "./types";
+import type { SpaceStyleProperty, HoverTagret } from "./types";
import { InputPopover } from "./input-popover";
-import { SpacingTooltip } from "./tooltip";
+import { SpaceTooltip } from "./tooltip";
import { getStyleSource } from "../../shared/style-info";
import { useKeyboardNavigation } from "./keyboard";
@@ -24,7 +24,7 @@ const Cell = ({
onPopoverClose: () => void;
onChange: ComponentProps<typeof InputPopover>["onChange"];
onHover: (target: HoverTagret | undefined) => void;
- property: SpacingStyleProperty;
+ property: SpaceStyleProperty;
isActive: boolean;
scrubStatus: ReturnType<typeof useScrub>;
currentStyle: RenderCategoryProps["currentStyle"];
@@ -58,7 +58,7 @@ const Cell = ({
onClose={onPopoverClose}
/>
{isActive && isPopoverOpen === false && scrubStatus.isActive === false ? (
- <SpacingTooltip property={property} />
+ <SpaceTooltip property={property} />
) : null}
<ValueText
css={{
@@ -67,7 +67,7 @@ const Cell = ({
// Click and scrub works everywhere anyway, but we want cursors to be different.
//
// In order to have control over cursor we're setting pointerEvents to "all" here
- // because SpacingLayout sets it to "none" for cells' content.
+ // because SpaceLayout sets it to "none" for cells' content.
pointerEvents: "all",
}}
value={finalValue}
@@ -82,7 +82,7 @@ const Cell = ({
);
};
-export const SpacingSection = ({
+export const SpaceSection = ({
setProperty,
deleteProperty,
createBatchUpdate,
@@ -98,7 +98,7 @@ export const SpacingSection = ({
target: hoverTarget,
onChange: (values, options) => {
const batch = createBatchUpdate();
- for (const property of spacingPropertiesNames) {
+ for (const property of spacePropertiesNames) {
const value = values[property];
if (value !== undefined) {
batch.setProperty(property)(value);
@@ -108,7 +108,7 @@ export const SpacingSection = ({
},
});
- const [openProperty, setOpenProperty] = useState<SpacingStyleProperty>();
+ const [openProperty, setOpenProperty] = useState<SpaceStyleProperty>();
const layoutRef = useRef<HTMLDivElement>(null);
@@ -135,7 +135,7 @@ export const SpacingSection = ({
};
return (
- <SpacingLayout
+ <SpaceLayout
ref={layoutRef}
onClick={() => setOpenProperty(hoverTarget?.property)}
onHover={handleHover}
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/tooltip.tsx b/apps/designer/app/designer/features/style-panel/sections/space/tooltip.tsx
similarity index 91%
rename from apps/designer/app/designer/features/style-panel/sections/spacing/tooltip.tsx
rename to apps/designer/app/designer/features/style-panel/sections/space/tooltip.tsx
index bcf850f0ac..b67ae06aad 100644
--- a/apps/designer/app/designer/features/style-panel/sections/spacing/tooltip.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/space/tooltip.tsx
@@ -3,7 +3,7 @@ import {
Tooltip,
useEnhancedTooltipProps,
} from "@webstudio-is/design-system";
-import { SpacingStyleProperty } from "./types";
+import { SpaceStyleProperty } from "./types";
import { useDebounce } from "use-debounce";
import { useState } from "react";
@@ -39,10 +39,10 @@ const sides = {
marginLeft: "right",
} as const;
-export const SpacingTooltip = ({
+export const SpaceTooltip = ({
property,
}: {
- property: SpacingStyleProperty;
+ property: SpaceStyleProperty;
}) => {
const { delayDuration } = useEnhancedTooltipProps();
const [initialOpen, setInitialOpen] = useState(false);
diff --git a/apps/designer/app/designer/features/style-panel/sections/space/types.ts b/apps/designer/app/designer/features/style-panel/sections/space/types.ts
new file mode 100644
index 0000000000..d08db1b162
--- /dev/null
+++ b/apps/designer/app/designer/features/style-panel/sections/space/types.ts
@@ -0,0 +1,10 @@
+import { categories } from "@webstudio-is/react-sdk";
+
+export const spacePropertiesNames = categories.space.properties;
+
+export type SpaceStyleProperty = typeof spacePropertiesNames[number];
+
+export type HoverTagret = {
+ property: SpaceStyleProperty;
+ element: SVGElement | HTMLElement;
+};
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/value-text.stories.tsx b/apps/designer/app/designer/features/style-panel/sections/space/value-text.stories.tsx
similarity index 93%
rename from apps/designer/app/designer/features/style-panel/sections/spacing/value-text.stories.tsx
rename to apps/designer/app/designer/features/style-panel/sections/space/value-text.stories.tsx
index 46bbb370b4..a2cb600f3f 100644
--- a/apps/designer/app/designer/features/style-panel/sections/spacing/value-text.stories.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/space/value-text.stories.tsx
@@ -1,7 +1,7 @@
import type { ComponentMeta } from "@storybook/react";
import React from "react";
import { parseCssValue } from "../../shared/parse-css-value";
-import { SpacingLayout } from "./layout";
+import { SpaceLayout } from "./layout";
import { ValueText as ValueTextComponent } from "./value-text";
export const ValueText = (
@@ -12,7 +12,7 @@ export const ValueText = (
) => {
const [hovered, setHovered] = React.useState<{ property: string }>();
return (
- <SpacingLayout
+ <SpaceLayout
onHover={setHovered}
onClick={() => null}
renderCell={({ property }) => (
@@ -31,7 +31,7 @@ ValueText.args = {
};
export default {
- title: "Spacing/ValueText",
+ title: "Space/ValueText",
component: ValueText,
argTypes: {
origin: {
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/value-text.tsx b/apps/designer/app/designer/features/style-panel/sections/space/value-text.tsx
similarity index 100%
rename from apps/designer/app/designer/features/style-panel/sections/spacing/value-text.tsx
rename to apps/designer/app/designer/features/style-panel/sections/space/value-text.tsx
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/types.ts b/apps/designer/app/designer/features/style-panel/sections/spacing/types.ts
deleted file mode 100644
index a33cad36e6..0000000000
--- a/apps/designer/app/designer/features/style-panel/sections/spacing/types.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { categories } from "@webstudio-is/react-sdk";
-
-export const spacingPropertiesNames = categories.spacing.properties;
-
-export type SpacingStyleProperty = typeof spacingPropertiesNames[number];
-
-export type HoverTagret = {
- property: SpacingStyleProperty;
- element: SVGElement | HTMLElement;
-};
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 909f799735..488a2bf03d 100644
--- a/apps/designer/app/designer/features/style-panel/style-sections.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-sections.tsx
@@ -15,7 +15,7 @@ import {
LayoutSection,
FlexChildSection,
GridChildSection,
- SpacingSection,
+ SpaceSection,
SizeSection,
PositionSection,
TypographySection,
@@ -126,7 +126,7 @@ const sections: {
layout: LayoutSection,
flexChild: FlexChildSection,
gridChild: GridChildSection,
- spacing: SpacingSection,
+ space: SpaceSection,
size: SizeSection,
position: PositionSection,
typography: TypographySection,
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 5b127756c3..84d7be36a0 100644
--- a/apps/designer/app/designer/features/style-panel/style-settings.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-settings.tsx
@@ -80,8 +80,8 @@ const appliesTo = (
};
const didRender = (category: Category, property: StyleProperty): boolean => {
- // We only want to render the first thing in spacing since the widget will be the way to set all margin and padding
- if (category === "spacing" && property !== categories.spacing.properties[0]) {
+ // We only want to render the first thing in space since the widget will be the way to set all margin and padding
+ if (category === "space" && property !== categories.space.properties[0]) {
return true;
}
return false;
@@ -131,7 +131,7 @@ export const StyleSettings = ({
category,
};
- // @todo remove isRendered once spacing section is converted to a section
+ // @todo remove isRendered once space section is converted to a section
if (isInCategory && isApplicable && isRendered === false) {
// We are making a separate array of properties which come after the "moreFrom"
// so we can make them collapsable
diff --git a/packages/react-sdk/src/css/categories.ts b/packages/react-sdk/src/css/categories.ts
index 7c229b3d9e..6f352e6225 100644
--- a/packages/react-sdk/src/css/categories.ts
+++ b/packages/react-sdk/src/css/categories.ts
@@ -39,7 +39,7 @@ const gridChild = [
"order",
] as const;
-const spacing = [
+const space = [
"marginTop",
"marginRight",
"marginBottom",
@@ -217,7 +217,7 @@ export const categories = {
properties: gridChild,
moreFrom: "",
},
- spacing: { label: "Spacing", properties: spacing, moreFrom: "" },
+ space: { label: "Space", properties: space, moreFrom: "" },
size: { label: "Size", properties: size, moreFrom: "" },
position: { label: "Position", properties: position, moreFrom: "" },
typography: {