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.

fixes

Roman Pominovffdb590c3032
diff --git a/apps/designer/app/designer/shared/tree/sortable-tree.tsx b/apps/designer/app/designer/shared/tree/sortable-tree.tsx
index 8936007b9a..b39ce40438 100644
--- a/apps/designer/app/designer/shared/tree/sortable-tree.tsx
+++ b/apps/designer/app/designer/shared/tree/sortable-tree.tsx
@@ -19,7 +19,12 @@ import {
getInstancePathWithPositions,
} from "~/shared/tree-utils";
import { createPortal } from "react-dom";
-import { TreeNode, getIsExpandable } from "./tree-node";
+import {
+ TreeNode,
+ getIsExpandable,
+ getPlacementIndicatorAlignment,
+ INDENT,
+} from "./tree-node";
import { useExpandState, type TreeProps } from "./tree";
import { CSSProperties } from "@stitches/react";
@@ -98,8 +103,7 @@ export const SortableTree = ({
const desiredDepth = dragItemDepth + horizontalShift;
const shiftLine = (depth: number) => {
- // @todo: fix magic numbers
- const shift = depth * 15 + 15;
+ const shift = getPlacementIndicatorAlignment(depth);
return {
...placement,
x: placement.x + shift,
@@ -272,8 +276,7 @@ export const SortableTree = ({
});
const dragHandlers = useDrag<Instance>({
- // @todo: fix magic number
- shiftDistanceThreshold: 15,
+ shiftDistanceThreshold: INDENT,
elementToData: (element) => {
const dragItemElement = element.closest("[data-drag-item-id]");
@@ -381,32 +384,43 @@ export const SortableTree = ({
);
};
+// @todo: if we decide to keep this color, we need to add it to design-system
+const PLACEMENT_INDICATOR_COLOR = "#f531b3";
+
const PlacementIndicatorLine = ({ line }: { line: Placement }) => {
+ const circleSize = 8;
+ const lineHeight = 2;
+
+ // overlap the line with the circle by this much
+ // to make sure they are connected
+ const ovelap = 1;
+
+ // The goal is to put center of the circle at line.x/y
+
return (
<Box
style={{
- // @todo: fix magic numbers
- top: line.y - 1,
- left: line.x + 4,
- width: line.length - 4,
- height: 2,
+ top: line.y - lineHeight / 2,
+ left: line.x + (circleSize / 2 - ovelap),
+ width: line.length - (circleSize / 2 - ovelap),
+ height: lineHeight,
}}
css={{
boxSizing: "content-box",
position: "absolute",
- background: "#f531b3",
+ background: PLACEMENT_INDICATOR_COLOR,
pointerEvents: "none",
}}
>
<Box
css={{
- // @todo: fix magic numbers
- width: 8,
- height: 8,
- top: -3,
- left: -7,
+ width: circleSize,
+ height: circleSize,
+ top: (lineHeight - circleSize) / 2,
+ left: ovelap - circleSize,
position: "absolute",
- border: "solid 2px #f531b3",
+ border: `solid ${PLACEMENT_INDICATOR_COLOR}`,
+ borderWidth: "$2",
borderRadius: "50%",
}}
/>
@@ -427,8 +441,8 @@ const PlacementIndicatorOutline = ({ rect }: { rect: Rect }) => {
position: "absolute",
pointerEvents: "none",
boxSizing: "border-box",
- // @todo: add color to theme
- border: "2px solid #f531b3",
+ border: `solid ${PLACEMENT_INDICATOR_COLOR}`,
+ borderWidth: "$2",
borderRadius: "$2",
}}
/>
diff --git a/apps/designer/app/designer/shared/tree/tree-node.tsx b/apps/designer/app/designer/shared/tree/tree-node.tsx
index 798b7dfb02..7c0a2dd78f 100644
--- a/apps/designer/app/designer/shared/tree/tree-node.tsx
+++ b/apps/designer/app/designer/shared/tree/tree-node.tsx
@@ -14,6 +14,11 @@ import noop from "lodash.noop";
export const INDENT = 16;
const ITEM_HEIGHT = 32;
const ICONS_SIZE = 15;
+const ITEM_PADDING = 8;
+
+export const getPlacementIndicatorAlignment = (depth: number) => {
+ return depth * INDENT + ITEM_PADDING;
+};
export const getIsExpandable = (instance: Instance) => {
return (
@@ -41,12 +46,13 @@ const CustomButton = styled("button", {
content: "''",
display: "block",
position: "absolute",
- top: 0,
left: 2,
right: 2,
+ top: 0,
bottom: 0,
boxSizing: "border-box",
- border: "2px solid $blue10",
+ border: "solid $blue10",
+ borderWidth: "$2",
borderRadius: "$2",
pointerEvents: "none",
},
@@ -58,7 +64,8 @@ const CustomButton = styled("button", {
const nestingLineStyles = {
width: Math.ceil(INDENT / 2),
height: ITEM_HEIGHT,
- borderRight: "1px solid",
+ borderRight: "solid",
+ borderRightWidth: "$1",
borderColor: "$slate9",
};
const nestingLineStylesSelected = {
@@ -199,8 +206,8 @@ export const TreeNode = forwardRef<HTMLDivElement, TreeNodeProps>(
css={{
color: isSelected ? "$loContrast" : "$hiContrast",
alignItems: "center",
- pr: "$2",
- pl: "$2",
+ pr: ITEM_PADDING,
+ pl: ITEM_PADDING,
backgroundColor: isSelected
? "$blue10"
: parentIsSelected
diff --git a/packages/design-system/src/stitches.config.ts b/packages/design-system/src/stitches.config.ts
index 170d76ae6c..5445d8e422 100644
--- a/packages/design-system/src/stitches.config.ts
+++ b/packages/design-system/src/stitches.config.ts
@@ -257,6 +257,10 @@ export const {
4: "400",
max: "999",
},
+ borderWidths: {
+ 1: "1px",
+ 2: "2px",
+ },
},
media: {
bp1: "(min-width: 520px)",