Skip to content

Commit ef8e92c

Browse files
fix: restore dynamic text colors for Pokemon cards
- Fix card text color logic that was accidentally removed - Restore proper contrast for light background Pokemon (normal, fairy, ice) - Ensure dark text on light backgrounds and white text on dark backgrounds - Fix Pokemon name and type pill text colors - Maintain beautiful card appearance with proper readability
1 parent b75a3b3 commit ef8e92c

1 file changed

Lines changed: 35 additions & 20 deletions

File tree

src/pages/Pokedex.jsx

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,24 @@ export default function Pokedex() {
408408
fontWeight: 600,
409409
fontSize: '0.9rem',
410410
backgroundColor: 'rgba(255,255,255,0.9)',
411+
color: '#333',
411412
boxShadow: '0 4px 12px rgba(0,0,0,0.15)',
412-
cursor: 'pointer'
413+
cursor: 'pointer',
414+
appearance: 'none',
415+
backgroundImage: `url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e")`,
416+
backgroundRepeat: 'no-repeat',
417+
backgroundPosition: 'right 8px center',
418+
backgroundSize: '16px',
419+
paddingRight: '32px'
413420
}}
414421
value={selectedType}
415422
onChange={(e) => setSelectedType(e.target.value)}
416423
>
417-
<option value="">All Types</option>
424+
<option value="" style={{ backgroundColor: 'white', color: '#333' }}>All Types</option>
418425
{availableTypes.map(type => (
419-
<option key={type} value={type}>{type.charAt(0).toUpperCase() + type.slice(1)}</option>
426+
<option key={type} value={type} style={{ backgroundColor: 'white', color: '#333' }}>
427+
{type.charAt(0).toUpperCase() + type.slice(1)}
428+
</option>
420429
))}
421430
</select>
422431

@@ -472,12 +481,14 @@ export default function Pokedex() {
472481
steel: ["#d7e0e6", "#9fb0bd"],
473482
normal: ["#f5f5f5", "#dcdcdc"]
474483
};
475-
const colors = typeColors[primaryType] || typeColors.normal;
476-
const cardStyle = {
477-
...cardBaseStyle,
478-
background: `linear-gradient(135deg, ${colors[0]}, ${colors[1]})`,
479-
color: "#111",
480-
};
484+
const colors = typeColors[primaryType] || typeColors.normal;
485+
// Determine text color based on background brightness
486+
const isLightBackground = primaryType === 'normal' || primaryType === 'fairy' || primaryType === 'ice';
487+
const cardStyle = {
488+
...cardBaseStyle,
489+
background: `linear-gradient(135deg, ${colors[0]}, ${colors[1]})`,
490+
color: isLightBackground ? "#333" : "#fff",
491+
};
481492

482493
return (
483494
<div
@@ -527,17 +538,21 @@ export default function Pokedex() {
527538
}}
528539
/>
529540

530-
<div className="card-name" style={{ color: "#fff" }}>
531-
{p.name}
532-
</div>
533-
534-
<div className="types" aria-hidden="false">
535-
{p.types.map((t) => (
536-
<div key={t.type.name} className="type-pill">
537-
{t.type.name}
538-
</div>
539-
))}
540-
</div>
541+
<div className="card-name" style={{ color: isLightBackground ? "#333" : "#fff" }}>
542+
{p.name}
543+
</div>
544+
545+
<div className="types" aria-hidden="false">
546+
{p.types.map((t) => (
547+
<div
548+
key={t.type.name}
549+
className="type-pill"
550+
style={{ color: isLightBackground ? "#333" : "#fff" }}
551+
>
552+
{t.type.name}
553+
</div>
554+
))}
555+
</div>
541556

542557
<img
543558
src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/items/poke-ball.png"

0 commit comments

Comments
 (0)