Skip to content

Commit a26c618

Browse files
committed
feat: module based grouping of tools
1 parent a381ffb commit a26c618

File tree

16 files changed

+289
-103
lines changed

16 files changed

+289
-103
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ Devbox is a lightweight, cross-platform desktop application built with Tauri (Ru
2424

2525
- [x] Move tool position
2626
- [x] Quick access icon on menu
27-
- [ ] Grouped tools
27+
- [x] Grouped tools
2828
- [x] Hide/Unhide tools
29-
- [ ] Smart clipboard
3029
- [ ] Dashboard
3130
- [ ] Pin notes
3231
- [ ] Frequently used tools
3332
- [ ] All tools
3433
- [ ] Add Custom RSS Feed (maybe)
35-
- [ ] Quick access tools from menu toolbar (maybe)
34+
- [ ] Smart clipboard
3635
- [ ] Tools shortcut from MAC spotlight (maybe)
3736

3837
### Tools
@@ -79,6 +78,6 @@ Devbox is a lightweight, cross-platform desktop application built with Tauri (Ru
7978
- [ ] Hashing Text
8079
- [ ] Hasing Files
8180
- [ ] Notes
82-
- [ ] World clock
81+
- [ ] Timezone
8382
- [ ] WebSocket Client
8483
- [ ] Mock API Server / Webhook test

src/App.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import classes from "./App.module.css";
2-
import "@mantine/spotlight/styles.css";
31
import "@mantine/dropzone/styles.css";
2+
import "@mantine/spotlight/styles.css";
3+
import classes from "./App.module.css";
44

55
import { Box, Stack } from "@mantine/core";
66
import { Spotlight } from "@mantine/spotlight";
77
import { loader as monacoLoader } from "@monaco-editor/react";
8+
import { relaunch } from "@tauri-apps/plugin-process";
9+
import { check } from "@tauri-apps/plugin-updater";
810
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
9-
import { useLocation, useNavigate } from "react-router-dom";
1011
import {
1112
ImperativePanelHandle,
1213
Panel,
1314
PanelGroup,
1415
PanelResizeHandle,
1516
} from "react-resizable-panels";
16-
import { check } from "@tauri-apps/plugin-updater";
17-
import { relaunch } from "@tauri-apps/plugin-process";
17+
import { useLocation, useNavigate } from "react-router-dom";
1818

19-
import { Sidebar } from "./Components/Sidebar";
2019
import { BsSearch } from "react-icons/bs";
21-
import { useRouteTransition } from "./hooks/useRouteAnim";
22-
import { useKeyboardShortcuts } from "./hooks/useKeyboardShortcuts";
23-
import { insertTauriDragRegion } from "./utils/dragRegion";
24-
import { APP_CONFIG } from "./constants/app";
2520
import { AppRoutes } from "./Components/AppRoutes";
21+
import { Sidebar } from "./Components/Sidebar";
22+
import { APP_CONFIG } from "./constants/app";
2623
import { sidebarTools } from "./constants/sidebar";
24+
import { useKeyboardShortcuts } from "./hooks/useKeyboardShortcuts";
25+
import { useRouteTransition } from "./hooks/useRouteAnim";
26+
import { insertTauriDragRegion } from "./utils/dragRegion";
2727

2828
const PANEL_CONFIG = APP_CONFIG.PANEL;
2929

src/Components/Settings.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
55

66
export interface SidebarConfig {
77
showDescription: boolean;
8+
showModules: boolean;
89
hiddenTools: string[];
910
}
1011

@@ -13,6 +14,7 @@ export default function Settings() {
1314
key: "sidebarConfig",
1415
defaultValue: {
1516
showDescription: false,
17+
showModules: true,
1618
hiddenTools: [],
1719
},
1820
});
@@ -27,6 +29,11 @@ export default function Settings() {
2729
setSidebarConfig(newConfig);
2830
};
2931

32+
const handleToggleModules = async (checked: boolean) => {
33+
const newConfig = { ...sidebarConfig, showModules: checked };
34+
setSidebarConfig(newConfig);
35+
};
36+
3037
const handleToolVisibility = async (toolId: string, checked: boolean) => {
3138
let updatedHidden: string[];
3239
if (!checked) {
@@ -57,6 +64,11 @@ export default function Settings() {
5764
checked={!!sidebarConfig.showDescription}
5865
onChange={e => handleToggle(e.currentTarget.checked)}
5966
/>
67+
<Switch
68+
label="Group tools by module"
69+
checked={!!sidebarConfig.showModules}
70+
onChange={e => handleToggleModules(e.currentTarget.checked)}
71+
/>
6072

6173
{/* Manage Tools */}
6274
<Stack gap="xs" mt="md">

src/Components/Sidebar/Tool.tsx

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { Box, Text, useMantineTheme } from "@mantine/core";
2+
import cx from "clsx";
3+
4+
import { SidebarTool } from "./types";
5+
6+
import { cloneElement, ReactElement } from "react";
7+
import { useLocation } from "react-router-dom";
8+
import { SIDEBAR_CONSTANTS } from "./constants";
9+
import classes from "./styles.module.css";
10+
11+
type ToolProps = {
12+
tool: SidebarTool;
13+
handleNavigation: (to: string) => void;
14+
showDescription: boolean;
15+
};
16+
17+
const Tool = ({ tool, showDescription, handleNavigation }: ToolProps) => {
18+
const location = useLocation();
19+
const theme = useMantineTheme();
20+
21+
return (
22+
<Box
23+
key={tool.id}
24+
className={cx(classes.navigationItem, {
25+
[classes.selectedNavigationItem]: location.pathname === tool.to,
26+
})}
27+
mt={SIDEBAR_CONSTANTS.SPACING.ITEM_MARGIN_TOP}
28+
onClick={() => handleNavigation(tool.to)}
29+
>
30+
<Box className={classes.itemContent} w="100%">
31+
{cloneElement(tool.icon as ReactElement, {
32+
size: SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM,
33+
background: theme.colors?.blue[5],
34+
flex: 1,
35+
style: { minWidth: SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM },
36+
})}
37+
<Box w="80%">
38+
<Text size="xs" fw={location.pathname === tool.to ? "600" : "400"}>
39+
{tool.text}
40+
</Text>
41+
{showDescription && tool.description && (
42+
<Text
43+
size="11px"
44+
c="dimmed"
45+
mt={2}
46+
w="100%"
47+
styles={{
48+
root: {
49+
whiteSpace: "nowrap",
50+
overflow: "hidden",
51+
textOverflow: "ellipsis",
52+
},
53+
}}
54+
>
55+
{tool.description}
56+
</Text>
57+
)}
58+
</Box>
59+
</Box>
60+
</Box>
61+
);
62+
};
63+
64+
export default Tool;

src/Components/Sidebar/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const SIDEBAR_CONSTANTS = {
55
LARGE: 20,
66
},
77
SPACING: {
8-
ITEM_MARGIN_TOP: 2,
8+
ITEM_MARGIN_TOP: 6,
99
},
1010
SCROLL_BEHAVIOR: {
1111
BLOCK: "center" as const,

0 commit comments

Comments
 (0)