From e0999f701cd1834c3d940113cd8dd5247c5fe95f Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Fri, 19 Apr 2024 00:09:27 +0100 Subject: feature: Nested lists (#110). Fixes #62 * feature: Add support for nested lists * prevent moving the parent to a subtree --- .../components/dashboard/lists/AllListsView.tsx | 113 ++++++++++++++------- 1 file changed, 74 insertions(+), 39 deletions(-) (limited to 'apps/web/components/dashboard/lists/AllListsView.tsx') diff --git a/apps/web/components/dashboard/lists/AllListsView.tsx b/apps/web/components/dashboard/lists/AllListsView.tsx index 00e76a23..308af5db 100644 --- a/apps/web/components/dashboard/lists/AllListsView.tsx +++ b/apps/web/components/dashboard/lists/AllListsView.tsx @@ -1,31 +1,59 @@ "use client"; import Link from "next/link"; -import { useNewListModal } from "@/components/dashboard/sidebar/NewListModal"; +import { EditListModal } from "@/components/dashboard/lists/EditListModal"; import { Button } from "@/components/ui/button"; -import { api } from "@/lib/trpc"; -import { keepPreviousData } from "@tanstack/react-query"; -import { Plus } from "lucide-react"; +import { CollapsibleTriggerChevron } from "@/components/ui/collapsible"; +import { MoreHorizontal, Plus } from "lucide-react"; import type { ZBookmarkList } from "@hoarder/shared/types/lists"; +import { CollapsibleBookmarkLists } from "./CollapsibleBookmarkLists"; +import { ListOptions } from "./ListOptions"; + function ListItem({ name, icon, path, + style, + list, + open, + collapsible, }: { name: string; icon: string; path: string; + style?: React.CSSProperties; + list?: ZBookmarkList; + open?: boolean; + collapsible: boolean; }) { return ( - -
-

- {icon} {name} -

-
- +
  • + + {collapsible && ( + + )} + +

    + {icon} {name} +

    + +
    + {list && ( + + + + )} +
  • ); } @@ -34,34 +62,41 @@ export default function AllListsView({ }: { initialData: ZBookmarkList[]; }) { - const { setOpen: setIsNewListModalOpen } = useNewListModal(); - let { data: lists } = api.lists.list.useQuery(undefined, { - initialData: { lists: initialData }, - placeholderData: keepPreviousData, - }); - - // TODO: This seems to be a bug in react query - lists ||= { lists: initialData }; - return ( -
    - - - - {lists.lists.map((l) => ( - - ))} -
    + ); } -- cgit v1.2.3-70-g09d2