From b456cad3d544f60c751046305ae2395530aa9d69 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Sat, 22 Feb 2025 15:56:04 +0800 Subject: [PATCH] feat: enhance accessibility and improve component styles across the application --- .../ClientComponents/detail/NetworkChart.tsx | 16 ++-- .../detail/ServerDetailChartClient.tsx | 64 ++++++++-------- .../detail/ServerDetailClient.tsx | 76 +++++++++---------- .../ClientComponents/detail/ServerIPInfo.tsx | 38 +++++----- app/(main)/ClientComponents/main/Global.tsx | 4 +- .../ClientComponents/main/GlobalInfo.tsx | 2 +- .../ClientComponents/main/InteractiveMap.tsx | 10 +-- .../ClientComponents/main/MapTooltip.tsx | 10 +-- .../main/ServerListClient.tsx | 16 ++-- .../main/ServerOverviewClient.tsx | 64 ++++++++-------- app/(main)/footer.tsx | 6 +- app/(main)/header.tsx | 24 +++--- app/(main)/server/[id]/page.tsx | 4 +- app/not-found.tsx | 6 +- biome.json | 3 + components/AnimatedCount.tsx | 2 +- components/DashCommand.tsx | 4 +- components/LanguageSwitcher.tsx | 4 +- components/ServerCard.tsx | 42 +++++----- components/ServerCardInline.tsx | 52 ++++++------- components/SignIn.tsx | 12 +-- components/Switch.tsx | 10 +-- components/TabSwitch.tsx | 6 +- components/ThemeSwitcher.tsx | 4 +- components/loading/GlobalLoading.tsx | 2 +- components/loading/NetworkChartLoading.tsx | 2 +- components/loading/ServerDetailLoading.tsx | 20 ++--- .../ui/animated-circular-progress-bar.tsx | 8 +- components/ui/animated-tooltip.tsx | 2 +- components/ui/card.tsx | 4 +- components/ui/chart.tsx | 8 +- components/ui/command.tsx | 10 +-- components/ui/dialog.tsx | 10 +-- components/ui/dropdown-menu.tsx | 12 +-- components/ui/input.tsx | 2 +- components/ui/navigation-menu.tsx | 8 +- components/ui/popover.tsx | 2 +- components/ui/sheet.tsx | 8 +- components/ui/tooltip.tsx | 2 +- 39 files changed, 291 insertions(+), 288 deletions(-) diff --git a/app/(main)/ClientComponents/detail/NetworkChart.tsx b/app/(main)/ClientComponents/detail/NetworkChart.tsx index 67f3e84..6fd530b 100644 --- a/app/(main)/ClientComponents/detail/NetworkChart.tsx +++ b/app/(main)/ClientComponents/detail/NetworkChart.tsx @@ -47,8 +47,8 @@ export function NetworkChartClient({ return ( <>
-

{error.message}

-

{t("chart_fetch_error_message")}

+

{error.message}

+

{t("chart_fetch_error_message")}

@@ -123,12 +123,12 @@ export const NetworkChart = React.memo(function NetworkChart({ key={key} data-active={activeChart === key} className={ - "relative z-30 flex cursor-pointer grow basis-0 flex-col justify-center gap-1 border-b border-neutral-200 dark:border-neutral-800 px-6 py-4 text-left data-[active=true]:bg-muted/50 sm:border-l sm:border-t-0 sm:px-6" + "relative z-30 flex grow basis-0 cursor-pointer flex-col justify-center gap-1 border-neutral-200 border-b px-6 py-4 text-left data-[active=true]:bg-muted/50 sm:border-t-0 sm:border-l sm:px-6 dark:border-neutral-800" } onClick={() => handleButtonClick(key)} > - {key} - + {key} + {chartData[key][chartData[key].length - 1].avg_delay.toFixed(2)}ms @@ -269,16 +269,16 @@ export const NetworkChart = React.memo(function NetworkChart({ {chartDataKey.length} {t("ServerMonitorCount")} -
+
-
{chartButtons}
+
{chartButtons}
- + diff --git a/app/(main)/ClientComponents/detail/ServerDetailChartClient.tsx b/app/(main)/ClientComponents/detail/ServerDetailChartClient.tsx index c14f0cd..8809c0c 100644 --- a/app/(main)/ClientComponents/detail/ServerDetailChartClient.tsx +++ b/app/(main)/ClientComponents/detail/ServerDetailChartClient.tsx @@ -64,8 +64,8 @@ export default function ServerDetailChartClient({ return ( <>
-

{error.message}

-

{t("chart_fetch_error_message")}

+

{error.message}

+

{t("chart_fetch_error_message")}

) @@ -73,7 +73,7 @@ export default function ServerDetailChartClient({ if (!data) return return ( -
+
@@ -150,9 +150,9 @@ function CpuChart({
-

CPU

+

CPU

-

{cpu.toFixed(0)}%

+

{cpu.toFixed(0)}%

-

{t("Process")}

+

{t("Process")}

-

{process}

+

{process}

@@ -388,7 +388,7 @@ function MemChart({
-

{t("Mem")}

+

{t("Mem")}

-

{mem.toFixed(0)}%

+

{mem.toFixed(0)}%

-

{t("Swap")}

+

{t("Swap")}

-

{swap.toFixed(0)}%

+

{swap.toFixed(0)}%

-
+
{formatBytes(data.status.MemUsed)} / {formatBytes(data.host.MemTotal)}
-
+
swap: {formatBytes(data.status.SwapUsed)}
@@ -542,10 +542,10 @@ function DiskChart({
-

{t("Disk")}

+

{t("Disk")}

-

{disk.toFixed(0)}%

+

{disk.toFixed(0)}%

-
+
{formatBytes(data.status.DiskUsed)} / {formatBytes(data.host.DiskTotal)}
@@ -681,18 +681,18 @@ function NetworkChart({
-
-

{t("Upload")}

+
+

{t("Upload")}

- -

{up.toFixed(2)} M/s

+ +

{up.toFixed(2)} M/s

-
-

{t("Download")}

+
+

{t("Download")}

- -

{down.toFixed(2)} M/s

+ +

{down.toFixed(2)} M/s

@@ -823,18 +823,18 @@ function ConnectChart({
-
-

TCP

+
+

TCP

- -

{tcp}

+ +

{tcp}

-
-

UDP

+
+

UDP

- -

{udp}

+ +

{udp}

diff --git a/app/(main)/ClientComponents/detail/ServerDetailClient.tsx b/app/(main)/ClientComponents/detail/ServerDetailClient.tsx index f75d5d4..287905c 100644 --- a/app/(main)/ClientComponents/detail/ServerDetailClient.tsx +++ b/app/(main)/ClientComponents/detail/ServerDetailClient.tsx @@ -55,8 +55,8 @@ export default function ServerDetailClient({ return ( <>
-

{error.message}

-

{t("detail_fetch_error_message")}

+

{error.message}

+

{t("detail_fetch_error_message")}

) @@ -89,19 +89,19 @@ export default function ServerDetailClient({
{name}
-
- +
+
-

{t("status")}

+

{t("status")}

- +
-

{t("Uptime")}

+

{t("Uptime")}

{" "} {uptime / 86400 >= 1 @@ -127,62 +127,62 @@ export default function ServerDetailClient({ {version && ( - +
-

{t("Version")}

+

{t("Version")}

{version}
)} {arch && ( - +
-

{t("Arch")}

+

{t("Arch")}

{arch}
)} - +
-

{t("Mem")}

+

{t("Mem")}

{formatBytes(mem_total)}
- +
-

{t("Disk")}

+

{t("Disk")}

{formatBytes(disk_total)}
{country_code && ( - +
-

{t("Region")}

+

{t("Region")}

-
{countries.getName(country_code, "en")}
- +
{countries.getName(country_code, "en")}
+
)}
-
+
{platform && ( - +
-

{t("System")}

+

{t("System")}

{" "} @@ -193,10 +193,10 @@ export default function ServerDetailClient({ )} {cpu_info && cpu_info.length > 0 && ( - +
-

{t("CPU")}

+

{t("CPU")}

{cpu_info.join(", ")}
@@ -204,31 +204,31 @@ export default function ServerDetailClient({
)} {gpu_info && gpu_info.length > 0 && ( - +
-

{"GPU"}

+

{"GPU"}

{gpu_info.join(", ")}
)}
-
- +
+
-

{t("Load")}

+

{t("Load")}

{load_1 || "0.00"} / {load_5 || "0.00"} / {load_15 || "0.00"}
- +
-

{t("Upload")}

+

{t("Upload")}

{net_out_transfer ? (
{formatBytes(net_out_transfer)}
) : ( @@ -237,10 +237,10 @@ export default function ServerDetailClient({
- +
-

{t("Download")}

+

{t("Download")}

{net_in_transfer ? (
{formatBytes(net_in_transfer)}
) : ( @@ -250,11 +250,11 @@ export default function ServerDetailClient({
-
- +
+
-

{t("LastActive")}

+

{t("LastActive")}

{last_active_time_string ? last_active_time_string : "N/A"}
diff --git a/app/(main)/ClientComponents/detail/ServerIPInfo.tsx b/app/(main)/ClientComponents/detail/ServerIPInfo.tsx index 15407c1..6d2d9b5 100644 --- a/app/(main)/ClientComponents/detail/ServerIPInfo.tsx +++ b/app/(main)/ClientComponents/detail/ServerIPInfo.tsx @@ -22,92 +22,92 @@ export default function ServerIPInfo({ server_id }: { server_id: number }) { return ( <> -
+
{data.asn?.autonomous_system_organization && ( - +
-

{"ASN"}

+

{"ASN"}

{data.asn.autonomous_system_organization}
)} {data.asn?.autonomous_system_number && ( - +
-

{t("asn_number")}

+

{t("asn_number")}

AS{data.asn.autonomous_system_number}
)} {data.city?.registered_country?.names.en && ( - +
-

{t("registered_country")}

+

{t("registered_country")}

{data.city.registered_country?.names.en}
)} {data.city?.country?.iso_code && ( - +
-

{"ISO"}

+

{"ISO"}

{data.city.country?.iso_code}
)} {data.city?.city?.names.en && ( - +
-

{t("city")}

+

{t("city")}

{data.city.city?.names.en}
)} {data.city?.location?.longitude && ( - +
-

{t("longitude")}

+

{t("longitude")}

{data.city.location?.longitude}
)} {data.city?.location?.latitude && ( - +
-

{t("latitude")}

+

{t("latitude")}

{data.city.location?.latitude}
)} {data.city?.location?.time_zone && ( - +
-

{t("time_zone")}

+

{t("time_zone")}

{data.city.location?.time_zone}
)} {data.city?.postal && ( - +
-

{t("postal_code")}

+

{t("postal_code")}

{data.city.postal?.code}
diff --git a/app/(main)/ClientComponents/main/Global.tsx b/app/(main)/ClientComponents/main/Global.tsx index 546f927..0740f3a 100644 --- a/app/(main)/ClientComponents/main/Global.tsx +++ b/app/(main)/ClientComponents/main/Global.tsx @@ -13,7 +13,7 @@ export default function ServerGlobal() { if (error) return (
-

{error.message}

+

{error.message}

) @@ -43,7 +43,7 @@ export default function ServerGlobal() { ) return ( -
+
diff --git a/app/(main)/ClientComponents/main/GlobalInfo.tsx b/app/(main)/ClientComponents/main/GlobalInfo.tsx index a536497..ff4c5fa 100644 --- a/app/(main)/ClientComponents/main/GlobalInfo.tsx +++ b/app/(main)/ClientComponents/main/GlobalInfo.tsx @@ -10,7 +10,7 @@ export default function GlobalInfo({ countries }: GlobalInfoProps) { const t = useTranslations("Global") return (
-

+

{t("Distributions")} {countries.length} {t("Regions")}

diff --git a/app/(main)/ClientComponents/main/InteractiveMap.tsx b/app/(main)/ClientComponents/main/InteractiveMap.tsx index f2d3f36..4ceec0b 100644 --- a/app/(main)/ClientComponents/main/InteractiveMap.tsx +++ b/app/(main)/ClientComponents/main/InteractiveMap.tsx @@ -32,13 +32,13 @@ export function InteractiveMap({ const path = geoPath().projection(projection) return ( -
setTooltipData(null)}> +
setTooltipData(null)}> Interactive Map @@ -67,8 +67,8 @@ export function InteractiveMap({ d={path(feature) || ""} className={ isHighlighted - ? "fill-green-700 hover:fill-green-600 dark:fill-green-900 dark:hover:fill-green-700 transition-all cursor-pointer" - : "fill-neutral-200/50 dark:fill-neutral-800 stroke-neutral-300/40 dark:stroke-neutral-700 stroke-[0.5]" + ? "cursor-pointer fill-green-700 transition-all hover:fill-green-600 dark:fill-green-900 dark:hover:fill-green-700" + : "fill-neutral-200/50 stroke-[0.5] stroke-neutral-300/40 dark:fill-neutral-800 dark:stroke-neutral-700" } onMouseEnter={() => { if (!isHighlighted) { @@ -140,7 +140,7 @@ export function InteractiveMap({ cx={x} cy={y} r={4} - className="fill-sky-700 stroke-white hover:fill-sky-600 dark:fill-sky-900 dark:hover:fill-sky-700 transition-all" + className="fill-sky-700 stroke-white transition-all hover:fill-sky-600 dark:fill-sky-900 dark:hover:fill-sky-700" /> ) diff --git a/app/(main)/ClientComponents/main/MapTooltip.tsx b/app/(main)/ClientComponents/main/MapTooltip.tsx index 1f6175f..c364caa 100644 --- a/app/(main)/ClientComponents/main/MapTooltip.tsx +++ b/app/(main)/ClientComponents/main/MapTooltip.tsx @@ -21,7 +21,7 @@ const MapTooltip = memo(function MapTooltip() { return (
{tooltipData.country === "China" ? "Mainland China" : tooltipData.country}

-

+

{tooltipData.count} {t("Servers")}

diff --git a/app/(main)/ClientComponents/main/ServerListClient.tsx b/app/(main)/ClientComponents/main/ServerListClient.tsx index 71f1759..3cd3827 100644 --- a/app/(main)/ClientComponents/main/ServerListClient.tsx +++ b/app/(main)/ClientComponents/main/ServerListClient.tsx @@ -56,8 +56,8 @@ const getTagCounts = (servers: any[]) => { } const LoadingState = ({ t }: { t: any }) => ( -
-
+
+
{t("connecting")}...
@@ -66,8 +66,8 @@ const LoadingState = ({ t }: { t: any }) => ( const ErrorState = ({ error, t }: { error: Error; t: any }) => (
-

{error.message}

-

{t("error_message")}

+

{error.message}

+

{t("error_message")}

) @@ -80,7 +80,7 @@ const ServerList = ({ return (
{servers.map((serverInfo) => ( @@ -171,7 +171,7 @@ export default function ServerListClient() { return ( <> -
+
diff --git a/components/loading/GlobalLoading.tsx b/components/loading/GlobalLoading.tsx index c0690b4..f3326f2 100644 --- a/components/loading/GlobalLoading.tsx +++ b/components/loading/GlobalLoading.tsx @@ -6,7 +6,7 @@ import { useTranslations } from "next-intl" export default function GlobalLoading() { const t = useTranslations("Global") return ( -
+
{t("Loading")} diff --git a/components/loading/NetworkChartLoading.tsx b/components/loading/NetworkChartLoading.tsx index 139ef2c..3ecac75 100644 --- a/components/loading/NetworkChartLoading.tsx +++ b/components/loading/NetworkChartLoading.tsx @@ -11,7 +11,7 @@ export default function NetworkChartLoading() {
-
+
diff --git a/components/loading/ServerDetailLoading.tsx b/components/loading/ServerDetailLoading.tsx index e6f0f6b..bbefb12 100644 --- a/components/loading/ServerDetailLoading.tsx +++ b/components/loading/ServerDetailLoading.tsx @@ -5,13 +5,13 @@ import { useRouter } from "next/navigation" export function ServerDetailChartLoading() { return (
-
- - - - - - +
+ + + + + +
) @@ -26,12 +26,12 @@ export function ServerDetailLoading() { onClick={() => { router.push("/") }} - className="flex flex-none cursor-pointer font-semibold leading-none items-center break-all tracking-tight gap-0.5 text-xl" + className="flex flex-none cursor-pointer items-center gap-0.5 break-all font-semibold text-xl leading-none tracking-tight" > - +
- + ) } diff --git a/components/ui/animated-circular-progress-bar.tsx b/components/ui/animated-circular-progress-bar.tsx index 00c5d9e..0bf7e1a 100644 --- a/components/ui/animated-circular-progress-bar.tsx +++ b/components/ui/animated-circular-progress-bar.tsx @@ -21,7 +21,7 @@ export default function AnimatedCircularProgressBar({ return (
{currentPercent} diff --git a/components/ui/animated-tooltip.tsx b/components/ui/animated-tooltip.tsx index 6ff7391..05e1b9e 100644 --- a/components/ui/animated-tooltip.tsx +++ b/components/ui/animated-tooltip.tsx @@ -14,7 +14,7 @@ export const AnimatedTooltip = ({ return ( <> {items.map((item) => ( -
+
(

), @@ -37,7 +37,7 @@ const CardDescription = React.forwardRef< HTMLParagraphElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( -

+

)) CardDescription.displayName = "CardDescription" diff --git a/components/ui/chart.tsx b/components/ui/chart.tsx index 34a8d0d..186b452 100644 --- a/components/ui/chart.tsx +++ b/components/ui/chart.tsx @@ -164,16 +164,16 @@ const ChartTooltipContent = React.forwardRef<

{!nestLabel && ( -
{!nestLabel ? tooltipLabel : null}
+
{!nestLabel ? tooltipLabel : null}
)}
@@ -233,7 +233,7 @@ const ChartTooltipContent = React.forwardRef< {item.value && ( diff --git a/components/ui/command.tsx b/components/ui/command.tsx index 6c6c07c..485106b 100644 --- a/components/ui/command.tsx +++ b/components/ui/command.tsx @@ -40,7 +40,7 @@ const CommandInput = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( -
+
(({ className, ...props }, ref) => ( )) @@ -84,7 +84,7 @@ const CommandGroup = React.forwardRef< ) => { return ( ) diff --git a/components/ui/dialog.tsx b/components/ui/dialog.tsx index fbd7e86..abed57f 100644 --- a/components/ui/dialog.tsx +++ b/components/ui/dialog.tsx @@ -21,7 +21,7 @@ const DialogOverlay = React.forwardRef< {children} - + Close @@ -72,7 +72,7 @@ const DialogTitle = React.forwardRef< >(({ className, ...props }, ref) => ( )) @@ -84,7 +84,7 @@ const DialogDescription = React.forwardRef< >(({ className, ...props }, ref) => ( )) diff --git a/components/ui/dropdown-menu.tsx b/components/ui/dropdown-menu.tsx index b654ce7..614511f 100644 --- a/components/ui/dropdown-menu.tsx +++ b/components/ui/dropdown-menu.tsx @@ -45,7 +45,7 @@ const DropdownMenuSubContent = React.forwardRef< (({ className, inset, ...props }, ref) => ( )) diff --git a/components/ui/input.tsx b/components/ui/input.tsx index 8a27b36..3bcaec3 100644 --- a/components/ui/input.tsx +++ b/components/ui/input.tsx @@ -9,7 +9,7 @@ const Input = React.forwardRef( , React.ComponentPropsWithoutRef >(({ className, ...props }, ref) => ( -
+
(({ className, ...props }, ref) => ( {children} - + Close @@ -88,7 +88,7 @@ const SheetTitle = React.forwardRef< >(({ className, ...props }, ref) => ( )) @@ -100,7 +100,7 @@ const SheetDescription = React.forwardRef< >(({ className, ...props }, ref) => ( )) diff --git a/components/ui/tooltip.tsx b/components/ui/tooltip.tsx index ea7126b..6be4b8a 100644 --- a/components/ui/tooltip.tsx +++ b/components/ui/tooltip.tsx @@ -18,7 +18,7 @@ const TooltipContent = React.forwardRef< ref={ref} sideOffset={sideOffset} className={cn( - "z-50 overflow-hidden rounded-[10px] border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", + "fade-in-0 zoom-in-95 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 animate-in overflow-hidden rounded-[10px] border bg-popover px-3 py-1.5 text-popover-foreground text-sm shadow-md data-[state=closed]:animate-out", className, )} {...props}