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.

feat: Sticky actions in navigator (#4818)

Oleg Isonena9180f7c4a48
diff --git a/packages/design-system/src/components/tree.tsx b/packages/design-system/src/components/tree.tsx
index 95e5d65bf8..aa15583c0f 100644
--- a/packages/design-system/src/components/tree.tsx
+++ b/packages/design-system/src/components/tree.tsx
@@ -29,6 +29,7 @@ import { TreePositionIndicator } from "./list-position-indicator";
const treeNodeLevel = "--tree-node-level";
const treeNodeOutline = "--tree-node-outline";
+const treeNodeBackgroundColor = "--tree-node-background-color";
const treeActionOpacity = "--tree-action-opacity";
const treeDepthBarsVisibility = "--tree-depth-bars-visibility";
const treeDepthBarsColor = "--tree-depth-bars-color";
@@ -39,7 +40,6 @@ const ITEM_PADDING_LEFT = 8;
const ITEM_PADDING_RIGHT = 10;
const BARS_GAP = 16;
const EXPAND_WIDTH = 24;
-const ACTION_WIDTH = 24;
const TreeContainer = ({ children }: { children: ReactNode }) => {
const focusManager = useFocusManager();
@@ -97,16 +97,15 @@ const NodeContainer = styled("div", {
position: "relative",
height: ITEM_HEIGHT,
"&:hover, &:has(:focus-visible), &:has([aria-current=true])": {
- backgroundColor: theme.colors.backgroundHover,
+ [treeNodeBackgroundColor]: theme.colors.backgroundHover,
+ backgroundColor: `var(${treeNodeBackgroundColor})`,
[treeActionOpacity]: 1,
},
"&:has([aria-selected=true])": {
- backgroundColor: theme.colors.backgroundItemCurrent,
+ [treeNodeBackgroundColor]: theme.colors.backgroundItemCurrent,
+ backgroundColor: `var(${treeNodeBackgroundColor})`,
[treeDepthBarsColor]: theme.colors.borderItemChildLineCurrent,
},
- "&:has([data-tree-action])": {
- paddingRight: ACTION_WIDTH,
- },
});
const DepthBars = styled("div", {
@@ -157,14 +156,16 @@ const ActionContainer = styled("div", {
// use opacity to hide action instead of visibility
// to prevent focus loss while navigating with keyboard
opacity: `var(${treeActionOpacity}, 0)`,
- position: "absolute",
- top: 0,
- right: ITEM_PADDING_RIGHT,
- width: ACTION_WIDTH,
+ position: "sticky",
+ translate: `calc(${theme.sizes.sidebarWidth} - 100%) -100%`,
+ paddingLeft: ITEM_PADDING_LEFT,
+ paddingRight: ITEM_PADDING_RIGHT,
+ left: 0,
height: "inherit",
- display: "flex",
+ display: "inline-flex",
justifyContent: "center",
alignItems: "center",
+ backgroundColor: `var(${treeNodeBackgroundColor})`,
});
const DropIndicator = ({