-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: modularized categories (#3615)
Modularized category and fixed Discover More not appearing
- Loading branch information
1 parent
af05228
commit cb1a2f2
Showing
4 changed files
with
132 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...nd/src/pages/FlowPage/components/extraSidebarComponent/SidebarCategoryComponent/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import ShadTooltip from "@/components/shadTooltipComponent"; | ||
import { nodeColors, nodeIconsLucide, nodeNames } from "@/utils/styleUtils"; | ||
import { removeCountFromString } from "@/utils/utils"; | ||
import { Fragment } from "react/jsx-runtime"; | ||
import DisclosureComponent from "../../DisclosureComponent"; | ||
import SidebarDraggableComponent from "../sideBarDraggableComponent"; | ||
import sensitiveSort from "../utils/sensitive-sort"; | ||
|
||
export function SidebarCategoryComponent({ | ||
index, | ||
search, | ||
getFilterEdge, | ||
category, | ||
name, | ||
onDragStart, | ||
}) { | ||
return ( | ||
<Fragment | ||
key={`DisclosureComponent${index + search + JSON.stringify(getFilterEdge)}`} | ||
> | ||
<DisclosureComponent | ||
isChild={false} | ||
defaultOpen={ | ||
getFilterEdge.length !== 0 || search.length !== 0 ? true : false | ||
} | ||
button={{ | ||
title: nodeNames[name] ?? nodeNames.unknown, | ||
Icon: nodeIconsLucide[name] ?? nodeIconsLucide.unknown, | ||
}} | ||
> | ||
<div className="side-bar-components-gap"> | ||
{Object.keys(category) | ||
.sort((a, b) => | ||
sensitiveSort(category[a].display_name, category[b].display_name), | ||
) | ||
.map((SBItemName: string, index) => ( | ||
<ShadTooltip | ||
content={category[SBItemName].display_name} | ||
side="right" | ||
key={index} | ||
> | ||
<SidebarDraggableComponent | ||
sectionName={name as string} | ||
apiClass={category[SBItemName]} | ||
key={index} | ||
onDragStart={(event) => | ||
onDragStart(event, { | ||
//split type to remove type in nodes saved with same name removing it's | ||
type: removeCountFromString(SBItemName), | ||
node: category[SBItemName], | ||
}) | ||
} | ||
color={nodeColors[name]} | ||
itemName={SBItemName} | ||
//convert error to boolean | ||
error={!!category[SBItemName].error} | ||
display_name={category[SBItemName].display_name} | ||
official={ | ||
category[SBItemName].official === false ? false : true | ||
} | ||
/> | ||
</ShadTooltip> | ||
))} | ||
</div> | ||
</DisclosureComponent> | ||
</Fragment> | ||
); | ||
} |
Oops, something went wrong.