use ItemContainer in skeleton, too

This commit is contained in:
Matt Dunn-Rankin 2020-04-25 19:02:30 -07:00
parent 6794093e8e
commit 047dbb6327

View file

@ -49,9 +49,7 @@ export function ItemListSkeleton({ count }) {
return ( return (
<Flex direction="column"> <Flex direction="column">
{Array.from({ length: count }).map((_, i) => ( {Array.from({ length: count }).map((_, i) => (
<Box key={i} mb="2" mt="2"> <ItemSkeleton key={i} />
<ItemSkeleton />
</Box>
))} ))}
</Flex> </Flex>
); );
@ -63,33 +61,7 @@ export function Item({ item, outfitState, dispatchToOutfit }) {
const theme = useTheme(); const theme = useTheme();
return ( return (
<Box <ItemContainer>
mb="1"
mt="1"
p="1"
rounded="lg"
d="flex"
alignItems="center"
cursor="pointer"
border="1px"
borderColor="transparent"
className={
"item-container " +
css`
&:hover,
input:focus + & {
background-color: ${theme.colors.gray["100"]};
}
input:active + & {
border-color: ${theme.colors.green["400"]};
}
input:checked:focus + & {
border-color: ${theme.colors.green["800"]};
}
`
}
>
<ItemThumbnail src={item.thumbnailUrl} /> <ItemThumbnail src={item.thumbnailUrl} />
<Box width="3" /> <Box width="3" />
<ItemName>{item.name}</ItemName> <ItemName>{item.name}</ItemName>
@ -120,16 +92,54 @@ export function Item({ item, outfitState, dispatchToOutfit }) {
/> />
</Tooltip> </Tooltip>
)} )}
</Box> </ItemContainer>
); );
} }
function ItemSkeleton() { function ItemSkeleton() {
return ( return (
<Box d="flex" alignItems="center"> <ItemContainer>
<Skeleton width="50px" height="50px" /> <Box d="flex" alignItems="center">
<Box width="3" /> <Skeleton width="50px" height="50px" />
<Skeleton height="1.5rem" width="12rem" /> <Box width="3" />
<Skeleton height="1.5rem" width="12rem" />
</Box>
</ItemContainer>
);
}
function ItemContainer({ children }) {
const theme = useTheme();
return (
<Box
p="1"
mb="1"
mt="1"
rounded="lg"
d="flex"
alignItems="center"
cursor="pointer"
border="1px"
borderColor="transparent"
className={
"item-container " +
css`
&:hover,
input:focus + & {
background-color: ${theme.colors.gray["100"]};
}
input:active + & {
border-color: ${theme.colors.green["400"]};
}
input:checked:focus + & {
border-color: ${theme.colors.green["800"]};
}
`
}
>
{children}
</Box> </Box>
); );
} }