2020-07-31 16:57:37 -07:00
|
|
|
import * as React from "react";
|
2020-07-31 22:11:32 -07:00
|
|
|
import gql from "graphql-tag";
|
2020-07-31 23:00:10 -07:00
|
|
|
import { useQuery, useMutation } from "@apollo/client";
|
2020-08-01 12:50:01 -07:00
|
|
|
import { css } from "emotion";
|
2020-07-31 16:57:37 -07:00
|
|
|
import {
|
|
|
|
Badge,
|
|
|
|
Box,
|
|
|
|
Drawer,
|
|
|
|
DrawerBody,
|
|
|
|
DrawerCloseButton,
|
|
|
|
DrawerContent,
|
|
|
|
DrawerHeader,
|
|
|
|
DrawerOverlay,
|
|
|
|
FormControl,
|
2020-07-31 22:11:32 -07:00
|
|
|
FormErrorMessage,
|
2020-07-31 16:57:37 -07:00
|
|
|
FormHelperText,
|
|
|
|
FormLabel,
|
2020-08-01 01:35:27 -07:00
|
|
|
HStack,
|
2020-07-31 16:57:37 -07:00
|
|
|
Link,
|
|
|
|
Select,
|
2020-07-31 22:11:32 -07:00
|
|
|
Spinner,
|
2020-08-01 01:35:27 -07:00
|
|
|
Stack,
|
2020-08-27 23:09:07 -07:00
|
|
|
Text,
|
2020-07-31 22:11:32 -07:00
|
|
|
useBreakpointValue,
|
2020-08-12 00:37:31 -07:00
|
|
|
useColorModeValue,
|
2020-08-01 12:50:01 -07:00
|
|
|
useDisclosure,
|
2020-12-25 09:08:33 -08:00
|
|
|
} from "@chakra-ui/react";
|
2020-08-01 12:50:01 -07:00
|
|
|
import { CheckCircleIcon, EditIcon, ExternalLinkIcon } from "@chakra-ui/icons";
|
2020-07-31 23:00:10 -07:00
|
|
|
|
2020-08-01 22:41:03 -07:00
|
|
|
import ItemLayerSupportModal from "./ItemLayerSupportModal";
|
2020-08-14 22:01:04 -07:00
|
|
|
import Metadata, { MetadataLabel, MetadataValue } from "./Metadata";
|
2020-08-01 01:35:27 -07:00
|
|
|
import { OutfitLayers } from "../../components/OutfitPreview";
|
|
|
|
import useOutfitAppearance from "../../components/useOutfitAppearance";
|
2020-08-05 00:25:25 -07:00
|
|
|
import { OutfitStateContext } from "../useOutfitState";
|
2020-08-29 14:54:02 -07:00
|
|
|
import useSupport from "./useSupport";
|
2020-07-31 16:57:37 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ItemSupportDrawer shows Support UI for the item when open.
|
|
|
|
*
|
|
|
|
* This component controls the drawer element. The actual content is imported
|
|
|
|
* from another lazy-loaded component!
|
|
|
|
*/
|
2020-08-05 00:25:25 -07:00
|
|
|
function ItemSupportDrawer({ item, isOpen, onClose }) {
|
2020-09-12 19:29:20 -07:00
|
|
|
const placement = useBreakpointValue({ base: "bottom", lg: "right" });
|
2020-07-31 22:11:32 -07:00
|
|
|
|
2020-07-31 16:57:37 -07:00
|
|
|
return (
|
|
|
|
<Drawer
|
2020-07-31 22:11:32 -07:00
|
|
|
placement={placement}
|
2020-09-12 19:29:20 -07:00
|
|
|
size="md"
|
2020-07-31 16:57:37 -07:00
|
|
|
isOpen={isOpen}
|
|
|
|
onClose={onClose}
|
|
|
|
// blockScrollOnMount doesn't matter on our fullscreen UI, but the
|
|
|
|
// default implementation breaks out layout somehow 🤔 idk, let's not!
|
|
|
|
blockScrollOnMount={false}
|
|
|
|
>
|
|
|
|
<DrawerOverlay>
|
2020-08-01 01:35:27 -07:00
|
|
|
<DrawerContent
|
|
|
|
maxHeight={placement === "bottom" ? "90vh" : undefined}
|
|
|
|
overflow="auto"
|
|
|
|
>
|
2020-07-31 16:57:37 -07:00
|
|
|
<DrawerCloseButton />
|
2020-08-12 00:37:31 -07:00
|
|
|
<DrawerHeader>
|
2020-07-31 16:57:37 -07:00
|
|
|
{item.name}
|
2020-07-31 22:11:32 -07:00
|
|
|
<Badge colorScheme="pink" marginLeft="3">
|
2020-07-31 16:57:37 -07:00
|
|
|
Support <span aria-hidden="true">💖</span>
|
|
|
|
</Badge>
|
|
|
|
</DrawerHeader>
|
2020-08-14 22:01:04 -07:00
|
|
|
<DrawerBody paddingBottom="5">
|
|
|
|
<Metadata>
|
2020-08-27 22:33:32 -07:00
|
|
|
<MetadataLabel>Item ID:</MetadataLabel>
|
2020-08-14 22:01:04 -07:00
|
|
|
<MetadataValue>{item.id}</MetadataValue>
|
2020-08-27 23:09:07 -07:00
|
|
|
<MetadataLabel>Restricted zones:</MetadataLabel>
|
|
|
|
<MetadataValue>
|
|
|
|
<ItemSupportRestrictedZones item={item} />
|
|
|
|
</MetadataValue>
|
2020-08-14 22:01:04 -07:00
|
|
|
</Metadata>
|
|
|
|
<Stack spacing="8" marginTop="6">
|
|
|
|
<ItemSupportFields item={item} />
|
|
|
|
<ItemSupportAppearanceLayers item={item} />
|
|
|
|
</Stack>
|
2020-07-31 16:57:37 -07:00
|
|
|
</DrawerBody>
|
|
|
|
</DrawerContent>
|
|
|
|
</DrawerOverlay>
|
|
|
|
</Drawer>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-27 23:09:07 -07:00
|
|
|
function ItemSupportRestrictedZones({ item }) {
|
|
|
|
const { speciesId, colorId } = React.useContext(OutfitStateContext);
|
|
|
|
|
|
|
|
// NOTE: It would be a better reflection of the data to just query restricted
|
|
|
|
// zones right off the item... but we already have them in cache from
|
|
|
|
// the appearance, so query them that way to be instant in practice!
|
|
|
|
const { loading, error, data } = useQuery(
|
|
|
|
gql`
|
|
|
|
query ItemSupportRestrictedZones(
|
|
|
|
$itemId: ID!
|
|
|
|
$speciesId: ID!
|
|
|
|
$colorId: ID!
|
|
|
|
) {
|
|
|
|
item(id: $itemId) {
|
|
|
|
id
|
|
|
|
appearanceOn(speciesId: $speciesId, colorId: $colorId) {
|
|
|
|
restrictedZones {
|
|
|
|
id
|
|
|
|
label
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{ variables: { itemId: item.id, speciesId, colorId } }
|
|
|
|
);
|
|
|
|
|
|
|
|
if (loading) {
|
|
|
|
return <Spinner size="xs" />;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
return <Text color="red.400">{error.message}</Text>;
|
|
|
|
}
|
|
|
|
|
|
|
|
const restrictedZones = data?.item?.appearanceOn?.restrictedZones || [];
|
|
|
|
if (restrictedZones.length === 0) {
|
|
|
|
return "None";
|
|
|
|
}
|
|
|
|
|
|
|
|
return restrictedZones
|
|
|
|
.map((z) => `${z.label} (${z.id})`)
|
|
|
|
.sort()
|
|
|
|
.join(", ");
|
|
|
|
}
|
|
|
|
|
2020-08-14 21:38:45 -07:00
|
|
|
function ItemSupportFields({ item }) {
|
|
|
|
const { loading, error, data } = useQuery(
|
2020-07-31 22:31:28 -07:00
|
|
|
gql`
|
2020-08-14 21:38:45 -07:00
|
|
|
query ItemSupportFields($itemId: ID!) {
|
2020-07-31 22:31:28 -07:00
|
|
|
item(id: $itemId) {
|
2020-08-01 00:04:11 -07:00
|
|
|
id
|
2020-07-31 22:31:28 -07:00
|
|
|
manualSpecialColor {
|
|
|
|
id
|
|
|
|
}
|
2020-08-14 21:38:45 -07:00
|
|
|
explicitlyBodySpecific
|
2020-07-31 22:31:28 -07:00
|
|
|
}
|
2020-07-31 22:11:32 -07:00
|
|
|
}
|
2020-07-31 22:31:28 -07:00
|
|
|
`,
|
2020-08-01 00:35:48 -07:00
|
|
|
{
|
|
|
|
variables: { itemId: item.id },
|
|
|
|
|
|
|
|
// HACK: I think it's a bug in @apollo/client 3.1.1 that, if the
|
|
|
|
// optimistic response sets `manualSpecialColor` to null, the query
|
|
|
|
// doesn't update, even though its cache has updated :/
|
|
|
|
//
|
|
|
|
// This cheap trick of changing the display name every re-render
|
|
|
|
// persuades Apollo that this is a different query, so it re-checks
|
|
|
|
// its cache and finds the empty `manualSpecialColor`. Weird!
|
2020-08-14 21:38:45 -07:00
|
|
|
displayName: `ItemSupportFields-${new Date()}`,
|
2020-08-01 00:35:48 -07:00
|
|
|
}
|
2020-07-31 22:31:28 -07:00
|
|
|
);
|
2020-07-31 22:11:32 -07:00
|
|
|
|
2020-08-14 21:38:45 -07:00
|
|
|
const errorColor = useColorModeValue("red.500", "red.300");
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{error && <Box color={errorColor}>{error.message}</Box>}
|
|
|
|
<ItemSupportSpecialColorFields
|
|
|
|
loading={loading}
|
|
|
|
error={error}
|
|
|
|
item={item}
|
|
|
|
manualSpecialColor={data?.item?.manualSpecialColor?.id}
|
|
|
|
/>
|
|
|
|
<ItemSupportPetCompatibilityRuleFields
|
|
|
|
loading={loading}
|
|
|
|
error={error}
|
|
|
|
item={item}
|
|
|
|
explicitlyBodySpecific={data?.item?.explicitlyBodySpecific}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ItemSupportSpecialColorFields({
|
|
|
|
loading,
|
|
|
|
error,
|
|
|
|
item,
|
|
|
|
manualSpecialColor,
|
|
|
|
}) {
|
2020-08-29 14:54:02 -07:00
|
|
|
const { supportSecret } = useSupport();
|
2020-08-14 21:38:45 -07:00
|
|
|
|
2020-07-31 23:40:05 -07:00
|
|
|
const {
|
|
|
|
loading: colorsLoading,
|
|
|
|
error: colorsError,
|
|
|
|
data: colorsData,
|
|
|
|
} = useQuery(
|
|
|
|
gql`
|
|
|
|
query ItemSupportDrawerAllColors {
|
|
|
|
allColors {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
isStandard
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
);
|
|
|
|
|
2020-07-31 23:00:10 -07:00
|
|
|
const [
|
|
|
|
mutate,
|
2020-07-31 23:40:05 -07:00
|
|
|
{ loading: mutationLoading, error: mutationError, data: mutationData },
|
2020-07-31 23:00:10 -07:00
|
|
|
] = useMutation(gql`
|
|
|
|
mutation ItemSupportDrawerSetManualSpecialColor(
|
|
|
|
$itemId: ID!
|
|
|
|
$colorId: ID
|
|
|
|
$supportSecret: String!
|
|
|
|
) {
|
|
|
|
setManualSpecialColor(
|
|
|
|
itemId: $itemId
|
|
|
|
colorId: $colorId
|
|
|
|
supportSecret: $supportSecret
|
|
|
|
) {
|
2020-08-01 00:04:11 -07:00
|
|
|
id
|
2020-07-31 23:00:10 -07:00
|
|
|
manualSpecialColor {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
2020-08-14 21:38:45 -07:00
|
|
|
const onChange = React.useCallback(
|
|
|
|
(e) => {
|
|
|
|
const colorId = e.target.value || null;
|
|
|
|
const color =
|
|
|
|
colorId != null ? { __typename: "Color", id: colorId } : null;
|
|
|
|
mutate({
|
|
|
|
variables: {
|
|
|
|
itemId: item.id,
|
|
|
|
colorId,
|
|
|
|
supportSecret,
|
|
|
|
},
|
|
|
|
optimisticResponse: {
|
|
|
|
__typename: "Mutation",
|
|
|
|
setManualSpecialColor: {
|
|
|
|
__typename: "Item",
|
|
|
|
id: item.id,
|
|
|
|
manualSpecialColor: color,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).catch((e) => {
|
|
|
|
// Ignore errors from the promise, because we'll handle them on render!
|
|
|
|
});
|
|
|
|
},
|
|
|
|
[item.id, mutate, supportSecret]
|
|
|
|
);
|
|
|
|
|
2020-07-31 23:40:05 -07:00
|
|
|
const nonStandardColors =
|
|
|
|
colorsData?.allColors?.filter((c) => !c.isStandard) || [];
|
2020-07-31 22:11:32 -07:00
|
|
|
nonStandardColors.sort((a, b) => a.name.localeCompare(b.name));
|
|
|
|
|
2020-08-12 00:37:31 -07:00
|
|
|
const linkColor = useColorModeValue("green.500", "green.300");
|
|
|
|
|
2020-07-31 16:57:37 -07:00
|
|
|
return (
|
2020-08-14 21:38:45 -07:00
|
|
|
<FormControl isInvalid={Boolean(error || colorsError || mutationError)}>
|
2020-07-31 16:57:37 -07:00
|
|
|
<FormLabel>Special color</FormLabel>
|
2020-07-31 22:11:32 -07:00
|
|
|
<Select
|
2020-07-31 22:31:28 -07:00
|
|
|
placeholder={
|
2020-08-14 21:38:45 -07:00
|
|
|
loading || colorsLoading
|
2020-07-31 23:40:05 -07:00
|
|
|
? "Loading…"
|
|
|
|
: "Default: Auto-detect from item description"
|
2020-07-31 22:31:28 -07:00
|
|
|
}
|
2020-08-14 21:38:45 -07:00
|
|
|
value={manualSpecialColor?.id}
|
2020-08-01 00:04:11 -07:00
|
|
|
isDisabled={mutationLoading}
|
2020-07-31 23:00:10 -07:00
|
|
|
icon={
|
2020-08-14 21:38:45 -07:00
|
|
|
loading || colorsLoading || mutationLoading ? (
|
2020-07-31 23:00:10 -07:00
|
|
|
<Spinner />
|
2020-07-31 23:40:05 -07:00
|
|
|
) : mutationData ? (
|
2020-07-31 23:00:10 -07:00
|
|
|
<CheckCircleIcon />
|
|
|
|
) : undefined
|
|
|
|
}
|
2020-08-14 21:38:45 -07:00
|
|
|
onChange={onChange}
|
2020-07-31 22:11:32 -07:00
|
|
|
>
|
|
|
|
{nonStandardColors.map((color) => (
|
|
|
|
<option key={color.id} value={color.id}>
|
|
|
|
{color.name}
|
|
|
|
</option>
|
|
|
|
))}
|
2020-07-31 16:57:37 -07:00
|
|
|
</Select>
|
2020-07-31 23:40:05 -07:00
|
|
|
{colorsError && (
|
|
|
|
<FormErrorMessage>{colorsError.message}</FormErrorMessage>
|
|
|
|
)}
|
|
|
|
{mutationError && (
|
|
|
|
<FormErrorMessage>{mutationError.message}</FormErrorMessage>
|
|
|
|
)}
|
2020-08-14 21:38:45 -07:00
|
|
|
{!colorsError && !mutationError && (
|
2020-07-31 22:11:32 -07:00
|
|
|
<FormHelperText>
|
|
|
|
This controls which previews we show on the{" "}
|
|
|
|
<Link
|
|
|
|
href={`https://impress.openneo.net/items/${
|
|
|
|
item.id
|
|
|
|
}-${item.name.replace(/ /g, "-")}`}
|
2020-08-12 00:37:31 -07:00
|
|
|
color={linkColor}
|
2020-07-31 22:11:32 -07:00
|
|
|
isExternal
|
|
|
|
>
|
|
|
|
item page <ExternalLinkIcon />
|
|
|
|
</Link>
|
|
|
|
.
|
|
|
|
</FormHelperText>
|
|
|
|
)}
|
2020-07-31 16:57:37 -07:00
|
|
|
</FormControl>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-14 21:38:45 -07:00
|
|
|
function ItemSupportPetCompatibilityRuleFields({
|
|
|
|
loading,
|
|
|
|
error,
|
|
|
|
item,
|
|
|
|
explicitlyBodySpecific,
|
|
|
|
}) {
|
2020-08-29 14:54:02 -07:00
|
|
|
const { supportSecret } = useSupport();
|
2020-08-14 21:38:45 -07:00
|
|
|
|
|
|
|
const [
|
|
|
|
mutate,
|
|
|
|
{ loading: mutationLoading, error: mutationError, data: mutationData },
|
|
|
|
] = useMutation(gql`
|
|
|
|
mutation ItemSupportDrawerSetItemExplicitlyBodySpecific(
|
|
|
|
$itemId: ID!
|
|
|
|
$explicitlyBodySpecific: Boolean!
|
|
|
|
$supportSecret: String!
|
|
|
|
) {
|
|
|
|
setItemExplicitlyBodySpecific(
|
|
|
|
itemId: $itemId
|
|
|
|
explicitlyBodySpecific: $explicitlyBodySpecific
|
|
|
|
supportSecret: $supportSecret
|
|
|
|
) {
|
|
|
|
id
|
|
|
|
explicitlyBodySpecific
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
const onChange = React.useCallback(
|
|
|
|
(e) => {
|
|
|
|
const explicitlyBodySpecific = e.target.value === "true";
|
|
|
|
mutate({
|
|
|
|
variables: {
|
|
|
|
itemId: item.id,
|
|
|
|
explicitlyBodySpecific,
|
|
|
|
supportSecret,
|
|
|
|
},
|
|
|
|
optimisticResponse: {
|
|
|
|
__typename: "Mutation",
|
|
|
|
setItemExplicitlyBodySpecific: {
|
|
|
|
__typename: "Item",
|
|
|
|
id: item.id,
|
|
|
|
explicitlyBodySpecific,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).catch((e) => {
|
|
|
|
// Ignore errors from the promise, because we'll handle them on render!
|
|
|
|
});
|
|
|
|
},
|
|
|
|
[item.id, mutate, supportSecret]
|
|
|
|
);
|
|
|
|
|
2020-08-11 23:05:38 -07:00
|
|
|
return (
|
2020-08-14 21:38:45 -07:00
|
|
|
<FormControl isInvalid={Boolean(error || mutationError)}>
|
2020-08-11 23:05:38 -07:00
|
|
|
<FormLabel>Pet compatibility rule</FormLabel>
|
2020-08-14 21:38:45 -07:00
|
|
|
<Select
|
|
|
|
value={explicitlyBodySpecific ? "true" : "false"}
|
|
|
|
isDisabled={mutationLoading}
|
|
|
|
icon={
|
|
|
|
loading || mutationLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : mutationData ? (
|
|
|
|
<CheckCircleIcon />
|
|
|
|
) : undefined
|
|
|
|
}
|
|
|
|
onChange={onChange}
|
|
|
|
>
|
|
|
|
{loading ? (
|
|
|
|
<option>Loading…</option>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<option value="false">
|
|
|
|
Default: Auto-detect whether this fits all pets
|
|
|
|
</option>
|
|
|
|
<option value="true">
|
|
|
|
Body specific: Always different for each pet body
|
|
|
|
</option>
|
|
|
|
</>
|
|
|
|
)}
|
2020-08-11 23:05:38 -07:00
|
|
|
</Select>
|
2020-08-14 21:38:45 -07:00
|
|
|
{mutationError && (
|
|
|
|
<FormErrorMessage>{mutationError.message}</FormErrorMessage>
|
|
|
|
)}
|
|
|
|
{!mutationError && (
|
|
|
|
<FormHelperText>
|
|
|
|
By default, we assume Background-y zones fit all pets the same. When
|
|
|
|
items don't follow that rule, we can override it.
|
|
|
|
</FormHelperText>
|
|
|
|
)}
|
2020-08-11 23:05:38 -07:00
|
|
|
</FormControl>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-05 00:25:25 -07:00
|
|
|
/**
|
|
|
|
* NOTE: This component takes `outfitState` from context, rather than as a prop
|
|
|
|
* from its parent, for performance reasons. We want `Item` to memoize
|
|
|
|
* and generally skip re-rendering on `outfitState` changes, and to make
|
|
|
|
* sure the context isn't accessed when the drawer is closed. So we use
|
|
|
|
* it here, only when the drawer is open!
|
|
|
|
*/
|
2020-08-14 21:38:45 -07:00
|
|
|
function ItemSupportAppearanceLayers({ item }) {
|
2020-08-05 00:25:25 -07:00
|
|
|
const outfitState = React.useContext(OutfitStateContext);
|
2020-08-28 22:58:39 -07:00
|
|
|
const { speciesId, colorId, pose, appearanceId } = outfitState;
|
2020-08-01 01:35:27 -07:00
|
|
|
const { error, visibleLayers } = useOutfitAppearance({
|
|
|
|
speciesId,
|
|
|
|
colorId,
|
|
|
|
pose,
|
2020-08-28 22:58:39 -07:00
|
|
|
appearanceId,
|
2020-08-01 01:35:27 -07:00
|
|
|
wornItemIds: [item.id],
|
|
|
|
});
|
|
|
|
|
|
|
|
const biologyLayers = visibleLayers.filter((l) => l.source === "pet");
|
|
|
|
const itemLayers = visibleLayers.filter((l) => l.source === "item");
|
|
|
|
itemLayers.sort((a, b) => a.zone.depth - b.zone.depth);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<FormControl>
|
|
|
|
<FormLabel>Appearance layers</FormLabel>
|
2020-08-01 12:50:01 -07:00
|
|
|
<HStack spacing="4" overflow="auto" paddingX="1">
|
2020-08-01 01:35:27 -07:00
|
|
|
{itemLayers.map((itemLayer) => (
|
|
|
|
<ItemSupportAppearanceLayer
|
2020-08-01 15:30:26 -07:00
|
|
|
key={itemLayer.id}
|
2020-08-01 12:50:01 -07:00
|
|
|
item={item}
|
2020-08-01 14:12:57 -07:00
|
|
|
itemLayer={itemLayer}
|
|
|
|
biologyLayers={biologyLayers}
|
|
|
|
outfitState={outfitState}
|
2020-08-01 01:35:27 -07:00
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</HStack>
|
|
|
|
{error && <FormErrorMessage>{error.message}</FormErrorMessage>}
|
|
|
|
</FormControl>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-08-01 14:12:57 -07:00
|
|
|
function ItemSupportAppearanceLayer({
|
|
|
|
item,
|
|
|
|
itemLayer,
|
|
|
|
biologyLayers,
|
|
|
|
outfitState,
|
|
|
|
}) {
|
2020-08-01 12:50:01 -07:00
|
|
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
|
|
|
|
2020-08-12 00:43:26 -07:00
|
|
|
const iconButtonBgColor = useColorModeValue("green.100", "green.300");
|
|
|
|
const iconButtonColor = useColorModeValue("green.800", "gray.900");
|
|
|
|
|
2020-08-01 01:35:27 -07:00
|
|
|
return (
|
2020-08-01 12:50:01 -07:00
|
|
|
<Box
|
|
|
|
as="button"
|
|
|
|
width="150px"
|
|
|
|
textAlign="center"
|
|
|
|
fontSize="xs"
|
|
|
|
onClick={onOpen}
|
|
|
|
>
|
2020-08-01 01:35:27 -07:00
|
|
|
<Box
|
|
|
|
width="150px"
|
|
|
|
height="150px"
|
|
|
|
marginBottom="1"
|
|
|
|
boxShadow="md"
|
|
|
|
borderRadius="md"
|
2020-08-04 23:00:31 -07:00
|
|
|
position="relative"
|
2020-08-01 01:35:27 -07:00
|
|
|
>
|
|
|
|
<OutfitLayers visibleLayers={[...biologyLayers, itemLayer]} />
|
2020-08-04 23:00:31 -07:00
|
|
|
<Box
|
|
|
|
className={css`
|
|
|
|
opacity: 0;
|
|
|
|
transition: opacity 0.2s;
|
|
|
|
|
|
|
|
button:hover &,
|
|
|
|
button:focus & {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* On touch devices, always show the icon, to clarify that this is
|
|
|
|
* an interactable object! (Whereas I expect other devices to
|
|
|
|
* discover things by exploratory hover or focus!) */
|
|
|
|
@media (hover: none) {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
`}
|
2020-08-12 00:43:26 -07:00
|
|
|
background={iconButtonBgColor}
|
|
|
|
color={iconButtonColor}
|
2020-08-04 23:00:31 -07:00
|
|
|
borderRadius="full"
|
|
|
|
boxShadow="sm"
|
|
|
|
position="absolute"
|
|
|
|
bottom="2"
|
|
|
|
right="2"
|
|
|
|
padding="2"
|
|
|
|
alignItems="center"
|
|
|
|
justifyContent="center"
|
|
|
|
width="32px"
|
|
|
|
height="32px"
|
|
|
|
>
|
|
|
|
<EditIcon
|
|
|
|
boxSize="16px"
|
|
|
|
position="relative"
|
|
|
|
top="-2px"
|
|
|
|
right="-1px"
|
|
|
|
/>
|
|
|
|
</Box>
|
2020-08-01 01:35:27 -07:00
|
|
|
</Box>
|
2020-08-01 12:50:01 -07:00
|
|
|
<Box fontWeight="bold">{itemLayer.zone.label}</Box>
|
2020-08-01 01:35:27 -07:00
|
|
|
<Box>Zone ID: {itemLayer.zone.id}</Box>
|
2020-08-01 15:30:26 -07:00
|
|
|
<Box>DTI ID: {itemLayer.id}</Box>
|
2020-08-01 22:41:03 -07:00
|
|
|
<ItemLayerSupportModal
|
2020-08-01 12:50:01 -07:00
|
|
|
item={item}
|
|
|
|
itemLayer={itemLayer}
|
2020-08-01 14:12:57 -07:00
|
|
|
outfitState={outfitState}
|
2020-08-01 12:50:01 -07:00
|
|
|
isOpen={isOpen}
|
|
|
|
onClose={onClose}
|
|
|
|
/>
|
2020-08-01 01:35:27 -07:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-31 16:57:37 -07:00
|
|
|
export default ItemSupportDrawer;
|