Skip to content

Commit c4e62b2

Browse files
committed
updated modules with description
1 parent a26c618 commit c4e62b2

File tree

5 files changed

+136
-52
lines changed

5 files changed

+136
-52
lines changed

src/Components/Sidebar/Tool.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ type ToolProps = {
1212
tool: SidebarTool;
1313
handleNavigation: (to: string) => void;
1414
showDescription: boolean;
15+
isModule?: boolean;
1516
};
1617

17-
const Tool = ({ tool, showDescription, handleNavigation }: ToolProps) => {
18+
const Tool = ({ tool, showDescription, handleNavigation, isModule }: ToolProps) => {
1819
const location = useLocation();
1920
const theme = useMantineTheme();
2021

@@ -26,13 +27,18 @@ const Tool = ({ tool, showDescription, handleNavigation }: ToolProps) => {
2627
})}
2728
mt={SIDEBAR_CONSTANTS.SPACING.ITEM_MARGIN_TOP}
2829
onClick={() => handleNavigation(tool.to)}
30+
title={tool.description}
2931
>
3032
<Box className={classes.itemContent} w="100%">
3133
{cloneElement(tool.icon as ReactElement, {
32-
size: SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM,
34+
size: isModule ? SIDEBAR_CONSTANTS.ICON_SIZE.SMALL : SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM,
3335
background: theme.colors?.blue[5],
3436
flex: 1,
35-
style: { minWidth: SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM },
37+
style: {
38+
minWidth: isModule
39+
? SIDEBAR_CONSTANTS.ICON_SIZE.SMALL
40+
: SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM,
41+
},
3642
})}
3743
<Box w="80%">
3844
<Text size="xs" fw={location.pathname === tool.to ? "600" : "400"}>

src/Components/Sidebar/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const SIDEBAR_CONSTANTS = {
22
ICON_SIZE: {
3-
SMALL: 16,
3+
SMALL: 15,
44
MEDIUM: 18,
55
LARGE: 20,
66
},

src/Components/Sidebar/index.tsx

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import cx from "clsx";
1515
import { useLocation, useNavigate } from "react-router-dom";
1616
import classes from "./styles.module.css";
1717

18-
import { moduleIcons } from "@/constants/tools";
18+
import { moduleRegistry, ToolModule } from "@/constants/tools";
1919
import { useSidebarShortcuts } from "@/hooks/useSidebarShortcuts";
2020
import { useSidebarState } from "@/hooks/useSidebarState";
2121
import { DragDropContext, Draggable, Droppable, OnDragEndResponder } from "@hello-pangea/dnd";
@@ -162,44 +162,63 @@ export const Sidebar = ({ collapsed, setCollapsed }: Props) => {
162162
item: classes.accordionItem,
163163
content: classes.accordionContent,
164164
}}
165-
defaultValue={"Encoders / Decoders"}
165+
defaultValue={"Network"}
166166
>
167-
{sidebarTools
168-
.reduce((acc, tool) => {
169-
if (!acc.find(t => t === tool.module)) {
170-
acc.push(tool.module);
171-
}
172-
return acc;
173-
}, [] as string[])
174-
.filter(module => module !== "")
167+
{Object.values(moduleRegistry)
168+
.sort((a: ToolModule, b: ToolModule) => a.order - b.order)
169+
.filter(module => sidebarTools.find(tool => tool.module === module.id))
175170
.map(module => (
176-
<Accordion.Item key={module} value={module}>
171+
<Accordion.Item key={module.id} value={module.id}>
177172
<Accordion.Control>
178-
<Group wrap="nowrap" style={{ whiteSpace: "nowrap" }} gap={8}>
179-
{cloneElement(moduleIcons[module] as ReactElement, {
173+
<Group
174+
wrap="nowrap"
175+
style={{ whiteSpace: "nowrap" }}
176+
gap={8}
177+
title={module.description}
178+
>
179+
{cloneElement(module.icon as ReactElement, {
180180
size: SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM,
181181
flex: 1,
182182
style: {
183183
minWidth: SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM,
184184
marginRight: 1,
185185
},
186186
})}
187-
<Text size="13px" fw="500">
188-
{module}
189-
</Text>
187+
<Group gap={8} w="95%">
188+
<Text size="12px" fw="500">
189+
{module.name}
190+
</Text>
191+
{showDescription && (
192+
<Text
193+
size="11px"
194+
c="dimmed"
195+
w="80%"
196+
styles={{
197+
root: {
198+
whiteSpace: "nowrap",
199+
overflow: "hidden",
200+
textOverflow: "ellipsis",
201+
},
202+
}}
203+
>
204+
{module.description}
205+
</Text>
206+
)}
207+
</Group>
190208
</Group>
191209
</Accordion.Control>
192210
<Accordion.Panel>
193211
<Box>
194212
{sidebarTools
195-
.filter(t => t.module === module)
213+
.filter(t => t.module === module.id)
196214
.filter(t => !hiddenTools.includes(t.id))
197215
.map(tool => (
198216
<Tool
199217
key={tool.id}
200218
tool={tool}
201219
showDescription={showDescription}
202220
handleNavigation={handleNavigation}
221+
isModule
203222
/>
204223
))}
205224
</Box>
@@ -227,7 +246,6 @@ export const Sidebar = ({ collapsed, setCollapsed }: Props) => {
227246
...provided.draggableProps.style,
228247
userSelect: "none",
229248
}}
230-
title={tool.description}
231249
>
232250
<Tool
233251
tool={tool}

src/Components/Sidebar/styles.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@
128128
background-color: light-dark(var(--mantine-color-gray-2), var(--mantine-color-dark-5));
129129
}
130130

131-
132131
.accordionItem {
133132
z-index: 0;
134133
transition: transform 150ms ease;

0 commit comments

Comments
 (0)