Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions packages/design-system/src/components/tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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();
Expand Down Expand Up @@ -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", {
Expand Down Expand Up @@ -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 = ({
Expand Down