Skip to content

Commit fc51e7c

Browse files
authored
feat: group by project/chronological sort improvements (#821)
1 parent 99a3aea commit fc51e7c

10 files changed

Lines changed: 627 additions & 629 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { useSortable } from "@dnd-kit/react/sortable";
2+
import type { ReactNode } from "react";
3+
4+
interface DraggableFolderProps {
5+
id: string;
6+
index: number;
7+
children: ReactNode;
8+
}
9+
10+
export function DraggableFolder({ id, index, children }: DraggableFolderProps) {
11+
const { ref, isDragging } = useSortable({
12+
id,
13+
index,
14+
group: "sidebar-folders",
15+
transition: {
16+
duration: 200,
17+
easing: "ease",
18+
},
19+
});
20+
21+
return (
22+
<div
23+
ref={ref}
24+
style={{
25+
opacity: isDragging ? 0.5 : 1,
26+
cursor: isDragging ? "grabbing" : undefined,
27+
}}
28+
>
29+
{children}
30+
</div>
31+
);
32+
}

apps/twig/src/renderer/features/sidebar/components/HistoryView.tsx

Lines changed: 0 additions & 194 deletions
This file was deleted.

apps/twig/src/renderer/features/sidebar/components/SidebarItem.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function SidebarItem({
3030
className="group focus-visible:-outline-offset-2 flex w-full cursor-pointer items-start bg-transparent px-2 py-1.5 text-left font-mono text-[12px] text-gray-11 transition-colors hover:bg-gray-3 focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent-8 data-[active]:bg-accent-4 data-[active]:text-gray-12"
3131
data-active={isActive || undefined}
3232
style={{
33-
paddingLeft: `${depth * INDENT_SIZE + 8}px`,
33+
paddingLeft: `${depth * INDENT_SIZE + 8 + (depth > 0 ? 4 : 0)}px`,
3434
gap: "4px",
3535
}}
3636
onClick={onClick}
@@ -39,14 +39,18 @@ export function SidebarItem({
3939
{icon && (
4040
<span
4141
className="flex shrink-0 items-center text-gray-10 group-data-[active]:text-gray-11"
42-
style={{ height: "18px" }}
42+
style={{
43+
height: "18px",
44+
width: "18px",
45+
justifyContent: "center",
46+
}}
4347
>
4448
{icon}
4549
</span>
4650
)}
4751
<span className="flex min-w-0 flex-1 flex-col overflow-hidden">
4852
<span className="flex items-center gap-1" style={{ height: "18px" }}>
49-
<span className="min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap">
53+
<span className="min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-gray-12">
5054
{label}
5155
</span>
5256
{endContent}

apps/twig/src/renderer/features/sidebar/components/SidebarMenu.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { DotsCircleSpinner } from "@components/DotsCircleSpinner";
22
import { RenameTaskDialog } from "@components/RenameTaskDialog";
33
import { useDeleteTask, useTasks } from "@features/tasks/hooks/useTasks";
4-
import { useTaskStore } from "@features/tasks/stores/taskStore";
5-
import { useMeQuery } from "@hooks/useMeQuery";
64
import { useTaskContextMenu } from "@hooks/useTaskContextMenu";
75
import { Box, Flex } from "@radix-ui/themes";
86
import type { Task } from "@shared/types";
@@ -12,15 +10,13 @@ import { useWorkspaceStore } from "@/renderer/features/workspace/stores/workspac
1210
import { useSidebarData } from "../hooks/useSidebarData";
1311
import { usePinnedTasksStore } from "../stores/pinnedTasksStore";
1412
import { useTaskViewedStore } from "../stores/taskViewedStore";
15-
import { HistoryView } from "./HistoryView";
1613
import { NewTaskItem } from "./items/HomeItem";
1714
import { SidebarItem } from "./SidebarItem";
15+
import { TaskListView } from "./TaskListView";
1816

1917
function SidebarMenuComponent() {
2018
const { view, navigateToTask, navigateToTaskInput } = useNavigationStore();
2119

22-
const activeFilters = useTaskStore((state) => state.activeFilters);
23-
const { data: currentUser } = useMeQuery();
2420
const { data: allTasks = [] } = useTasks();
2521

2622
const workspaces = useWorkspaceStore.use.workspaces();
@@ -33,8 +29,6 @@ function SidebarMenuComponent() {
3329

3430
const sidebarData = useSidebarData({
3531
activeView: view,
36-
activeFilters,
37-
currentUser,
3832
});
3933

4034
const previousTaskIdRef = useRef<string | null>(null);
@@ -131,13 +125,15 @@ function SidebarMenuComponent() {
131125
label="Loading tasks..."
132126
/>
133127
) : (
134-
<HistoryView
135-
historyData={sidebarData.historyData}
136-
pinnedData={sidebarData.pinnedData}
128+
<TaskListView
129+
pinnedTasks={sidebarData.pinnedTasks}
130+
flatTasks={sidebarData.flatTasks}
131+
groupedTasks={sidebarData.groupedTasks}
137132
activeTaskId={sidebarData.activeTaskId}
138133
onTaskClick={handleTaskClick}
139134
onTaskContextMenu={handleTaskContextMenu}
140135
onTaskDelete={handleTaskDelete}
136+
hasMore={sidebarData.hasMore}
141137
/>
142138
)}
143139
</Flex>

0 commit comments

Comments
 (0)