diff --git a/frontend/package.json b/frontend/package.json index 1e302af..01d13d0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "aurum-frontend", "private": true, - "version": "0.16.0", + "version": "0.16.1", "type": "module", "scripts": { "dev": "vite", diff --git a/frontend/src/components/layout/YearSelector.tsx b/frontend/src/components/layout/YearSelector.tsx index 3d8858f..48cacb2 100644 --- a/frontend/src/components/layout/YearSelector.tsx +++ b/frontend/src/components/layout/YearSelector.tsx @@ -1,3 +1,5 @@ +import { useEffect, useRef, useState } from "react"; +import { ChevronDown } from "lucide-react"; import { cn } from "@/lib/utils"; interface YearSelectorProps { @@ -6,27 +8,73 @@ interface YearSelectorProps { onChange: (year: number) => void; } +/** Compact dropdown, most recent year first — sits to the right of + * MonthSelector instead of competing with it as a second row of pills. */ export function YearSelector({ years, year, onChange }: YearSelectorProps) { + const [open, setOpen] = useState(false); + const rootRef = useRef(null); + const sortedYears = [...years].sort((a, b) => b - a); + + useEffect(() => { + if (!open) return; + function handlePointerDown(event: MouseEvent) { + if (rootRef.current && !rootRef.current.contains(event.target as Node)) { + setOpen(false); + } + } + function handleKeyDown(event: KeyboardEvent) { + if (event.key === "Escape") setOpen(false); + } + document.addEventListener("mousedown", handlePointerDown); + document.addEventListener("keydown", handleKeyDown); + return () => { + document.removeEventListener("mousedown", handlePointerDown); + document.removeEventListener("keydown", handleKeyDown); + }; + }, [open]); + return ( -
- {years.map((value) => { - const active = value === year; - return ( - - ); - })} +
+ + + {open && ( +
    + {sortedYears.map((value) => { + const active = value === year; + return ( +
  • + +
  • + ); + })} +
+ )}
); } diff --git a/frontend/src/pages/BudgetPage.tsx b/frontend/src/pages/BudgetPage.tsx index 77754d0..73581d5 100644 --- a/frontend/src/pages/BudgetPage.tsx +++ b/frontend/src/pages/BudgetPage.tsx @@ -54,9 +54,11 @@ export function BudgetPage() {
-
+
+
+ +
-
diff --git a/frontend/src/pages/DashboardPage.tsx b/frontend/src/pages/DashboardPage.tsx index a0c41a8..96e959a 100644 --- a/frontend/src/pages/DashboardPage.tsx +++ b/frontend/src/pages/DashboardPage.tsx @@ -35,9 +35,11 @@ export function DashboardPage() {
-
+
+
+ +
-
{isError && ( diff --git a/frontend/src/pages/TransactionsPage.tsx b/frontend/src/pages/TransactionsPage.tsx index c2dd370..552dabe 100644 --- a/frontend/src/pages/TransactionsPage.tsx +++ b/frontend/src/pages/TransactionsPage.tsx @@ -63,7 +63,16 @@ export function TransactionsPage() { return (
-
+
+
+ { + setMonth(value); + setPage(1); + }} + /> +
- { - setMonth(value); - setPage(1); - }} - />