-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: (frontend) update for species and variety models
- Loading branch information
Jacob Potter
committed
Nov 1, 2024
1 parent
206b19b
commit 3f28828
Showing
19 changed files
with
2,539 additions
and
1,299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {Pokemon} from "../../models/pokemon.ts"; | ||
import {PokemonSpecies} from "../../models/pokemon.ts"; | ||
import {ComingSoon} from "../ui/ComingSoon.tsx"; | ||
|
||
export const EvolutionChain = ({}: { pokemon: Pokemon | null }) => <ComingSoon/>; | ||
export const EvolutionChain = ({}: { pokemon: PokemonSpecies | null }) => <ComingSoon/>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import {Pokemon} from "../../models/pokemon.ts"; | ||
import {PokemonSpecies} from "../../models/pokemon.ts"; | ||
import {ComingSoon} from "../ui/ComingSoon.tsx"; | ||
|
||
export const PokemonDetails = ({}: { pokemon: Pokemon | null }) => ( | ||
export const PokemonDetails = ({}: { pokemon: PokemonSpecies | null }) => ( | ||
<ComingSoon/>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,34 @@ | ||
import {Pokemon} from "../../models/pokemon.ts"; | ||
import {PokemonSpecies} from "../../models/pokemon.ts"; | ||
import {capitalize} from "lodash"; | ||
import {MouseEventHandler} from "react"; | ||
|
||
interface PokemonListItemProps { | ||
pokemon: Pokemon, | ||
pokemonSpecies: PokemonSpecies, | ||
active?: boolean, | ||
onPokemonSelect: (pokemonId: number) => void | ||
} | ||
|
||
export const PokemonListItem = ({ | ||
pokemon, | ||
pokemonSpecies, | ||
onPokemonSelect, | ||
active, | ||
|
||
}: PokemonListItemProps) => { | ||
|
||
|
||
const pokemon = pokemonSpecies.varieties[0]; | ||
|
||
|
||
const handleSelect: MouseEventHandler<HTMLButtonElement> = (e) => { | ||
e.preventDefault(); | ||
onPokemonSelect(pokemon.id) | ||
pokemon ? onPokemonSelect(pokemon.id) : console.error("No default variety found") | ||
|
||
} | ||
|
||
return (<button | ||
onClick={handleSelect} | ||
className={`flex items-center justify-between lg:space-x-3 bg-sky-500 sm:px-2 sm:py-1 md:px-4 md:py-2.5 rounded-lg shadow-lg ${!active ? "opacity-70" : ''}`}> | ||
<div className={'flex flex-col items-start justify-center space-y-1'}> | ||
<h2 className={'hidden md:block text-xs lg:text-md font-bold'}>{capitalize(pokemon.name)}</h2> | ||
<img className={'hidden md:block w-16 lg:w-20 h-auto'} src={pokemon.primary_type.img_url} | ||
alt={pokemon.primary_type.name}/> | ||
{pokemon.secondary_type && | ||
<img className={'hidden md:block w-16 lg:w-20 h-auto'} src={pokemon.secondary_type.img_url} | ||
alt={pokemon.secondary_type.name}/>} | ||
</div> | ||
<img src={pokemon.sprite_url} alt={pokemon.name} className={'h-auto w-12 sm:w-16 mx-auto'}/> | ||
className={`flex items-center justify-between lg:space-x-3 bg-sky-500 sm:px-2 sm:py-1 md:px-3 rounded-lg shadow-lg ${!active ? "opacity-70" : ''}`}> | ||
<h2 className={'hidden md:block text-xs lg:text-md font-bold'}>{capitalize(pokemon?.name)}</h2> | ||
<img src={pokemon?.sprite_url} alt={pokemon?.name} className={'h-auto w-12 sm:w-16 md:w-[4.75rem] mx-auto'}/> | ||
</button>) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.