Refactor OutfitCard a bit

Preparing to make a skeleton version for loading!
This commit is contained in:
Emi Matchu 2021-01-08 00:35:09 -08:00
parent 3804457839
commit b478f35103

View file

@ -44,6 +44,14 @@ function UserOutfitsPageContent() {
svgUrl svgUrl
imageUrl(size: $size) imageUrl(size: $size)
} }
species {
id
name
}
color {
id
name
}
...PetAppearanceForGetVisibleLayers ...PetAppearanceForGetVisibleLayers
} }
itemAppearances { itemAppearances {
@ -55,6 +63,10 @@ function UserOutfitsPageContent() {
} }
...ItemAppearanceForGetVisibleLayers ...ItemAppearanceForGetVisibleLayers
} }
wornItems {
id
name
}
} }
} }
} }
@ -96,11 +108,38 @@ function UserOutfitsPageContent() {
} }
function OutfitCard({ outfit }) { function OutfitCard({ outfit }) {
const thumbnailUrl = buildOutfitThumbnailUrl( const image = (
<Box
as="img"
src={buildOutfitThumbnailUrl(
outfit.petAppearance, outfit.petAppearance,
outfit.itemAppearances outfit.itemAppearances
)}
width={150}
height={150}
alt="Outfit thumbnail"
/>
); );
return (
<Box
as={Link}
to={`/outfits/${outfit.id}`}
display="block"
transition="all 0.2s"
_hover={{ transform: `scale(1.05)` }}
_focus={{
transform: `scale(1.05)`,
boxShadow: "outline",
outline: "none",
}}
>
<OutfitCardLayout image={image} caption={outfit.name} />
</Box>
);
}
function OutfitCardLayout({ image, caption }) {
const { brightBackground } = useCommonStyles(); const { brightBackground } = useCommonStyles();
return ( return (
@ -114,26 +153,17 @@ function OutfitCard({ outfit }) {
width="calc(150px + 2em)" width="calc(150px + 2em)"
backgroundColor={brightBackground} backgroundColor={brightBackground}
transition="all 0.2s" transition="all 0.2s"
as={Link}
to={`/outfits/${outfit.id}`}
_hover={{ transform: `scale(1.05)` }}
_focus={{
transform: `scale(1.05)`,
boxShadow: "outline",
outline: "none",
}}
> >
<Box <Box
as="img"
src={thumbnailUrl}
width={150} width={150}
height={150} height={150}
marginBottom="2" marginBottom="2"
borderRadius="md" borderRadius="md"
background="gray.600" background="gray.600"
transition="all 0.2s" >
/> {image}
<Box>{outfit.name}</Box> </Box>
<Box>{caption}</Box>
</Flex> </Flex>
); );
} }