From a19e10715e0e9ea669f28509711d19325a0d81d0 Mon Sep 17 00:00:00 2001 From: frectonz Date: Sun, 23 Jun 2024 16:18:47 +0300 Subject: [PATCH] feat: uppercase text on overview page --- ui/src/routes/__root.tsx | 4 +- ui/src/routes/index.lazy.tsx | 229 ++++++++++++++++++----------------- 2 files changed, 117 insertions(+), 116 deletions(-) diff --git a/ui/src/routes/__root.tsx b/ui/src/routes/__root.tsx index b5da5ef..ca3ad73 100644 --- a/ui/src/routes/__root.tsx +++ b/ui/src/routes/__root.tsx @@ -120,8 +120,8 @@ function MobileNav() { xmlns="http://www.w3.org/2000/svg" > diff --git a/ui/src/routes/index.lazy.tsx b/ui/src/routes/index.lazy.tsx index d7b9640..c368b1a 100644 --- a/ui/src/routes/index.lazy.tsx +++ b/ui/src/routes/index.lazy.tsx @@ -1,34 +1,35 @@ import { createFileRoute } from "@tanstack/react-router"; import { + Workflow, + TextSearch, DatabaseZap, Table as TableIcon, - TextSearch, - Workflow, + LucideIcon, } from "lucide-react"; import { Bar, - BarChart, - ResponsiveContainer, - Tooltip, - TooltipProps, XAxis, YAxis, + Tooltip, + BarChart, + TooltipProps, + ResponsiveContainer, } from "recharts"; +import { + NameType, + ValueType, +} from "recharts/types/component/DefaultTooltipContent"; import { fetchOverview } from "@/api"; import { Card, + CardTitle, + CardHeader, CardContent, CardDescription, - CardHeader, - CardTitle, } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table"; -import { - NameType, - ValueType, -} from "recharts/types/component/DefaultTooltipContent"; export const Route = createFileRoute("/")({ component: Index, @@ -39,76 +40,56 @@ export const Route = createFileRoute("/")({ function Index() { const data = Route.useLoaderData(); + const cards: InfoCardProps[] = [ + { + title: "TABLES", + value: data.tables.toLocaleString(), + description: "The number of tables in the DB.", + icon: TableIcon, + }, + { + title: "INDEXES", + value: data.indexes.toLocaleString(), + description: "The number of indexes in the DB.", + icon: DatabaseZap, + }, + { + title: "VIEWS", + value: data.views.toLocaleString(), + description: "The number of views in the DB.", + icon: TextSearch, + }, + { + title: "TRIGGERS", + value: data.triggers.toLocaleString(), + description: "The number of triggers in the DB.", + icon: Workflow, + }, + ]; + return ( <>

- Exploring{" "} + EXPLORING{" "} {data.file_name}

- - - Tables - - - -
- {data.tables.toLocaleString()} -
-

- The number of tables in the DB. -

-
-
- - - Indexes - - - -
- {data.indexes.toLocaleString()} -
-

- The number of indexes across the whole DB. -

-
-
- - - Views - - - -
- {data.views.toLocaleString()} -
-

- The number of views in the DB. -

-
-
- - - Triggers - - - -
- {data.triggers.toLocaleString()} -
-

- The number of triggers in the DB. -

-
-
+ {cards.map((card, i) => ( + + ))}
- Rows Per Table + ROWS PER TABLE @@ -117,63 +98,41 @@ function Index() {
- More metadata - More info about the DB + MORE METADATA + More info about the DB.
- - -
File size
-
- The size of the DB on disk. -
-
- {data.file_size} -
+ {data.sqlite_version && ( - - -
SQLite version
-
- The SQLite version the DB was created with. -
-
- - {data.sqlite_version} - -
+ )} {data.created && ( - - -
Created on
-
- The date and time when the DB was created. -
-
- - {data.created.toUTCString()} - -
+ )} {data.modified && ( - - -
Modified on
-
- The date and time when the DB was last modified. -
-
- - {data.modified.toUTCString()} - -
+ )}
@@ -184,6 +143,48 @@ function Index() { ); } +type InfoCardProps = { + title: string; + value: string; + description: string; + icon: LucideIcon; +}; + +function InfoCard({ title, value, description, icon: Icon }: InfoCardProps) { + return ( + + + {title} + + + +
{value}
+

{description}

+
+
+ ); +} + +type MetadataRowProps = { + name: string; + description: string; + value: string; +}; + +function MetadataRow({ name, description, value }: MetadataRowProps) { + return ( + + +
{name}
+
+ {description} +
+
+ {value} +
+ ); +} + type TheBarChartProps = { counts: { count: number;