Compare commits

..

No commits in common. "041c26283b911fc9beebd0f513002d18158003bd" and "b7d7a3963aae6c852119e5088053f1fcab41ba8b" have entirely different histories.

1 changed files with 51 additions and 40 deletions

View File

@ -36,46 +36,57 @@ export function WeatherSearchForm() {
} }
return ( return (
<div className='p-6 border-6 border-b-slate-200/50 '> <div className='p-6 border-6 border-b-slate-200/50 '>
<form onSubmit={handleFormSubmit} className="space-by-3"> <form onSubmit={handleFormSubmit} className="space-by-3">
<div className="relative"> <div className="relative">
<div className="absolute inset-y-0 left-4 flex items-center pl-3 pointer-events-none"> <div className="absolute inset-y-0 left-4 flex items-center pl-3 pointer-events-none">
<Search className="w-5 h-5 text-gray-500 dark:text-gray-400" /> <Search className="w-5 h-5 text-gray-500 dark:text-gray-400" />
</div>
<Input
type="text"
value={city}
onChange={handleInputChange}
placeholder="请输入城市名称"
disabled={isLoading}
className={cn('pl-10 pr-4 py-2 w-full text-base rounded-xl bg-slate-50/50 focus:bg-white transition-all', inputError && 'border-red-500') }
/>
</div> </div>
<Input {inputError && (
type="text" <div className=" flex items-center gap-2 px-3 py-2 rounded-lg bg-red-50/80 animated-in slide-in-from-top-1 fade-in">
value={city} <AlertCircle className="inline w-4 h-4 text-red-500 mt-0.5" />
onChange={handleInputChange} <p className="text-red-500 text-xs">{inputError}</p>
placeholder="请输入城市名称" </div>
disabled={isLoading}
className={cn('pl-10 pr-4 py-2 w-full text-base rounded-xl bg-slate-50/50 focus:bg-white transition-all', inputError && 'border-red-500') }
/> )
</div> }
{inputError && (
<div className=" flex items-center gap-2 px-3 py-2 rounded-lg bg-red-50/80 animated-in slide-in-from-top-1 fade-in"> <div className='flex gap-2'>
<AlertCircle className="inline w-4 h-4 text-red-500 mt-0.5" /> <Button type="submit" disabled={isLoading || !city.trim()} className="mt-4 w-full">
<p className="text-red-500 text-xs">{inputError}</p> {isLoading ? <>
</div> <Loader2 className="animate-spin w-5 h-5 text-white" />
) <span>...</span>
} </> : (<>
<div className='flex gap-2'> <Search className="w-5 h-5 text-white" />
<Button type="submit" disabled={isLoading || !city.trim()} className="mt-4 w-full"> <span></span>
{isLoading ? <> </>)}
<Loader2 className="animate-spin w-5 h-5 text-white" />
<span>...</span>
</> : (<>
<Search className="w-5 h-5 text-white" />
<span></span>
</>)}
</Button>
{currentWeather && (
<Button type="button" variant="outline" onClick={refreshWeather} disabled={isLoading} className="mt-4 w-full" title='刷新数据'>
<RefreshCw className={cn("w-5 h-5", isLoading && "animate-spin")} />
</Button> </Button>
)} {currentWeather && (
</div> <Button type="button" variant="outline" onClick={refreshWeather} disabled={isLoading} className="mt-4 w-full" title='刷新数据'>
</form> <RefreshCw className={cn("w-5 h-5", isLoading && "animate-spin")} />
</div>
</Button>
)}
</div>
</form>
</div>
) )
} }