Skip to content

Commit

Permalink
Merge pull request #27 from chrisvasqm/improve-loading-indicators
Browse files Browse the repository at this point in the history
Improve cards loading indicators
  • Loading branch information
chrisvasqm authored May 14, 2024
2 parents f8f4e25 + 9f69ba5 commit dc5ffcd
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/components/pokemon/PokemonCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, Image, Skeleton, Text, VStack } from "@chakra-ui/react"
import { Card, Image, Skeleton, Spinner, Text, VStack } from "@chakra-ui/react"
import { motion } from 'framer-motion'
import { Link } from "react-router-dom"
import { capitalizeName, getPrimaryColorByType } from "../../common"
Expand Down Expand Up @@ -30,16 +30,33 @@ const PokemonCard = ({ result }: Props) => {
boxShadow={'lg'}
borderRadius={'xl'}
backgroundColor={typeColor}
alignItems={'center'}
justifyContent={'center'}
minWidth='40px'
minHeight='180px'>
<VStack>
<Image id='card-image' src={pokemon?.sprites.other["official-artwork"].front_default || "/src/assets/pokeball.png"} />
<Text id='card-name' fontWeight={'semibold'}>{capitalizeName(pokemon?.name || '')}</Text>
</VStack>

{isLoading && <Spinner boxSize={'40px'} />}

{!isLoading &&
<VStack height={'100%'} align={'center'} justify={'center'}>

<Image
id='card-image'
boxSize={'130px'}
objectFit={'contain'}
src={pokemon?.sprites.other["official-artwork"].front_default || "/src/assets/pokeball.png"} />

<Text
id='card-name'
fontWeight={'semibold'}>
{capitalizeName(pokemon?.name || '')}
</Text>

</VStack>}
</Card>
</Skeleton>
</Link>
</motion.div>
</motion.div >
)
}

Expand Down

0 comments on commit dc5ffcd

Please sign in to comment.