Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
skamril committed Sep 20, 2024
1 parent 8ad7209 commit 95167ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function FileTreeItem({ name, treeData, path }: Props) {
const filePath = path ? `${path}/${name}` : name;
const fileType = getFileType(treeData);
const FileIcon = getFileIcon(fileType);
const canExpand = isFolder(treeData) && Object.keys(treeData).length > 0;

////////////////////////////////////////////////////////////////
// Event handlers
Expand All @@ -23,6 +24,7 @@ function FileTreeItem({ name, treeData, path }: Props) {
const handleClick: TreeItemProps["onClick"] = ({ target }) => {
// The item is not selected if the click is on the expand/collapse icon
if (
canExpand &&
target instanceof Element &&
target.closest(".MuiTreeItem-iconContainer")
) {
Expand All @@ -47,9 +49,21 @@ function FileTreeItem({ name, treeData, path }: Props) {
}
onClick={handleClick}
sx={{
// Expand/collapse icon
".MuiTreeItem-iconContainer:hover": {
backgroundColor: "rgb(0 0 0 / 50%)",
".MuiTreeItem-content": {
p: 0,
alignItems: "normal",
// Expand/collapse icon
".MuiTreeItem-iconContainer": {
alignItems: "center",
borderTopLeftRadius: "inherit",
borderBottomLeftRadius: "inherit",
"&:hover": {
background: canExpand ? "inherit" : "none",
},
},
".MuiTreeItem-label": {
py: 0.5,
},
},
}}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { SimpleTreeView } from "@mui/x-tree-view/SimpleTreeView";
import ArrowRightIcon from "@mui/icons-material/ArrowRight";
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
import FileTreeItem from "./FileTreeItem";
import { getParentPaths, type TreeFolder } from "../utils";

Expand Down Expand Up @@ -44,10 +42,6 @@ function Tree(props: Props) {
: expandedItems
}
onExpandedItemsChange={handleExpandedItemsChange}
slots={{
expandIcon: ArrowRightIcon,
collapseIcon: ArrowDropDownIcon,
}}
>
{Object.keys(data).map((filename) => (
<FileTreeItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function Debug() {

return (
<SplitView id="debug" sizes={[15, 85]}>
<Box sx={{ overflow: "auto" }}>
<Box sx={{ px: 1, overflow: "auto" }}>
<UsePromiseCond
response={res}
ifResolved={(data) => (
Expand Down

0 comments on commit 95167ec

Please sign in to comment.