From 8f953cd6a161f41bce85479c83f29750809adefb Mon Sep 17 00:00:00 2001 From: imbytecat Date: Tue, 12 May 2026 00:39:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E6=9B=BF=E6=8D=A2=E5=8E=9F?= =?UTF-8?q?=E7=94=9F=E4=B8=8B=E6=8B=89=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ui.tsx | 67 ++++++++++++++++++++++++++++++++++++---- src/routes/batteries.tsx | 41 ++++++++++++------------ 2 files changed, 82 insertions(+), 26 deletions(-) diff --git a/src/components/ui.tsx b/src/components/ui.tsx index 9a35629..52d4990 100644 --- a/src/components/ui.tsx +++ b/src/components/ui.tsx @@ -1,3 +1,5 @@ +import * as RadixSelect from '@radix-ui/react-select' +import { Check, ChevronDown } from 'lucide-react' import type { ComponentPropsWithoutRef, ReactNode } from 'react' type Variant = 'default' | 'muted' | 'success' | 'warning' | 'danger' | 'info' @@ -72,17 +74,70 @@ export function Input({ className, ...props }: ComponentPropsWithoutRef<'input'> ) } -export function Select({ className, children, ...props }: ComponentPropsWithoutRef<'select'>) { +export function Select({ + value, + onValueChange, + children, + className, + id, +}: { + value?: string | number + onValueChange?: (value: string) => void + children: ReactNode + className?: string + id?: string +}) { return ( - + + + + + + {children} + ) } diff --git a/src/routes/batteries.tsx b/src/routes/batteries.tsx index 21cd835..030af63 100644 --- a/src/routes/batteries.tsx +++ b/src/routes/batteries.tsx @@ -6,13 +6,14 @@ import { useEffect, useMemo, useState } from 'react' import { z } from 'zod' import { orpc } from '@/client/orpc' import { MotionCardDiv, MotionHeader, MotionSection, MotionTableRow } from '@/components/motion' -import { Badge, Button, Card, Input, SectionTitle, Select } from '@/components/ui' +import { Badge, Button, Card, Input, SectionTitle, Select, SelectOption } from '@/components/ui' import type { BatteryInfo, BatteryListSort, PowerStatus } from '@/domain/battery' import { BATTERY_LIST_SORT, BATTERY_LIST_SORT_VALUES, POWER_STATUS, POWER_STATUS_VALUES } from '@/domain/battery' const pageSizeOptions = [20, 50, 100] as const type PageSizeOption = (typeof pageSizeOptions)[number] const firstPageCursor = '__FIRST_PAGE__' +const allPowerStatusValue = 'all' const searchFilterSchema = z.preprocess( (value) => (typeof value === 'string' ? value.trim() || undefined : value), @@ -78,7 +79,7 @@ function parseSort(value: string): BatteryListSort { } function parsePowerStatus(value: string): PowerStatus | undefined { - if (value === '') return undefined + if (value === allPowerStatusValue) return undefined const parsed = Number(value) @@ -326,22 +327,22 @@ function BatteriesPage() { @@ -352,21 +353,21 @@ function BatteriesPage() { @@ -377,20 +378,20 @@ function BatteriesPage() {