Skip to content

Commit a9180f7

Browse files
authored
feat: Sticky actions in navigator (#4818)
## Description https://share.descript.com/view/spOG60yRmmg Actions in navigator now always visible even when horizontal scroll is involved ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent af5d61d commit a9180f7

File tree

1 file changed

+12
-11
lines changed
  • packages/design-system/src/components

1 file changed

+12
-11
lines changed

packages/design-system/src/components/tree.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { TreePositionIndicator } from "./list-position-indicator";
2929

3030
const treeNodeLevel = "--tree-node-level";
3131
const treeNodeOutline = "--tree-node-outline";
32+
const treeNodeBackgroundColor = "--tree-node-background-color";
3233
const treeActionOpacity = "--tree-action-opacity";
3334
const treeDepthBarsVisibility = "--tree-depth-bars-visibility";
3435
const treeDepthBarsColor = "--tree-depth-bars-color";
@@ -39,7 +40,6 @@ const ITEM_PADDING_LEFT = 8;
3940
const ITEM_PADDING_RIGHT = 10;
4041
const BARS_GAP = 16;
4142
const EXPAND_WIDTH = 24;
42-
const ACTION_WIDTH = 24;
4343

4444
const TreeContainer = ({ children }: { children: ReactNode }) => {
4545
const focusManager = useFocusManager();
@@ -97,16 +97,15 @@ const NodeContainer = styled("div", {
9797
position: "relative",
9898
height: ITEM_HEIGHT,
9999
"&:hover, &:has(:focus-visible), &:has([aria-current=true])": {
100-
backgroundColor: theme.colors.backgroundHover,
100+
[treeNodeBackgroundColor]: theme.colors.backgroundHover,
101+
backgroundColor: `var(${treeNodeBackgroundColor})`,
101102
[treeActionOpacity]: 1,
102103
},
103104
"&:has([aria-selected=true])": {
104-
backgroundColor: theme.colors.backgroundItemCurrent,
105+
[treeNodeBackgroundColor]: theme.colors.backgroundItemCurrent,
106+
backgroundColor: `var(${treeNodeBackgroundColor})`,
105107
[treeDepthBarsColor]: theme.colors.borderItemChildLineCurrent,
106108
},
107-
"&:has([data-tree-action])": {
108-
paddingRight: ACTION_WIDTH,
109-
},
110109
});
111110

112111
const DepthBars = styled("div", {
@@ -157,14 +156,16 @@ const ActionContainer = styled("div", {
157156
// use opacity to hide action instead of visibility
158157
// to prevent focus loss while navigating with keyboard
159158
opacity: `var(${treeActionOpacity}, 0)`,
160-
position: "absolute",
161-
top: 0,
162-
right: ITEM_PADDING_RIGHT,
163-
width: ACTION_WIDTH,
159+
position: "sticky",
160+
translate: `calc(${theme.sizes.sidebarWidth} - 100%) -100%`,
161+
paddingLeft: ITEM_PADDING_LEFT,
162+
paddingRight: ITEM_PADDING_RIGHT,
163+
left: 0,
164164
height: "inherit",
165-
display: "flex",
165+
display: "inline-flex",
166166
justifyContent: "center",
167167
alignItems: "center",
168+
backgroundColor: `var(${treeNodeBackgroundColor})`,
168169
});
169170

170171
const DropIndicator = ({

0 commit comments

Comments
 (0)