Improve homepage modeling loading state

Add a skeleton stripe for the modeling data! Won't show up in most cases because we load fast, but it helps things a lot when it does. (Also, will we keep loading fast with the cache changes on this query?)
This commit is contained in:
Emi Matchu 2021-07-11 18:16:57 -07:00
parent f2259d6487
commit 2a5ecb688a
2 changed files with 29 additions and 18 deletions

View file

@ -4,6 +4,7 @@ import gql from "graphql-tag";
import { import {
Box, Box,
Button, Button,
Center,
Flex, Flex,
HStack, HStack,
IconButton, IconButton,
@ -13,6 +14,7 @@ import {
InputRightElement, InputRightElement,
Link, Link,
ListItem, ListItem,
Skeleton,
Textarea, Textarea,
UnorderedList, UnorderedList,
useColorModeValue, useColorModeValue,
@ -406,7 +408,11 @@ function NewItemsSectionContent() {
); );
if (loading) { if (loading) {
const footer = <Box fontSize="xs" height="1em" />; const footer = (
<Center fontSize="xs" height="1.5em">
<Skeleton height="4px" width="100%" />
</Center>
);
return ( return (
<Delay> <Delay>
<ItemCardHStack> <ItemCardHStack>
@ -456,28 +462,29 @@ function NewItemsSectionContent() {
<SquareItemCard <SquareItemCard
key={item.id} key={item.id}
item={item} item={item}
footer={ footer={<ItemModelingSummary item={item} />}
item.speciesThatNeedModels.length > 0 ? (
<Box
fontSize="xs"
fontStyle="italic"
fontWeight="600"
opacity="0.8"
>
Need {item.speciesThatNeedModels.length}1 models
</Box>
) : (
<Box fontSize="xs" fontStyle="italic" opacity="0.8">
Fully modeled!
</Box>
)
}
/> />
))} ))}
</ItemCardHStack> </ItemCardHStack>
); );
} }
function ItemModelingSummary({ item }) {
if (item.speciesThatNeedModels.length > 0) {
return (
<Box fontSize="xs" fontStyle="italic" fontWeight="600" opacity="0.8">
Need {item.speciesThatNeedModels.length}1 models
</Box>
);
}
return (
<Box fontSize="xs" fontStyle="italic" opacity="0.8">
Fully modeled!
</Box>
);
}
function ItemCardHStack({ children }) { function ItemCardHStack({ children }) {
return ( return (
// HACK: I wanted to just have an HStack with overflow:auto and internal // HACK: I wanted to just have an HStack with overflow:auto and internal

View file

@ -126,7 +126,11 @@ function SquareItemCardLayout({
> >
{name} {name}
</div> </div>
{footer && <Box marginTop="2">{footer}</Box>} {footer && (
<Box marginTop="2" width="100%">
{footer}
</Box>
)}
</div> </div>
)} )}
</ClassNames> </ClassNames>