From fde7b3b23e9a781acd294d2bd1e5f2b205242834 Mon Sep 17 00:00:00 2001 From: headlessdev Date: Sat, 26 Apr 2025 13:11:19 +0200 Subject: [PATCH] New compact view for applications --- ApplicationsFormatted.tsx | Bin 0 -> 116 bytes app/dashboard/applications/Applications.tsx | 494 +++++++++++--------- 2 files changed, 280 insertions(+), 214 deletions(-) create mode 100644 ApplicationsFormatted.tsx diff --git a/ApplicationsFormatted.tsx b/ApplicationsFormatted.tsx new file mode 100644 index 0000000000000000000000000000000000000000..a1653942ca0faee5bcec8f3655cb656d8048cf90 GIT binary patch literal 116 zcmW-X%L#xm5JcZuu!mIOC3x{<1@<6*Vo;1E0lQZxGVJW`n|YssMVc{Wg4}bGbdMZT np__8Us6{db($rPjnQcj_cMYAVsFFH2rK(qn08HTKUxlsOes literal 0 HcmV?d00001 diff --git a/app/dashboard/applications/Applications.tsx b/app/dashboard/applications/Applications.tsx index 8d28083..84d7952 100644 --- a/app/dashboard/applications/Applications.tsx +++ b/app/dashboard/applications/Applications.tsx @@ -25,6 +25,8 @@ import { List, Pencil, Zap, + ViewIcon, + Grid3X3, } from "lucide-react"; import { Card, @@ -76,6 +78,12 @@ import { import { StatusIndicator } from "@/components/status-indicator"; import { Toaster } from "@/components/ui/sonner" import { toast } from "sonner" +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; interface Application { id: number; @@ -129,23 +137,42 @@ export default function Dashboard() { const savedLayout = Cookies.get("layoutPreference-app"); const savedItemsPerPage = Cookies.get("itemsPerPage-app"); const initialIsGridLayout = savedLayout === "grid"; - const defaultItemsPerPage = initialIsGridLayout ? 15 : 5; + const initialIsCompactLayout = savedLayout === "compact"; + const defaultItemsPerPage = initialIsGridLayout ? 15 : (initialIsCompactLayout ? 30 : 5); const initialItemsPerPage = savedItemsPerPage ? parseInt(savedItemsPerPage) : defaultItemsPerPage; const [isGridLayout, setIsGridLayout] = useState(initialIsGridLayout); + const [isCompactLayout, setIsCompactLayout] = useState(initialIsCompactLayout); const [itemsPerPage, setItemsPerPage] = useState(initialItemsPerPage); const customInputRef = useRef(null); const debounceTimerRef = useRef(null); - const toggleLayout = () => { - const newLayout = !isGridLayout; - setIsGridLayout(newLayout); - Cookies.set("layoutPreference-app", newLayout ? "grid" : "standard", { - expires: 365, - path: "/", - sameSite: "strict", - }); - // Don't automatically change itemsPerPage when layout changes + const toggleLayout = (layout: string) => { + if (layout === "standard") { + setIsGridLayout(false); + setIsCompactLayout(false); + Cookies.set("layoutPreference-app", "standard", { + expires: 365, + path: "/", + sameSite: "strict", + }); + } else if (layout === "grid") { + setIsGridLayout(true); + setIsCompactLayout(false); + Cookies.set("layoutPreference-app", "grid", { + expires: 365, + path: "/", + sameSite: "strict", + }); + } else if (layout === "compact") { + setIsGridLayout(false); + setIsCompactLayout(true); + Cookies.set("layoutPreference-app", "compact", { + expires: 365, + path: "/", + sameSite: "strict", + }); + } }; const handleItemsPerPageChange = (value: string) => { @@ -335,20 +362,30 @@ export default function Dashboard() {
Your Applications
- + + + + + + toggleLayout("standard")}> + List View + + toggleLayout("grid")}> + Grid View + + toggleLayout("compact")}> + Compact View + + + - setEditName(e.target.value) - } - /> -
-
- - -
-
- -