From f9d48af6587e450675ee50608efaf0814f79d811 Mon Sep 17 00:00:00 2001 From: zetaloop Date: Wed, 25 Feb 2026 15:56:24 +0800 Subject: [PATCH] refactor(search): add IconInput size variant and adopt across search bars --- app/(main)/page.tsx | 14 ++++++-------- app/(main)/search/page.tsx | 10 ++++++---- components/ui/icon-input.tsx | 27 ++++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/app/(main)/page.tsx b/app/(main)/page.tsx index cd64fcb..2dc703d 100644 --- a/app/(main)/page.tsx +++ b/app/(main)/page.tsx @@ -2,7 +2,7 @@ import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card, CardContent, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" -import { Input } from "@/components/ui/input" +import { IconInput } from "@/components/ui/icon-input" import { listGames, listPlayers, listShops } from "@/lib/api" import { GameIcon } from "@/lib/game-icons" import { ArrowRight, Search, ShoppingBag, Star } from "lucide-react" @@ -30,17 +30,15 @@ export default function HomePage() { diff --git a/app/(main)/search/page.tsx b/app/(main)/search/page.tsx index 9b2f2f8..7b504ff 100644 --- a/app/(main)/search/page.tsx +++ b/app/(main)/search/page.tsx @@ -5,6 +5,7 @@ import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card" import { Checkbox } from "@/components/ui/checkbox" +import { IconInput } from "@/components/ui/icon-input" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { @@ -560,12 +561,13 @@ function SearchPageContent() {
-
- - + } type="search" placeholder="搜索陪玩、游戏、标签..." - className="pl-9 h-12 rounded-xl border-border bg-card text-base shadow-[var(--shadow-card)] transition-shadow focus:shadow-[var(--shadow-card-hover)]" + className="border-border bg-card shadow-[var(--shadow-card)] transition-shadow focus:shadow-[var(--shadow-card-hover)]" value={searchQuery} onChange={(e) => setSearchQuery(e.target.value)} /> diff --git a/components/ui/icon-input.tsx b/components/ui/icon-input.tsx index 17ca542..9a138a4 100644 --- a/components/ui/icon-input.tsx +++ b/components/ui/icon-input.tsx @@ -6,17 +6,38 @@ import { Input } from "./input" interface IconInputProps extends React.ComponentProps<"input"> { icon?: React.ReactNode rightElement?: React.ReactNode + inputSize?: "default" | "lg" } -function IconInput({ icon, rightElement, className, ...props }: IconInputProps) { +function IconInput({ + icon, + rightElement, + inputSize = "default", + className, + ...props +}: IconInputProps) { + const isLg = inputSize === "lg" return (
{icon && ( -
+
{icon}
)} - + {rightElement && (
{rightElement}
)}