diff --git a/src/OutfitPreview.js b/src/OutfitPreview.js
index 6a60add..e61584c 100644
--- a/src/OutfitPreview.js
+++ b/src/OutfitPreview.js
@@ -46,16 +46,6 @@ function OutfitPreview({ itemIds, speciesId, colorId }) {
{ variables: { itemIds, speciesId, colorId } }
);
- if (loading) {
- return (
-
-
-
-
-
- );
- }
-
if (error) {
return (
@@ -68,6 +58,37 @@ function OutfitPreview({ itemIds, speciesId, colorId }) {
);
}
+ return (
+
+ {getVisibleLayers(data).map((layer) => (
+
+
+
+ ))}
+ {loading && (
+
+
+
+
+
+
+
+
+ )}
+
+ );
+}
+
+function getVisibleLayers(data) {
+ if (!data) {
+ return [];
+ }
+
const allAppearances = [
data.petAppearance,
...data.items.map((i) => i.appearanceOn),
@@ -84,33 +105,19 @@ function OutfitPreview({ itemIds, speciesId, colorId }) {
);
visibleLayers.sort((a, b) => a.zone.depth - b.zone.depth);
- return (
-
- {visibleLayers.map((layer) => (
-
-
-
-
-
- ))}
-
- );
+ return visibleLayers;
}
function FullScreenCenter({ children }) {
return (
{children}