Skip to content

Commit 7dd0405

Browse files
committed
fix(landing): make search bar theme-aware
Light mode: white background, dark text Dark mode: dark background, light text - Background: bg-white / dark:bg-zinc-900 - Text: text-foreground (theme variable) - Border: border-zinc-200 / dark:border-zinc-800 - Placeholder: zinc-400 / dark:zinc-500 - Disabled button: zinc-100 / dark:zinc-800
1 parent 025b757 commit 7dd0405

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

frontend/src/components/landing/HeroSearch.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { cn } from '@/lib/utils'
66
type VisualState = 'idle' | 'focused' | 'searching' | 'done'
77

88
const glowStyles: Record<VisualState, string> = {
9-
idle: 'shadow-[0_0_0_1px_rgba(75,139,190,0.3)]',
10-
focused: 'shadow-[0_0_0_2px_var(--python-blue),0_0_20px_rgba(75,139,190,0.4)]',
11-
searching: 'shadow-[0_0_0_2px_var(--python-yellow),0_0_30px_rgba(255,212,59,0.3)]',
12-
done: 'shadow-[0_0_0_2px_#34D399,0_0_20px_rgba(52,211,153,0.4)]',
9+
idle: 'shadow-[0_0_0_1px_rgba(75,139,190,0.2)] dark:shadow-[0_0_0_1px_rgba(75,139,190,0.3)]',
10+
focused: 'shadow-[0_0_0_2px_var(--python-blue),0_0_20px_rgba(75,139,190,0.2)] dark:shadow-[0_0_0_2px_var(--python-blue),0_0_20px_rgba(75,139,190,0.4)]',
11+
searching: 'shadow-[0_0_0_2px_var(--python-yellow),0_0_30px_rgba(255,212,59,0.15)] dark:shadow-[0_0_0_2px_var(--python-yellow),0_0_30px_rgba(255,212,59,0.3)]',
12+
done: 'shadow-[0_0_0_2px_#34D399,0_0_20px_rgba(52,211,153,0.2)] dark:shadow-[0_0_0_2px_#34D399,0_0_20px_rgba(52,211,153,0.4)]',
1313
}
1414

1515
const EXAMPLE_QUERIES = [
@@ -99,7 +99,9 @@ export const HeroSearch = forwardRef<HeroSearchHandle, Props>(function HeroSearc
9999
<form onSubmit={submit} className="w-full">
100100
<motion.div
101101
className={cn(
102-
'relative bg-zinc-900 dark:bg-zinc-900/90 backdrop-blur-sm rounded-2xl border border-zinc-700 dark:border-zinc-800/50 overflow-hidden transition-shadow duration-300',
102+
'relative backdrop-blur-sm rounded-2xl border overflow-hidden transition-shadow duration-300',
103+
'bg-white dark:bg-zinc-900/90',
104+
'border-zinc-200 dark:border-zinc-800/50',
103105
glowStyles[state]
104106
)}
105107
animate={searching ? { scale: [1, 1.005, 1] } : {}}
@@ -110,7 +112,7 @@ export const HeroSearch = forwardRef<HeroSearchHandle, Props>(function HeroSearc
110112
<div
111113
className="absolute inset-0 rounded-2xl"
112114
style={{
113-
background: 'linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent)',
115+
background: 'linear-gradient(90deg, transparent, rgba(128,128,128,0.05), transparent)',
114116
backgroundSize: '200% 100%',
115117
animation: 'shimmer 3s ease-in-out infinite',
116118
}}
@@ -127,7 +129,10 @@ export const HeroSearch = forwardRef<HeroSearchHandle, Props>(function HeroSearc
127129
)}
128130

129131
<div className="flex items-center gap-3 px-5 py-4">
130-
<div className={cn('transition-colors', searching ? 'text-[var(--python-yellow)]' : 'text-zinc-500')}>
132+
<div className={cn(
133+
'transition-colors',
134+
searching ? 'text-[var(--python-yellow)]' : 'text-zinc-400 dark:text-zinc-500'
135+
)}>
131136
{searching ? <Loader2 className="w-5 h-5 animate-spin" /> : <Search className="w-5 h-5" />}
132137
</div>
133138

@@ -140,12 +145,11 @@ export const HeroSearch = forwardRef<HeroSearchHandle, Props>(function HeroSearc
140145
onFocus={() => setFocused(true)}
141146
onBlur={() => setFocused(false)}
142147
placeholder={focused ? 'Search for anything...' : ''}
143-
className="w-full bg-transparent text-white text-lg placeholder:text-zinc-500 focus:outline-none caret-white"
144-
style={{ color: 'white' }}
148+
className="w-full bg-transparent text-lg focus:outline-none text-foreground placeholder:text-muted-foreground"
145149
/>
146150
{showAnimatedPlaceholder && (
147151
<div className="absolute inset-0 flex items-center pointer-events-none">
148-
<span className="text-zinc-400 text-lg">
152+
<span className="text-zinc-400 dark:text-zinc-500 text-lg">
149153
{animatedPlaceholder}
150154
<span className="animate-pulse">|</span>
151155
</span>
@@ -154,7 +158,11 @@ export const HeroSearch = forwardRef<HeroSearchHandle, Props>(function HeroSearc
154158
</div>
155159

156160
{value && !searching && (
157-
<button type="button" onClick={() => onChange('')} className="text-zinc-500 hover:text-zinc-300">
161+
<button
162+
type="button"
163+
onClick={() => onChange('')}
164+
className="text-zinc-400 hover:text-zinc-600 dark:text-zinc-500 dark:hover:text-zinc-300"
165+
>
158166
<X className="w-4 h-4" />
159167
</button>
160168
)}
@@ -166,7 +174,7 @@ export const HeroSearch = forwardRef<HeroSearchHandle, Props>(function HeroSearc
166174
'px-5 py-2 rounded-xl font-medium transition-all',
167175
value.trim() && !searching
168176
? 'bg-[var(--python-blue)] text-white hover:opacity-90'
169-
: 'bg-zinc-800 text-zinc-500 cursor-not-allowed'
177+
: 'bg-zinc-100 text-zinc-400 dark:bg-zinc-800 dark:text-zinc-500 cursor-not-allowed'
170178
)}
171179
>
172180
{searching ? 'Searching...' : 'Search'}

0 commit comments

Comments
 (0)