import React from "react";
import { css } 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 }) {
return (
{visibleLayers.map((layer) => (
// We manage the fade-in and fade-out separately! The fade-out
// happens here, when the layer exits the DOM.
finishes preloading and
// applies the src to the underlying .
className={
doAnimations &&
css`
opacity: 0.01;
&[src] {
opacity: 1;
transition: opacity 0.2s;
}
`
}
// 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;