Overview
TheTypeSelector component displays all Pokemon types in a responsive grid, allowing users to select/deselect types with visual feedback. It’s designed to work with the TypeCalculator but can be used independently.
Import
Props
Array of currently selected type names
Callback function invoked when a type button is clicked
Usage Example
Features
Type-Based Theming
Each type button uses its corresponding theme fromPOKE_THEMES:
- Background uses
theme.bg(e.g.,bg-fire-600/20for fire) - Text uses
theme.text(e.g.,text-fire-400for fire)
- Background:
bg-zinc-900/50 - Text:
text-zinc-500 - Hover:
hover:text-zinc-300 hover:bg-zinc-800/50
Responsive Grid
The grid adapts to screen size:- Mobile: 9 rows × 2 columns
- Tablet: 6 rows × 3 columns
- Desktop: 4 rows × 5 columns (with 2 empty cells)
All Pokemon Types
Displays all 18 official Pokemon types fromALL_POKEMON_TYPES constant:
- Normal
- Fire
- Water
- Electric
- Grass
- Ice
- Fighting
- Poison
- Ground
- Flying
- Psychic
- Bug
- Rock
- Ghost
- Dragon
- Dark
- Steel
- Fairy
Component Structure
Styling Details
Button Base Styles
Typography
State Classes
Selected state:Type Theme Examples
Fire Type (Selected)
Water Type (Selected)
Grass Type (Selected)
Accessibility
- Uses semantic
<button>elements - Keyboard navigable (tab through types)
- Clear visual feedback for hover and selected states
- High contrast between selected and unselected states
Integration Example with TypeCalculator
Constants Used
ALL_POKEMON_TYPES
Location:@/constants
Array containing all 18 Pokemon type names in a specific order:
POKE_THEMES
Location:@/constants
Record mapping type names to theme objects:
Related Components
- TypeCalculator - Parent component that uses TypeSelector
- EffectivityResults - Displays calculation results
- TypeBadge - Individual type badge component
Performance Considerations
- Renders all 18 types at once (minimal performance impact)
- No virtualization needed due to small dataset
- Efficient re-renders through React’s reconciliation
Customization
You can customize the max selection limit by modifying the toggle handler:Source Location
/src/components/calculator/TypeSelector.tsx:1-40