Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ Devbox is a lightweight, cross-platform desktop application built with Tauri (Ru

- [x] Move tool position
- [x] Quick access icon on menu
- [ ] Grouped tools
- [x] Grouped tools
- [x] Hide/Unhide tools
- [ ] Smart clipboard
- [ ] Dashboard
- [ ] Pin notes
- [ ] Frequently used tools
- [ ] All tools
- [ ] Add Custom RSS Feed (maybe)
- [ ] Quick access tools from menu toolbar (maybe)
- [ ] Smart clipboard
- [ ] Tools shortcut from MAC spotlight (maybe)

### Tools
Expand Down Expand Up @@ -79,6 +78,6 @@ Devbox is a lightweight, cross-platform desktop application built with Tauri (Ru
- [ ] Hashing Text
- [ ] Hasing Files
- [ ] Notes
- [ ] World clock
- [ ] Timezone
- [ ] WebSocket Client
- [ ] Mock API Server / Webhook test
20 changes: 10 additions & 10 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import classes from "./App.module.css";
import "@mantine/spotlight/styles.css";
import "@mantine/dropzone/styles.css";
import "@mantine/spotlight/styles.css";
import classes from "./App.module.css";

import { Box, Stack } from "@mantine/core";
import { Spotlight } from "@mantine/spotlight";
import { loader as monacoLoader } from "@monaco-editor/react";
import { relaunch } from "@tauri-apps/plugin-process";
import { check } from "@tauri-apps/plugin-updater";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import {
ImperativePanelHandle,
Panel,
PanelGroup,
PanelResizeHandle,
} from "react-resizable-panels";
import { check } from "@tauri-apps/plugin-updater";
import { relaunch } from "@tauri-apps/plugin-process";
import { useLocation, useNavigate } from "react-router-dom";

import { Sidebar } from "./Components/Sidebar";
import { BsSearch } from "react-icons/bs";
import { useRouteTransition } from "./hooks/useRouteAnim";
import { useKeyboardShortcuts } from "./hooks/useKeyboardShortcuts";
import { insertTauriDragRegion } from "./utils/dragRegion";
import { APP_CONFIG } from "./constants/app";
import { AppRoutes } from "./Components/AppRoutes";
import { Sidebar } from "./Components/Sidebar";
import { APP_CONFIG } from "./constants/app";
import { sidebarTools } from "./constants/sidebar";
import { useKeyboardShortcuts } from "./hooks/useKeyboardShortcuts";
import { useRouteTransition } from "./hooks/useRouteAnim";
import { insertTauriDragRegion } from "./utils/dragRegion";

const PANEL_CONFIG = APP_CONFIG.PANEL;

Expand Down
12 changes: 12 additions & 0 deletions src/Components/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useEffect, useState } from "react";

export interface SidebarConfig {
showDescription: boolean;
showModules: boolean;
hiddenTools: string[];
}

Expand All @@ -13,6 +14,7 @@ export default function Settings() {
key: "sidebarConfig",
defaultValue: {
showDescription: false,
showModules: true,
hiddenTools: [],
},
});
Expand All @@ -27,6 +29,11 @@ export default function Settings() {
setSidebarConfig(newConfig);
};

const handleToggleModules = async (checked: boolean) => {
const newConfig = { ...sidebarConfig, showModules: checked };
setSidebarConfig(newConfig);
};

const handleToolVisibility = async (toolId: string, checked: boolean) => {
let updatedHidden: string[];
if (!checked) {
Expand Down Expand Up @@ -57,6 +64,11 @@ export default function Settings() {
checked={!!sidebarConfig.showDescription}
onChange={e => handleToggle(e.currentTarget.checked)}
/>
<Switch
label="Group tools by module"
checked={!!sidebarConfig.showModules}
onChange={e => handleToggleModules(e.currentTarget.checked)}
/>

{/* Manage Tools */}
<Stack gap="xs" mt="md">
Expand Down
70 changes: 70 additions & 0 deletions src/Components/Sidebar/Tool.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Box, Text, useMantineTheme } from "@mantine/core";
import cx from "clsx";

import { SidebarTool } from "./types";

import { cloneElement, ReactElement } from "react";
import { useLocation } from "react-router-dom";
import { SIDEBAR_CONSTANTS } from "./constants";
import classes from "./styles.module.css";

type ToolProps = {
tool: SidebarTool;
handleNavigation: (to: string) => void;
showDescription: boolean;
isModule?: boolean;
};

const Tool = ({ tool, showDescription, handleNavigation, isModule }: ToolProps) => {
const location = useLocation();
const theme = useMantineTheme();

return (
<Box
key={tool.id}
className={cx(classes.navigationItem, {
[classes.selectedNavigationItem]: location.pathname === tool.to,
})}
mt={SIDEBAR_CONSTANTS.SPACING.ITEM_MARGIN_TOP}
onClick={() => handleNavigation(tool.to)}
title={tool.description}
>
<Box className={classes.itemContent} w="100%">
{cloneElement(tool.icon as ReactElement, {
size: isModule ? SIDEBAR_CONSTANTS.ICON_SIZE.SMALL : SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM,
background: theme.colors?.blue[5],
flex: 1,
style: {
minWidth: isModule
? SIDEBAR_CONSTANTS.ICON_SIZE.SMALL
: SIDEBAR_CONSTANTS.ICON_SIZE.MEDIUM,
},
})}
<Box w="80%">
<Text size="xs" fw={location.pathname === tool.to ? "600" : "400"}>
{tool.text}
</Text>
{showDescription && tool.description && (
<Text
size="11px"
c="dimmed"
mt={2}
w="100%"
styles={{
root: {
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
},
}}
>
{tool.description}
</Text>
)}
</Box>
</Box>
</Box>
);
};

export default Tool;
4 changes: 2 additions & 2 deletions src/Components/Sidebar/constants.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export const SIDEBAR_CONSTANTS = {
ICON_SIZE: {
SMALL: 16,
SMALL: 15,
MEDIUM: 18,
LARGE: 20,
},
SPACING: {
ITEM_MARGIN_TOP: 2,
ITEM_MARGIN_TOP: 6,
},
SCROLL_BEHAVIOR: {
BLOCK: "center" as const,
Expand Down
Loading