Skip to content

Commit

Permalink
Add classname to identify expanded or collapsed nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraggle committed Sep 4, 2024
1 parent c302190 commit fb05e3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions sparkle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dust-tt/sparkle",
"version": "0.2.221",
"version": "0.2.222",
"scripts": {
"build": "rm -rf dist && npm run tailwind && npm run build:esm && npm run build:cjs",
"tailwind": "tailwindcss -i ./src/styles/tailwind.css -o dist/sparkle.css",
Expand Down Expand Up @@ -98,4 +98,4 @@
"tailwind-scrollbar-hide": "^1.1.7"
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
}
12 changes: 6 additions & 6 deletions sparkle/src/components/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ Tree.Item = function ({
isNavigatableSelected: "s-border-structure-200 s-bg-white",
};

const isExpanded = childrenToRender && !effectiveCollapsed;

return (
<>
<div
Expand All @@ -157,17 +159,15 @@ Tree.Item = function ({
? isSelected
? treeItemStyleClasses.isNavigatableSelected
: treeItemStyleClasses.isNavigatableUnselected
: ""
: "",
isExpanded ? "is-expanded" : "is-collapsed",
type
)}
onClick={onItemClick ? onItemClick : undefined}
>
{type === "node" && (
<IconButton
icon={
childrenToRender && !effectiveCollapsed
? ArrowDownSIcon
: ArrowRightSIcon
}
icon={isExpanded ? ArrowDownSIcon : ArrowRightSIcon}
size="xs"
variant="secondary"
onClick={(e) => {
Expand Down

0 comments on commit fb05e3a

Please sign in to comment.