From d1d98e2f7276813e855dd9cf983c149aa46b80c4 Mon Sep 17 00:00:00 2001 From: Matt Dunn-Rankin Date: Wed, 22 Apr 2020 15:24:38 -0700 Subject: [PATCH] add item list skeleton while loading --- src/ItemList.js | 29 ++++++++++++++++- src/WardrobePage.js | 78 +++++++++++++++++++++++++++++---------------- 2 files changed, 79 insertions(+), 28 deletions(-) diff --git a/src/ItemList.js b/src/ItemList.js index 659d2a2..b03f63b 100644 --- a/src/ItemList.js +++ b/src/ItemList.js @@ -1,5 +1,5 @@ import React from "react"; -import { Box, Image, PseudoBox, Stack } from "@chakra-ui/core"; +import { Box, Image, PseudoBox, Stack, Skeleton } from "@chakra-ui/core"; function ItemList({ items, wornItemIds, onWearItem }) { return ( @@ -17,6 +17,22 @@ function ItemList({ items, wornItemIds, onWearItem }) { ); } +function ItemListSkeleton() { + return ( + + + + + + + + + + + + ); +} + function Item({ item, isWorn, onWear }) { return ( + + + + + ); +} + function ItemThumbnail({ src, isWorn }) { return ( { + if (error) { + toast({ + title: "We couldn't load this outfit 😖", + description: "Please reload the page to try again. Sorry!", + status: "error", + isClosable: true, + duration: Infinity, + }); + } + }, [error, toast]); + return ( )} @@ -191,21 +205,29 @@ function SearchPanel({ query, wornItemIds, onWearItem }) { ); } -function ItemsPanel({ zonesAndItems, onWearItem }) { +function ItemsPanel({ zonesAndItems, loading, onWearItem }) { return ( - {zonesAndItems.map(({ zoneName, items, wornItemId }) => ( - - {zoneName} - - - ))} + {loading && + [1, 2, 3].map((i) => ( + + + + + ))} + {!loading && + zonesAndItems.map(({ zoneName, items, wornItemId }) => ( + + {zoneName} + + + ))} ); @@ -213,21 +235,23 @@ function ItemsPanel({ zonesAndItems, onWearItem }) { function OutfitHeading() { return ( - - - - {({ isEditing, onRequestEdit }) => ( - <> - - - {!isEditing && ( - - )} - - )} - - - + + + + + {({ isEditing, onRequestEdit }) => ( + <> + + + {!isEditing && ( + + )} + + )} + + + + ); }