From a80684c3fb4c19bf9a9700531dcd3c6fcd038a51 Mon Sep 17 00:00:00 2001 From: Vasily Zubarev Date: Mon, 24 Mar 2025 19:52:09 +0100 Subject: [PATCH] feat: improve loaders and styles --- app/globals.css | 8 +-- app/settings/loading.tsx | 10 +++ app/transactions/[transactionId]/loading.tsx | 5 +- app/transactions/loading.tsx | 15 +++- app/unsorted/loading.tsx | 31 ++++++++ components/forms/simple.tsx | 74 +++++++++++++++++++- components/sidebar/sidebar-item.tsx | 6 +- components/transactions/list.tsx | 6 +- 8 files changed, 143 insertions(+), 12 deletions(-) create mode 100644 app/settings/loading.tsx create mode 100644 app/unsorted/loading.tsx diff --git a/app/globals.css b/app/globals.css index 63c3e0d..38cabd4 100644 --- a/app/globals.css +++ b/app/globals.css @@ -33,8 +33,8 @@ --sidebar-foreground: 200 10% 30%; --sidebar-primary: 200 13% 80%; --sidebar-primary-foreground: 0 0% 98%; - --sidebar-accent: 200 13% 90%; - --sidebar-accent-foreground: 200 10% 30%; + --sidebar-accent: 240 5.9% 10%; + --sidebar-accent-foreground: 0 0% 98%; --sidebar-border: 200 13% 85%; --sidebar-ring: 200 13% 80%; } @@ -68,8 +68,8 @@ --sidebar-foreground: 200 10% 90%; --sidebar-primary: 200 13% 60%; --sidebar-primary-foreground: 0 0% 100%; - --sidebar-accent: 200 13% 25%; - --sidebar-accent-foreground: 200 10% 90%; + --sidebar-accent: 240 5.9% 10%; + --sidebar-accent-foreground: 0 0% 98%; --sidebar-border: 200 13% 25%; --sidebar-ring: 200 13% 60%; } diff --git a/app/settings/loading.tsx b/app/settings/loading.tsx new file mode 100644 index 0000000..14f648e --- /dev/null +++ b/app/settings/loading.tsx @@ -0,0 +1,10 @@ +import { Skeleton } from "@/components/ui/skeleton" + +export default function Loading() { + return ( +
+ + +
+ ) +} diff --git a/app/transactions/[transactionId]/loading.tsx b/app/transactions/[transactionId]/loading.tsx index 4011433..5f6add6 100644 --- a/app/transactions/[transactionId]/loading.tsx +++ b/app/transactions/[transactionId]/loading.tsx @@ -2,6 +2,9 @@ import { Skeleton } from "@/components/ui/skeleton" export default function Loading() { return ( - +
+ + +
) } diff --git a/app/transactions/loading.tsx b/app/transactions/loading.tsx index 04ec005..302d0fb 100644 --- a/app/transactions/loading.tsx +++ b/app/transactions/loading.tsx @@ -6,7 +6,10 @@ export default function Loading() { return ( <>
-

Transactions

+

+ Transactions + +

+
+ + + + + +
+
- {[...Array(20)].map((_, i) => ( + {[...Array(15)].map((_, i) => ( ))}
diff --git a/app/unsorted/loading.tsx b/app/unsorted/loading.tsx new file mode 100644 index 0000000..5366594 --- /dev/null +++ b/app/unsorted/loading.tsx @@ -0,0 +1,31 @@ +import { Skeleton } from "@/components/ui/skeleton" +import { Loader2 } from "lucide-react" + +export default function Loading() { + return ( +
+
+

+ Loading unsorted files... +

+
+ + + +
+ + {[...Array(4)].map((_, i) => ( +
+ + +
+ ))} +
+ + +
+
+
+
+ ) +} diff --git a/components/forms/simple.tsx b/components/forms/simple.tsx index 8a582cf..47ef3f3 100644 --- a/components/forms/simple.tsx +++ b/components/forms/simple.tsx @@ -1,9 +1,16 @@ +"use client" + +import { Button } from "@/components/ui/button" +import { Calendar } from "@/components/ui/calendar" import { Input } from "@/components/ui/input" +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Textarea } from "@/components/ui/textarea" import { cn } from "@/lib/utils" import { SelectProps } from "@radix-ui/react-select" -import { InputHTMLAttributes, TextareaHTMLAttributes } from "react" +import { format } from "date-fns" +import { CalendarIcon } from "lucide-react" +import { InputHTMLAttributes, TextareaHTMLAttributes, useState } from "react" type FormInputProps = InputHTMLAttributes & { title: string @@ -75,3 +82,68 @@ export const FormSelect = ({ ) } + +export const FormDate = ({ + title, + name, + placeholder = "Select date", + defaultValue, + ...props +}: { + title: string + name: string + placeholder?: string + defaultValue?: Date +}) => { + const [date, setDate] = useState(defaultValue) + const [manualInput, setManualInput] = useState(date ? format(date, "yyyy-MM-dd") : "") + + const handleDateSelect = (newDate: Date | undefined) => { + setDate(newDate) + setManualInput(newDate ? format(newDate, "yyyy-MM-dd") : "") + } + + const handleManualInputChange = (e: React.ChangeEvent) => { + setManualInput(e.target.value) + setDate(undefined) + try { + const newDate = new Date(e.currentTarget.value) + if (!isNaN(newDate.getTime())) { + setDate(newDate) + } + } catch (error) {} + } + + return ( + + ) +} diff --git a/components/sidebar/sidebar-item.tsx b/components/sidebar/sidebar-item.tsx index b3e9e21..4503857 100644 --- a/components/sidebar/sidebar-item.tsx +++ b/components/sidebar/sidebar-item.tsx @@ -21,7 +21,11 @@ export function SidebarMenuItemWithHighlight({ return ( {children} diff --git a/components/transactions/list.tsx b/components/transactions/list.tsx index bcbe72a..4755792 100644 --- a/components/transactions/list.tsx +++ b/components/transactions/list.tsx @@ -25,13 +25,13 @@ export const standardFieldRenderers: Record = { name: { name: "Name", code: "name", - classes: "font-medium max-w-[300px] min-w-[120px] overflow-hidden", + classes: "font-medium min-w-[120px] max-w-[300px] overflow-hidden", sortable: true, }, merchant: { name: "Merchant", code: "merchant", - classes: "max-w-[200px] max-h-[20px] min-w-[120px] overflow-hidden", + classes: "min-w-[120px] max-w-[250px] overflow-hidden", sortable: true, }, issuedAt: { @@ -221,7 +221,7 @@ export function TransactionList({ transactions, fields = [] }: { transactions: T - + {visibleFields.map((field) => (