diff --git a/src/app/WardrobePage/support/ItemSupportAppearanceLayerModal.js b/src/app/WardrobePage/support/ItemSupportAppearanceLayerModal.js index 16ef90fb..632e823b 100644 --- a/src/app/WardrobePage/support/ItemSupportAppearanceLayerModal.js +++ b/src/app/WardrobePage/support/ItemSupportAppearanceLayerModal.js @@ -2,6 +2,10 @@ import * as React from "react"; import { Button, Box, + FormControl, + FormErrorMessage, + FormHelperText, + FormLabel, HStack, Modal, ModalBody, @@ -9,74 +13,80 @@ import { ModalContent, ModalHeader, ModalOverlay, + Radio, + RadioGroup, } from "@chakra-ui/core"; import { ExternalLinkIcon } from "@chakra-ui/icons"; -function ItemSupportAppearanceLayerModal({ item, itemLayer, isOpen, onClose }) { +import { OutfitLayers } from "../../components/OutfitPreview"; +import SpeciesColorPicker from "../../components/SpeciesColorPicker"; +import useOutfitAppearance from "../../components/useOutfitAppearance"; + +function ItemSupportAppearanceLayerModal({ + item, + itemLayer, + outfitState, + isOpen, + onClose, +}) { return ( - + Layer {itemLayer.id}: {item.name} - - - ID: - - - {itemLayer.id} - - - Zone: - - + + ID: + {itemLayer.id} + Zone: + {itemLayer.zone.label} ({itemLayer.zone.id}) - - - Assets: - - - {itemLayer.svgUrl ? ( - - ) : ( - - )} - {itemLayer.imageUrl ? ( - - ) : ( - - )} - - + + Assets: + + + {itemLayer.svgUrl ? ( + + ) : ( + + )} + {itemLayer.imageUrl ? ( + + ) : ( + + )} + + + + + @@ -84,4 +94,122 @@ function ItemSupportAppearanceLayerModal({ item, itemLayer, isOpen, onClose }) { ); } +function ItemSupportAppearanceLayerPetCompatibility({ + item, + itemLayer, + outfitState, +}) { + const [selectedBiology, setSelectedBiology] = React.useState({ + speciesId: outfitState.speciesId, + colorId: outfitState.colorId, + pose: outfitState.pose, + isValid: true, + }); + const [visibleBiology, setVisibleBiology] = React.useState(selectedBiology); + console.log(selectedBiology, visibleBiology); + + const { loading, error, visibleLayers } = useOutfitAppearance({ + speciesId: visibleBiology.speciesId, + colorId: visibleBiology.colorId, + pose: visibleBiology.pose, + wornItemIds: [item.id], + }); + + const biologyLayers = visibleLayers.filter((l) => l.source === "pet"); + + return ( + + Pet compatibility + console.log(e)} + marginBottom="4" + > + + Fits all pets{" "} + + (Body ID: 0) + + + + Fits all pets with the same body as:{" "} + + (Body ID: 100) + + + + + + + + { + const speciesId = species.id; + const colorId = color.id; + + setSelectedBiology({ speciesId, colorId, isValid, pose }); + if (isValid) { + setVisibleBiology({ speciesId, colorId, isValid, pose }); + } + }} + /> + + {!error && ( + + If it doesn't look right, try some other options until it does! + + )} + {error && {error.message}} + + + ); +} + +function Metadata({ children }) { + return ( + + {children} + + ); +} + +function MetadataLabel({ children }) { + return ( + + {children} + + ); +} + +function MetadataValue({ children }) { + return ( + + {children} + + ); +} + export default ItemSupportAppearanceLayerModal; diff --git a/src/app/WardrobePage/support/ItemSupportDrawer.js b/src/app/WardrobePage/support/ItemSupportDrawer.js index 22750e36..4c2e3b54 100644 --- a/src/app/WardrobePage/support/ItemSupportDrawer.js +++ b/src/app/WardrobePage/support/ItemSupportDrawer.js @@ -250,9 +250,10 @@ function ItemSupportAppearanceFields({ item, outfitState }) { {itemLayers.map((itemLayer) => ( ))} @@ -261,7 +262,12 @@ function ItemSupportAppearanceFields({ item, outfitState }) { ); } -function ItemSupportAppearanceLayer({ biologyLayers, itemLayer, item }) { +function ItemSupportAppearanceLayer({ + item, + itemLayer, + biologyLayers, + outfitState, +}) { const { isOpen, onOpen, onClose } = useDisclosure(); return ( @@ -311,6 +317,7 @@ function ItemSupportAppearanceLayer({ biologyLayers, itemLayer, item }) { diff --git a/src/app/components/OutfitPreview.js b/src/app/components/OutfitPreview.js index bf9f5263..e80dd790 100644 --- a/src/app/components/OutfitPreview.js +++ b/src/app/components/OutfitPreview.js @@ -167,7 +167,7 @@ export function OutfitLayers({ opacity={isMounted && loading ? 1 : 0} transition={`opacity 0.2s ${loading ? loadingDelay : "0s"}`} > - + - + diff --git a/src/app/components/SpeciesColorPicker.js b/src/app/components/SpeciesColorPicker.js index a669b1e8..0d6a9536 100644 --- a/src/app/components/SpeciesColorPicker.js +++ b/src/app/components/SpeciesColorPicker.js @@ -15,7 +15,9 @@ function SpeciesColorPicker({ speciesId, colorId, idealPose, - showPlaceholders, + showPlaceholders = false, + isDisabled = false, + size = "md", dark = false, onChange, }) { @@ -51,30 +53,38 @@ function SpeciesColorPicker({ const backgroundColor = dark ? "gray.600" : "white"; const borderColor = dark ? "transparent" : "green.600"; const textColor = dark ? "gray.50" : "inherit"; - const SpeciesColorSelect = ({ ...props }) => ( - + ); + }; if ((loadingMeta || loadingValids) && !showPlaceholders) { return ( @@ -125,7 +135,8 @@ function SpeciesColorPicker({ {allColors.length === 0 && ( @@ -141,11 +152,12 @@ function SpeciesColorPicker({ ))} - + {allSpecies.length === 0 && ( diff --git a/src/app/components/useOutfitAppearance.js b/src/app/components/useOutfitAppearance.js index 8b4a34be..0d2af3df 100644 --- a/src/app/components/useOutfitAppearance.js +++ b/src/app/components/useOutfitAppearance.js @@ -117,6 +117,7 @@ export const itemAppearanceFragment = gql` id svgUrl imageUrl(size: SIZE_600) + bodyId zone { id depth diff --git a/src/server/index.js b/src/server/index.js index ed4a435d..b36052a8 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -104,6 +104,12 @@ const typeDefs = gql` or if it's not as simple as a single SVG (e.g. animated). """ svgUrl: String + + """ + This layer can fit on PetAppearances with the same bodyId. "0" is a + special body ID that indicates it fits all PetAppearances. + """ + bodyId: ID! } # Cache for 1 week (unlikely to change)