Skip to content

Commit 7e42ce1

Browse files
authored
Merge pull request #7 from smithg09/module-based-grouping
Module Based Grouping
2 parents a381ffb + c4e62b2 commit 7e42ce1

File tree

16 files changed

+375
-105
lines changed

16 files changed

+375
-105
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: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
isModule?: boolean;
16+
};
17+
18+
const Tool = ({ tool, showDescription, handleNavigation, isModule }: ToolProps) => {
19+
const location = useLocation();
20+
const theme = useMantineTheme();
21+
22+
return (
23+
<Box
24+
key={tool.id}
25+
className={cx(classes.navigationItem, {
26+
[classes.selectedNavigationItem]: location.pathname === tool.to,
27+
})}
28+
mt={SIDEBAR_CONSTANTS.SPACING.ITEM_MARGIN_TOP}
29+
onClick={() => handleNavigation(tool.to)}
30+
title={tool.description}
31+
>
32+
<Box className={classes.itemContent} w="100%">
33+
{cloneElement(tool.icon as ReactElement, {
34+
size: isModule ? SIDEBAR_CONSTANTS.ICON_SIZE.SMALL : SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM,
35+
background: theme.colors?.blue[5],
36+
flex: 1,
37+
style: {
38+
minWidth: isModule
39+
? SIDEBAR_CONSTANTS.ICON_SIZE.SMALL
40+
: SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM,
41+
},
42+
})}
43+
<Box w="80%">
44+
<Text size="xs" fw={location.pathname === tool.to ? "600" : "400"}>
45+
{tool.text}
46+
</Text>
47+
{showDescription && tool.description && (
48+
<Text
49+
size="11px"
50+
c="dimmed"
51+
mt={2}
52+
w="100%"
53+
styles={{
54+
root: {
55+
whiteSpace: "nowrap",
56+
overflow: "hidden",
57+
textOverflow: "ellipsis",
58+
},
59+
}}
60+
>
61+
{tool.description}
62+
</Text>
63+
)}
64+
</Box>
65+
</Box>
66+
</Box>
67+
);
68+
};
69+
70+
export default Tool;

src/Components/Sidebar/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export const SIDEBAR_CONSTANTS = {
22
ICON_SIZE: {
3-
SMALL: 16,
3+
SMALL: 15,
44
MEDIUM: 18,
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)