import React from "react"; import { css, cx } from "emotion"; import { CSSTransition, TransitionGroup } from "react-transition-group"; import { Box, Flex, Icon, Image, Spinner, Text } from "@chakra-ui/core"; import { Delay } from "./util"; import useOutfitAppearance from "./useOutfitAppearance"; /** * OutfitPreview renders the actual image layers for the outfit we're viewing! */ function OutfitPreview({ outfitState }) { const { loading, error, visibleLayers } = useOutfitAppearance(outfitState); if (error) { return ( Could not load preview. Try again? ); } return ( ); } /** * OutfitLayers is the raw UI component for rendering outfit layers. It's * used both in the main outfit preview, and in other minor UIs! */ export function OutfitLayers({ loading, visibleLayers, doAnimations = false }) { // If we're fading in, we should use Image, to detect the load success. But // if not, just use a plain img, so that we load instantly without a flicker! const ImageTag = doAnimations ? Image : "img"; return ( {visibleLayers.map((layer) => ( finishes preloading and // applies the src to the underlying . className={cx( css` object-fit: contain; max-width: 100%; max-height: 100%; transition: opacity 0.2s; &.do-animations { opacity: 0.01; } &.do-animations[src] { opacity: 1; } `, doAnimations && "do-animations" )} // This sets up the cache to not need to reload images during // download! // TODO: Re-enable this once we get our change into Chakra // main. For now, this will make Downloads a bit slower, which // is fine! // crossOrigin="Anonymous" /> ))} {loading && ( )} ); } function FullScreenCenter({ children }) { return ( {children} ); } export default OutfitPreview;