2020-09-11 23:56:47 -07:00
|
|
|
import React from "react";
|
2021-02-22 19:00:47 -08:00
|
|
|
import { ClassNames } from "@emotion/react";
|
2020-09-12 17:56:31 -07:00
|
|
|
import {
|
|
|
|
AspectRatio,
|
2020-09-12 22:21:00 -07:00
|
|
|
Button,
|
2020-09-12 17:56:31 -07:00
|
|
|
Box,
|
2020-11-08 15:46:11 -08:00
|
|
|
HStack,
|
2020-09-24 08:29:56 -07:00
|
|
|
IconButton,
|
2020-09-12 23:23:46 -07:00
|
|
|
SkeletonText,
|
2020-09-15 04:15:15 -07:00
|
|
|
Tooltip,
|
2020-09-12 22:21:00 -07:00
|
|
|
VisuallyHidden,
|
2020-09-12 17:56:31 -07:00
|
|
|
VStack,
|
2020-09-12 23:23:46 -07:00
|
|
|
useBreakpointValue,
|
2020-09-12 17:56:31 -07:00
|
|
|
useColorModeValue,
|
2020-09-12 22:45:58 -07:00
|
|
|
useTheme,
|
2020-09-12 22:21:00 -07:00
|
|
|
useToast,
|
2021-01-25 10:24:39 -08:00
|
|
|
useToken,
|
|
|
|
Wrap,
|
|
|
|
WrapItem,
|
2021-02-02 23:29:06 -08:00
|
|
|
Flex,
|
2021-02-06 15:46:10 -08:00
|
|
|
usePrefersReducedMotion,
|
2021-02-12 14:35:14 -08:00
|
|
|
Grid,
|
2020-12-25 09:08:33 -08:00
|
|
|
} from "@chakra-ui/react";
|
2020-09-12 23:10:29 -07:00
|
|
|
import {
|
|
|
|
CheckIcon,
|
|
|
|
ChevronRightIcon,
|
2021-01-26 15:02:11 -08:00
|
|
|
EditIcon,
|
2020-09-12 23:10:29 -07:00
|
|
|
StarIcon,
|
2020-09-20 21:08:16 -07:00
|
|
|
WarningIcon,
|
2021-02-02 23:29:06 -08:00
|
|
|
WarningTwoIcon,
|
2020-09-12 23:10:29 -07:00
|
|
|
} from "@chakra-ui/icons";
|
2020-09-24 08:29:56 -07:00
|
|
|
import { MdPause, MdPlayArrow } from "react-icons/md";
|
2020-09-11 23:56:47 -07:00
|
|
|
import gql from "graphql-tag";
|
2020-10-22 21:20:49 -07:00
|
|
|
import { useQuery, useMutation } from "@apollo/client";
|
2020-11-24 15:05:23 -08:00
|
|
|
import { Link, useParams } from "react-router-dom";
|
2020-09-11 23:56:47 -07:00
|
|
|
|
2020-11-23 09:34:46 -08:00
|
|
|
import ItemPageLayout, { SubtleSkeleton } from "./ItemPageLayout";
|
2021-02-06 15:46:10 -08:00
|
|
|
import { Delay, logAndCapture, usePageTitle } from "./util";
|
2021-02-10 13:49:37 -08:00
|
|
|
import HTML5Badge, { layerUsesHTML5 } from "./components/HTML5Badge";
|
2020-09-20 22:21:23 -07:00
|
|
|
import {
|
|
|
|
itemAppearanceFragment,
|
|
|
|
petAppearanceFragment,
|
|
|
|
} from "./components/useOutfitAppearance";
|
2021-02-09 20:28:03 -08:00
|
|
|
import { useOutfitPreview } from "./components/OutfitPreview";
|
2021-02-03 02:10:52 -08:00
|
|
|
import SpeciesColorPicker, {
|
|
|
|
useAllValidPetPoses,
|
|
|
|
getValidPoses,
|
|
|
|
getClosestPose,
|
|
|
|
} from "./components/SpeciesColorPicker";
|
2020-10-22 21:20:49 -07:00
|
|
|
import useCurrentUser from "./components/useCurrentUser";
|
2020-09-24 08:29:56 -07:00
|
|
|
import { useLocalStorage } from "./util";
|
2020-09-11 23:56:47 -07:00
|
|
|
|
|
|
|
function ItemPage() {
|
|
|
|
const { itemId } = useParams();
|
2020-09-12 19:29:20 -07:00
|
|
|
return <ItemPageContent itemId={itemId} />;
|
|
|
|
}
|
2020-09-11 23:56:47 -07:00
|
|
|
|
2020-09-12 19:29:20 -07:00
|
|
|
/**
|
|
|
|
* ItemPageContent is the content of ItemPage, but we also use it as the
|
|
|
|
* entry point for ItemPageDrawer! When embedded in ItemPageDrawer, the
|
|
|
|
* `isEmbedded` prop is true, so we know not to e.g. set the page title.
|
|
|
|
*/
|
|
|
|
export function ItemPageContent({ itemId, isEmbedded }) {
|
2020-10-22 21:20:49 -07:00
|
|
|
const { isLoggedIn } = useCurrentUser();
|
|
|
|
|
2020-09-12 18:32:06 -07:00
|
|
|
const { error, data } = useQuery(
|
2020-09-11 23:56:47 -07:00
|
|
|
gql`
|
|
|
|
query ItemPage($itemId: ID!) {
|
|
|
|
item(id: $itemId) {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
isNc
|
2020-11-08 15:13:30 -08:00
|
|
|
isPb
|
2020-09-11 23:56:47 -07:00
|
|
|
thumbnailUrl
|
2020-09-12 23:23:46 -07:00
|
|
|
description
|
2020-09-15 04:15:15 -07:00
|
|
|
createdAt
|
2021-04-07 16:48:41 -07:00
|
|
|
wakaValueText
|
2021-02-22 19:11:03 -08:00
|
|
|
|
|
|
|
# For Support users.
|
|
|
|
rarityIndex
|
|
|
|
isManuallyNc
|
2020-09-11 23:56:47 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2020-09-12 18:32:06 -07:00
|
|
|
{ variables: { itemId }, returnPartialData: true }
|
2020-09-11 23:56:47 -07:00
|
|
|
);
|
|
|
|
|
2020-09-12 19:29:20 -07:00
|
|
|
usePageTitle(data?.item?.name, { skip: isEmbedded });
|
2020-09-11 23:56:47 -07:00
|
|
|
|
|
|
|
if (error) {
|
|
|
|
return <Box color="red.400">{error.message}</Box>;
|
|
|
|
}
|
|
|
|
|
2020-09-12 18:32:06 -07:00
|
|
|
const item = data?.item;
|
2020-09-11 23:56:47 -07:00
|
|
|
|
2020-09-12 17:27:00 -07:00
|
|
|
return (
|
2020-11-23 09:34:46 -08:00
|
|
|
<ItemPageLayout item={item} isEmbedded={isEmbedded}>
|
|
|
|
<VStack spacing="8" marginTop="4">
|
|
|
|
<ItemPageDescription
|
|
|
|
description={item?.description}
|
2020-09-12 23:10:29 -07:00
|
|
|
isEmbedded={isEmbedded}
|
2020-11-23 09:34:46 -08:00
|
|
|
/>
|
|
|
|
<VStack spacing="4">
|
|
|
|
{isLoggedIn && <ItemPageOwnWantButtons itemId={itemId} />}
|
2020-11-23 09:36:05 -08:00
|
|
|
<ItemPageTradeLinks itemId={itemId} isEmbedded={isEmbedded} />
|
2020-11-23 09:34:46 -08:00
|
|
|
</VStack>
|
|
|
|
{!isEmbedded && <ItemPageOutfitPreview itemId={itemId} />}
|
|
|
|
</VStack>
|
|
|
|
</ItemPageLayout>
|
2020-09-11 23:56:47 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-23 09:34:46 -08:00
|
|
|
function ItemPageDescription({ description, isEmbedded }) {
|
|
|
|
// Show 2 lines of description text placeholder on small screens, or when
|
|
|
|
// embedded in the wardrobe page's narrow drawer. In larger contexts, show
|
|
|
|
// just 1 line.
|
|
|
|
const viewportNumDescriptionLines = useBreakpointValue({ base: 2, md: 1 });
|
|
|
|
const numDescriptionLines = isEmbedded ? 2 : viewportNumDescriptionLines;
|
2020-09-15 04:15:15 -07:00
|
|
|
|
|
|
|
return (
|
2020-11-23 09:34:46 -08:00
|
|
|
<Box width="100%" alignSelf="flex-start">
|
|
|
|
{description || (
|
|
|
|
<Box
|
|
|
|
maxWidth="40em"
|
|
|
|
minHeight={numDescriptionLines * 1.5 + "em"}
|
|
|
|
display="flex"
|
|
|
|
flexDirection="column"
|
|
|
|
alignItems="stretch"
|
|
|
|
justifyContent="center"
|
|
|
|
>
|
|
|
|
<Delay ms={500}>
|
|
|
|
<SkeletonText noOfLines={numDescriptionLines} spacing="4" />
|
|
|
|
</Delay>
|
|
|
|
</Box>
|
|
|
|
)}
|
|
|
|
</Box>
|
2020-09-15 04:15:15 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-12 22:21:00 -07:00
|
|
|
function ItemPageOwnWantButtons({ itemId }) {
|
2020-10-22 21:20:49 -07:00
|
|
|
const { loading, error, data } = useQuery(
|
2020-09-12 22:21:00 -07:00
|
|
|
gql`
|
|
|
|
query ItemPageOwnWantButtons($itemId: ID!) {
|
|
|
|
item(id: $itemId) {
|
|
|
|
id
|
|
|
|
currentUserOwnsThis
|
|
|
|
currentUserWantsThis
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-01-21 14:57:21 -08:00
|
|
|
{ variables: { itemId }, context: { sendAuth: true } }
|
2020-09-12 22:21:00 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
return <Box color="red.400">{error.message}</Box>;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Box display="flex">
|
2020-09-15 05:20:10 -07:00
|
|
|
<SubtleSkeleton isLoaded={!loading} marginRight="4">
|
2020-10-22 21:20:49 -07:00
|
|
|
<ItemPageOwnButton
|
|
|
|
itemId={itemId}
|
|
|
|
isChecked={data?.item?.currentUserOwnsThis}
|
|
|
|
/>
|
2020-09-15 05:20:10 -07:00
|
|
|
</SubtleSkeleton>
|
2020-09-12 22:21:00 -07:00
|
|
|
|
2020-09-15 05:20:10 -07:00
|
|
|
<SubtleSkeleton isLoaded={!loading}>
|
2020-10-22 21:20:49 -07:00
|
|
|
<ItemPageWantButton
|
|
|
|
itemId={itemId}
|
|
|
|
isChecked={data?.item?.currentUserWantsThis}
|
|
|
|
/>
|
|
|
|
</SubtleSkeleton>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ItemPageOwnButton({ itemId, isChecked }) {
|
|
|
|
const theme = useTheme();
|
|
|
|
const toast = useToast();
|
|
|
|
|
|
|
|
const [sendAddMutation] = useMutation(
|
|
|
|
gql`
|
|
|
|
mutation ItemPageOwnButtonAdd($itemId: ID!) {
|
|
|
|
addToItemsCurrentUserOwns(itemId: $itemId) {
|
|
|
|
id
|
|
|
|
currentUserOwnsThis
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{
|
|
|
|
variables: { itemId },
|
2021-01-21 14:57:21 -08:00
|
|
|
context: { sendAuth: true },
|
2020-10-22 21:20:49 -07:00
|
|
|
optimisticResponse: {
|
|
|
|
__typename: "Mutation",
|
|
|
|
addToItemsCurrentUserOwns: {
|
|
|
|
__typename: "Item",
|
|
|
|
id: itemId,
|
|
|
|
currentUserOwnsThis: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2020-10-23 22:43:56 -07:00
|
|
|
const [sendRemoveMutation] = useMutation(
|
|
|
|
gql`
|
|
|
|
mutation ItemPageOwnButtonRemove($itemId: ID!) {
|
|
|
|
removeFromItemsCurrentUserOwns(itemId: $itemId) {
|
|
|
|
id
|
|
|
|
currentUserOwnsThis
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{
|
|
|
|
variables: { itemId },
|
2021-01-21 14:57:21 -08:00
|
|
|
context: { sendAuth: true },
|
2020-10-23 22:43:56 -07:00
|
|
|
optimisticResponse: {
|
|
|
|
__typename: "Mutation",
|
|
|
|
removeFromItemsCurrentUserOwns: {
|
|
|
|
__typename: "Item",
|
|
|
|
id: itemId,
|
|
|
|
currentUserOwnsThis: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2020-10-22 21:20:49 -07:00
|
|
|
return (
|
2021-01-03 19:11:46 -08:00
|
|
|
<ClassNames>
|
|
|
|
{({ css }) => (
|
|
|
|
<Box as="label">
|
|
|
|
<VisuallyHidden
|
|
|
|
as="input"
|
|
|
|
type="checkbox"
|
|
|
|
checked={isChecked}
|
|
|
|
onChange={(e) => {
|
|
|
|
if (e.target.checked) {
|
|
|
|
sendAddMutation().catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
toast({
|
|
|
|
title: "We had trouble adding this to the items you own.",
|
|
|
|
description:
|
|
|
|
"Check your internet connection, and try again.",
|
|
|
|
status: "error",
|
|
|
|
duration: 5000,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
sendRemoveMutation().catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
toast({
|
|
|
|
title:
|
|
|
|
"We had trouble removing this from the items you own.",
|
|
|
|
description:
|
|
|
|
"Check your internet connection, and try again.",
|
|
|
|
status: "error",
|
|
|
|
duration: 5000,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
as="div"
|
|
|
|
colorScheme={isChecked ? "green" : "gray"}
|
|
|
|
size="lg"
|
|
|
|
cursor="pointer"
|
|
|
|
transitionDuration="0.4s"
|
|
|
|
className={css`
|
|
|
|
input:focus + & {
|
|
|
|
box-shadow: ${theme.shadows.outline};
|
|
|
|
}
|
|
|
|
`}
|
|
|
|
>
|
|
|
|
<IconCheckbox
|
|
|
|
icon={<CheckIcon />}
|
|
|
|
isChecked={isChecked}
|
|
|
|
marginRight="0.5em"
|
|
|
|
/>
|
|
|
|
I own this
|
|
|
|
</Button>
|
|
|
|
</Box>
|
|
|
|
)}
|
|
|
|
</ClassNames>
|
2020-10-22 21:20:49 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ItemPageWantButton({ itemId, isChecked }) {
|
|
|
|
const theme = useTheme();
|
|
|
|
const toast = useToast();
|
|
|
|
|
|
|
|
const [sendAddMutation] = useMutation(
|
|
|
|
gql`
|
|
|
|
mutation ItemPageWantButtonAdd($itemId: ID!) {
|
|
|
|
addToItemsCurrentUserWants(itemId: $itemId) {
|
|
|
|
id
|
|
|
|
currentUserWantsThis
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{
|
|
|
|
variables: { itemId },
|
2021-01-21 14:57:21 -08:00
|
|
|
context: { sendAuth: true },
|
2020-10-22 21:20:49 -07:00
|
|
|
optimisticResponse: {
|
|
|
|
__typename: "Mutation",
|
|
|
|
addToItemsCurrentUserWants: {
|
|
|
|
__typename: "Item",
|
|
|
|
id: itemId,
|
|
|
|
currentUserWantsThis: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2020-10-23 22:43:56 -07:00
|
|
|
const [sendRemoveMutation] = useMutation(
|
|
|
|
gql`
|
|
|
|
mutation ItemPageWantButtonRemove($itemId: ID!) {
|
|
|
|
removeFromItemsCurrentUserWants(itemId: $itemId) {
|
|
|
|
id
|
|
|
|
currentUserWantsThis
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{
|
|
|
|
variables: { itemId },
|
2021-01-21 14:57:21 -08:00
|
|
|
context: { sendAuth: true },
|
2020-10-23 22:43:56 -07:00
|
|
|
optimisticResponse: {
|
|
|
|
__typename: "Mutation",
|
|
|
|
removeFromItemsCurrentUserWants: {
|
|
|
|
__typename: "Item",
|
|
|
|
id: itemId,
|
|
|
|
currentUserWantsThis: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2020-10-22 21:20:49 -07:00
|
|
|
return (
|
2021-01-03 19:11:46 -08:00
|
|
|
<ClassNames>
|
|
|
|
{({ css }) => (
|
|
|
|
<Box as="label">
|
|
|
|
<VisuallyHidden
|
|
|
|
as="input"
|
|
|
|
type="checkbox"
|
|
|
|
isChecked={isChecked}
|
|
|
|
onChange={(e) => {
|
|
|
|
if (e.target.checked) {
|
|
|
|
sendAddMutation().catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
toast({
|
|
|
|
title: "We had trouble adding this to the items you want.",
|
|
|
|
description:
|
|
|
|
"Check your internet connection, and try again.",
|
|
|
|
status: "error",
|
|
|
|
duration: 5000,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
sendRemoveMutation().catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
toast({
|
|
|
|
title:
|
|
|
|
"We had trouble removing this from the items you want.",
|
|
|
|
description:
|
|
|
|
"Check your internet connection, and try again.",
|
|
|
|
status: "error",
|
|
|
|
duration: 5000,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
as="div"
|
|
|
|
colorScheme={isChecked ? "blue" : "gray"}
|
|
|
|
size="lg"
|
|
|
|
cursor="pointer"
|
|
|
|
transitionDuration="0.4s"
|
|
|
|
className={css`
|
|
|
|
input:focus + & {
|
|
|
|
box-shadow: ${theme.shadows.outline};
|
|
|
|
}
|
|
|
|
`}
|
|
|
|
>
|
|
|
|
<IconCheckbox
|
|
|
|
icon={<StarIcon />}
|
|
|
|
isChecked={isChecked}
|
|
|
|
marginRight="0.5em"
|
|
|
|
/>
|
|
|
|
I want this
|
|
|
|
</Button>
|
|
|
|
</Box>
|
|
|
|
)}
|
|
|
|
</ClassNames>
|
2020-09-12 22:21:00 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-23 09:36:05 -08:00
|
|
|
function ItemPageTradeLinks({ itemId, isEmbedded }) {
|
2020-11-09 06:26:29 -08:00
|
|
|
const { data, loading, error } = useQuery(
|
|
|
|
gql`
|
|
|
|
query ItemPageTradeLinks($itemId: ID!) {
|
|
|
|
item(id: $itemId) {
|
|
|
|
id
|
|
|
|
numUsersOfferingThis
|
|
|
|
numUsersSeekingThis
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{ variables: { itemId } }
|
|
|
|
);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
return <Box color="red.400">{error.message}</Box>;
|
|
|
|
}
|
|
|
|
|
2020-11-08 15:46:11 -08:00
|
|
|
return (
|
2020-11-09 06:26:29 -08:00
|
|
|
<HStack spacing="2">
|
|
|
|
<Box as="header" fontSize="sm" fontWeight="bold">
|
|
|
|
Trading:
|
|
|
|
</Box>
|
|
|
|
<SubtleSkeleton isLoaded={!loading}>
|
|
|
|
<ItemPageTradeLink
|
2020-11-24 15:01:24 -08:00
|
|
|
href={`/items/${itemId}/trades/offering`}
|
2020-11-09 06:26:29 -08:00
|
|
|
count={data?.item?.numUsersOfferingThis || 0}
|
|
|
|
label="offering"
|
|
|
|
colorScheme="green"
|
2020-11-23 09:36:05 -08:00
|
|
|
isEmbedded={isEmbedded}
|
2020-11-09 06:26:29 -08:00
|
|
|
/>
|
|
|
|
</SubtleSkeleton>
|
|
|
|
<SubtleSkeleton isLoaded={!loading}>
|
|
|
|
<ItemPageTradeLink
|
2020-11-24 15:01:24 -08:00
|
|
|
href={`/items/${itemId}/trades/seeking`}
|
2020-11-09 06:26:29 -08:00
|
|
|
count={data?.item?.numUsersSeekingThis || 0}
|
|
|
|
label="seeking"
|
|
|
|
colorScheme="blue"
|
2020-11-23 09:36:05 -08:00
|
|
|
isEmbedded={isEmbedded}
|
2020-11-09 06:26:29 -08:00
|
|
|
/>
|
|
|
|
</SubtleSkeleton>
|
|
|
|
</HStack>
|
2020-11-08 15:46:11 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:01:24 -08:00
|
|
|
function ItemPageTradeLink({ href, count, label, colorScheme, isEmbedded }) {
|
2020-11-08 15:46:11 -08:00
|
|
|
return (
|
|
|
|
<Button
|
2020-11-24 15:05:23 -08:00
|
|
|
as={Link}
|
|
|
|
to={href}
|
2020-11-23 09:36:05 -08:00
|
|
|
target={isEmbedded ? "_blank" : undefined}
|
2020-11-08 15:46:11 -08:00
|
|
|
size="xs"
|
|
|
|
variant="outline"
|
|
|
|
colorScheme={colorScheme}
|
|
|
|
borderRadius="full"
|
|
|
|
paddingRight="1"
|
|
|
|
>
|
|
|
|
<Box display="grid" gridTemplateAreas="single-area">
|
|
|
|
<Box
|
|
|
|
gridArea="single-area"
|
|
|
|
display="flex"
|
|
|
|
flexAlign="center"
|
|
|
|
justifyContent="center"
|
|
|
|
>
|
|
|
|
{count} {label} <ChevronRightIcon minHeight="1.2em" />
|
|
|
|
</Box>
|
|
|
|
<Box
|
|
|
|
gridArea="single-area"
|
|
|
|
display="flex"
|
|
|
|
flexAlign="center"
|
|
|
|
justifyContent="center"
|
|
|
|
visibility="hidden"
|
|
|
|
>
|
|
|
|
888 offering <ChevronRightIcon minHeight="1.2em" />
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-12 22:21:00 -07:00
|
|
|
function IconCheckbox({ icon, isChecked, ...props }) {
|
|
|
|
return (
|
|
|
|
<Box display="grid" gridTemplateAreas="the-same-area" {...props}>
|
|
|
|
<Box
|
|
|
|
gridArea="the-same-area"
|
|
|
|
width="1em"
|
|
|
|
height="1em"
|
|
|
|
border="2px solid currentColor"
|
|
|
|
borderRadius="md"
|
|
|
|
opacity={isChecked ? "0" : "0.75"}
|
|
|
|
transform={isChecked ? "scale(0.75)" : "none"}
|
|
|
|
transition="all 0.4s"
|
|
|
|
/>
|
|
|
|
<Box
|
|
|
|
gridArea="the-same-area"
|
|
|
|
display="flex"
|
|
|
|
opacity={isChecked ? "1" : "0"}
|
|
|
|
transform={isChecked ? "none" : "scale(0.1)"}
|
|
|
|
transition="all 0.4s"
|
|
|
|
>
|
|
|
|
{icon}
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-12 17:56:31 -07:00
|
|
|
function ItemPageOutfitPreview({ itemId }) {
|
2020-09-20 21:08:16 -07:00
|
|
|
const idealPose = React.useMemo(
|
|
|
|
() => (Math.random() > 0.5 ? "HAPPY_FEM" : "HAPPY_MASC"),
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
const [petState, setPetState] = React.useState({
|
2020-09-21 02:52:42 -07:00
|
|
|
// We'll fill these in once the canonical appearance data arrives.
|
2020-09-21 02:43:58 -07:00
|
|
|
speciesId: null,
|
|
|
|
colorId: null,
|
|
|
|
pose: null,
|
2021-02-09 22:31:50 -08:00
|
|
|
isValid: false,
|
2020-09-21 02:52:42 -07:00
|
|
|
|
|
|
|
// We use appearance ID, in addition to the above, to give the Apollo cache
|
|
|
|
// a really clear hint that the canonical pet appearance we preloaded is
|
|
|
|
// the exact right one to show! But switching species/color will null this
|
|
|
|
// out again, and that's okay. (We'll do an unnecessary reload if you
|
|
|
|
// switch back to it though... we could maybe do something clever there!)
|
|
|
|
appearanceId: null,
|
2020-09-20 21:08:16 -07:00
|
|
|
});
|
2021-02-03 14:27:02 -08:00
|
|
|
const [preferredSpeciesId, setPreferredSpeciesId] = useLocalStorage(
|
|
|
|
"DTIItemPreviewPreferredSpeciesId",
|
|
|
|
null
|
|
|
|
);
|
2021-02-03 15:24:12 -08:00
|
|
|
const [preferredColorId, setPreferredColorId] = useLocalStorage(
|
|
|
|
"DTIItemPreviewPreferredColorId",
|
|
|
|
null
|
|
|
|
);
|
2021-02-03 14:27:02 -08:00
|
|
|
|
2021-02-03 15:24:12 -08:00
|
|
|
const setPetStateFromUserAction = (newPetState) => {
|
|
|
|
setPetState(newPetState);
|
|
|
|
|
|
|
|
// When the user _intentionally_ chooses a species or color, save it in
|
|
|
|
// local storage for next time. (This won't update when e.g. their
|
|
|
|
// preferred species or color isn't available for this item, so we update
|
|
|
|
// to the canonical species or color automatically.)
|
|
|
|
//
|
|
|
|
// Re the "ifs", I have no reason to expect null to come in here, but,
|
|
|
|
// since this is touching client-persisted data, I want it to be even more
|
|
|
|
// reliable than usual!
|
|
|
|
if (newPetState.speciesId && newPetState.speciesId !== petState.speciesId) {
|
|
|
|
setPreferredSpeciesId(newPetState.speciesId);
|
|
|
|
}
|
|
|
|
if (newPetState.colorId && newPetState.colorId !== petState.colorId) {
|
|
|
|
if (colorIsBasic(newPetState.colorId)) {
|
|
|
|
// When the user chooses a basic color, don't index on it specifically,
|
|
|
|
// and instead reset to use default colors.
|
|
|
|
setPreferredColorId(null);
|
|
|
|
} else {
|
|
|
|
setPreferredColorId(newPetState.colorId);
|
|
|
|
}
|
2021-02-03 14:27:02 -08:00
|
|
|
}
|
|
|
|
};
|
2020-09-20 21:08:16 -07:00
|
|
|
|
2021-02-03 16:14:08 -08:00
|
|
|
// We don't need to reload this query when preferred species/color change, so
|
|
|
|
// cache their initial values here to use as query arguments.
|
|
|
|
const [initialPreferredSpeciesId] = React.useState(preferredSpeciesId);
|
|
|
|
const [initialPreferredColorId] = React.useState(preferredColorId);
|
|
|
|
|
2020-09-20 22:21:23 -07:00
|
|
|
// Start by loading the "canonical" pet and item appearance for the outfit
|
|
|
|
// preview. We'll use this to initialize both the preview and the picker.
|
2020-09-21 02:52:42 -07:00
|
|
|
//
|
2021-02-03 14:27:02 -08:00
|
|
|
// If the user has a preferred species saved from using the ItemPage in the
|
|
|
|
// past, we'll send that instead. This will return the appearance on that
|
|
|
|
// species if possible, or the default canonical species if not.
|
|
|
|
//
|
2020-09-21 02:52:42 -07:00
|
|
|
// TODO: If this is a non-standard pet color, like Mutant, we'll do an extra
|
|
|
|
// query after this loads, because our Apollo cache can't detect the
|
|
|
|
// shared item appearance. (For standard colors though, our logic to
|
|
|
|
// cover standard-color switches works for this preloading too.)
|
2021-02-03 02:10:52 -08:00
|
|
|
const { loading: loadingGQL, error: errorGQL, data } = useQuery(
|
2020-09-21 02:43:58 -07:00
|
|
|
gql`
|
2021-02-03 15:24:12 -08:00
|
|
|
query ItemPageOutfitPreview(
|
|
|
|
$itemId: ID!
|
|
|
|
$preferredSpeciesId: ID
|
|
|
|
$preferredColorId: ID
|
|
|
|
) {
|
2020-09-21 02:43:58 -07:00
|
|
|
item(id: $itemId) {
|
2020-09-20 22:21:23 -07:00
|
|
|
id
|
2021-02-02 16:29:20 -08:00
|
|
|
name
|
2021-02-12 18:15:45 -08:00
|
|
|
restrictedZones {
|
|
|
|
id
|
|
|
|
label @client
|
|
|
|
}
|
2021-02-12 16:09:11 -08:00
|
|
|
compatibleBodiesAndTheirZones {
|
|
|
|
body {
|
|
|
|
id
|
|
|
|
representsAllBodies
|
|
|
|
species {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
zones {
|
|
|
|
id
|
|
|
|
label @client
|
|
|
|
}
|
2021-02-02 15:22:08 -08:00
|
|
|
}
|
2021-02-03 15:24:12 -08:00
|
|
|
canonicalAppearance(
|
|
|
|
preferredSpeciesId: $preferredSpeciesId
|
|
|
|
preferredColorId: $preferredColorId
|
|
|
|
) {
|
2020-09-20 22:21:23 -07:00
|
|
|
id
|
2020-09-21 02:43:58 -07:00
|
|
|
...ItemAppearanceForOutfitPreview
|
|
|
|
body {
|
2020-09-20 22:21:23 -07:00
|
|
|
id
|
2021-02-03 15:24:12 -08:00
|
|
|
canonicalAppearance(preferredColorId: $preferredColorId) {
|
2020-09-21 02:43:58 -07:00
|
|
|
id
|
|
|
|
species {
|
|
|
|
id
|
2021-02-02 16:29:20 -08:00
|
|
|
name
|
2020-09-21 02:43:58 -07:00
|
|
|
}
|
|
|
|
color {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
pose
|
|
|
|
|
|
|
|
...PetAppearanceForOutfitPreview
|
|
|
|
}
|
2020-09-20 22:21:23 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-21 02:43:58 -07:00
|
|
|
${itemAppearanceFragment}
|
|
|
|
${petAppearanceFragment}
|
|
|
|
`,
|
|
|
|
{
|
2021-02-03 16:14:08 -08:00
|
|
|
variables: {
|
|
|
|
itemId,
|
|
|
|
preferredSpeciesId: initialPreferredSpeciesId,
|
|
|
|
preferredColorId: initialPreferredColorId,
|
|
|
|
},
|
2020-09-21 02:43:58 -07:00
|
|
|
onCompleted: (data) => {
|
|
|
|
const canonicalBody = data?.item?.canonicalAppearance?.body;
|
|
|
|
const canonicalPetAppearance = canonicalBody?.canonicalAppearance;
|
|
|
|
|
|
|
|
setPetState({
|
|
|
|
speciesId: canonicalPetAppearance?.species?.id,
|
|
|
|
colorId: canonicalPetAppearance?.color?.id,
|
|
|
|
pose: canonicalPetAppearance?.pose,
|
2021-02-09 22:31:50 -08:00
|
|
|
isValid: true,
|
2020-09-21 02:52:42 -07:00
|
|
|
appearanceId: canonicalPetAppearance?.id,
|
2020-09-21 02:43:58 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
2020-09-20 22:21:23 -07:00
|
|
|
|
2021-02-12 16:09:11 -08:00
|
|
|
const compatibleBodies =
|
|
|
|
data?.item?.compatibleBodiesAndTheirZones?.map(({ body }) => body) || [];
|
|
|
|
const compatibleBodiesAndTheirZones =
|
|
|
|
data?.item?.compatibleBodiesAndTheirZones || [];
|
2021-02-02 15:22:08 -08:00
|
|
|
|
2021-02-02 16:29:20 -08:00
|
|
|
// If there's only one compatible body, and the canonical species's name
|
|
|
|
// appears in the item name, then this is probably a species-specific item,
|
|
|
|
// and we should adjust the UI to avoid implying that other species could
|
|
|
|
// model it.
|
|
|
|
const isProbablySpeciesSpecific =
|
|
|
|
compatibleBodies.length === 1 &&
|
|
|
|
!compatibleBodies[0].representsAllBodies &&
|
|
|
|
(data?.item?.name || "").includes(
|
|
|
|
data?.item?.canonicalAppearance?.body?.canonicalAppearance?.species?.name
|
|
|
|
);
|
|
|
|
const couldProbablyModelMoreData = !isProbablySpeciesSpecific;
|
|
|
|
|
2021-02-03 02:10:52 -08:00
|
|
|
// TODO: Does this double-trigger the HTTP request with SpeciesColorPicker?
|
|
|
|
const {
|
|
|
|
loading: loadingValids,
|
|
|
|
error: errorValids,
|
|
|
|
valids,
|
|
|
|
} = useAllValidPetPoses();
|
|
|
|
|
2020-09-24 08:29:56 -07:00
|
|
|
const [hasAnimations, setHasAnimations] = React.useState(false);
|
|
|
|
const [isPaused, setIsPaused] = useLocalStorage("DTIOutfitIsPaused", true);
|
|
|
|
|
2021-02-09 20:28:03 -08:00
|
|
|
// This is like <OutfitPreview />, but we can use the appearance data, too!
|
|
|
|
const { appearance, preview } = useOutfitPreview({
|
|
|
|
speciesId: petState.speciesId,
|
|
|
|
colorId: petState.colorId,
|
|
|
|
pose: petState.pose,
|
|
|
|
appearanceId: petState.appearanceId,
|
|
|
|
wornItemIds: [itemId],
|
|
|
|
isLoading: loadingGQL || loadingValids,
|
|
|
|
spinnerVariant: "corner",
|
|
|
|
engine: "canvas",
|
|
|
|
onChangeHasAnimations: setHasAnimations,
|
|
|
|
});
|
|
|
|
|
|
|
|
// If there's an appearance loaded for this item, but it's empty, then the
|
|
|
|
// item is incompatible. (There should only be one item appearance: this one!)
|
|
|
|
const itemAppearance = appearance?.itemAppearances?.[0];
|
2021-02-09 21:39:29 -08:00
|
|
|
const itemLayers = itemAppearance?.layers || [];
|
|
|
|
const isCompatible = itemLayers.length > 0;
|
2021-02-10 13:49:37 -08:00
|
|
|
const usesHTML5 = itemLayers.every(layerUsesHTML5);
|
2021-02-09 20:28:03 -08:00
|
|
|
|
2020-09-21 02:43:58 -07:00
|
|
|
const borderColor = useColorModeValue("green.700", "green.400");
|
|
|
|
const errorColor = useColorModeValue("red.600", "red.400");
|
|
|
|
|
2021-02-03 02:10:52 -08:00
|
|
|
const error = errorGQL || errorValids;
|
2020-09-21 02:43:58 -07:00
|
|
|
if (error) {
|
|
|
|
return <Box color="red.400">{error.message}</Box>;
|
|
|
|
}
|
|
|
|
|
2020-09-12 17:56:31 -07:00
|
|
|
return (
|
2021-02-12 14:35:14 -08:00
|
|
|
<Grid
|
|
|
|
templateAreas={{
|
|
|
|
base: `
|
|
|
|
"preview"
|
|
|
|
"speciesColorPicker"
|
|
|
|
"speciesFacesPicker"
|
|
|
|
"zones"
|
|
|
|
`,
|
|
|
|
md: `
|
|
|
|
"preview speciesFacesPicker"
|
|
|
|
"speciesColorPicker zones"
|
|
|
|
`,
|
|
|
|
}}
|
|
|
|
templateRows={{
|
2021-02-12 17:33:34 -08:00
|
|
|
// HACK: Really I wanted 400px to match the natural height of the
|
|
|
|
// preview in md, but in Chromium that creates a scrollbar and
|
|
|
|
// 401px doesn't, not sure exactly why?
|
|
|
|
base: "auto auto 200px auto",
|
|
|
|
md: "401px auto",
|
2021-02-12 14:35:14 -08:00
|
|
|
}}
|
|
|
|
templateColumns={{
|
|
|
|
base: "minmax(min-content, 400px)",
|
|
|
|
md: "minmax(min-content, 400px) fit-content(480px)",
|
|
|
|
}}
|
|
|
|
rowGap="4"
|
|
|
|
columnGap="6"
|
|
|
|
justifyContent="center"
|
2021-02-03 16:08:02 -08:00
|
|
|
>
|
2021-02-12 14:35:14 -08:00
|
|
|
<AspectRatio
|
|
|
|
gridArea="preview"
|
|
|
|
maxWidth="400px"
|
|
|
|
maxHeight="400px"
|
|
|
|
ratio="1"
|
|
|
|
border="1px"
|
|
|
|
borderColor={borderColor}
|
|
|
|
transition="border-color 0.2s"
|
|
|
|
borderRadius="lg"
|
|
|
|
boxShadow="lg"
|
|
|
|
overflow="hidden"
|
|
|
|
>
|
|
|
|
<Box>
|
|
|
|
{petState.isValid && preview}
|
|
|
|
<CustomizeMoreButton
|
2020-09-20 21:08:16 -07:00
|
|
|
speciesId={petState.speciesId}
|
|
|
|
colorId={petState.colorId}
|
|
|
|
pose={petState.pose}
|
2021-02-12 14:35:14 -08:00
|
|
|
itemId={itemId}
|
|
|
|
isDisabled={!petState.isValid}
|
2020-09-20 21:08:16 -07:00
|
|
|
/>
|
2021-02-12 14:35:14 -08:00
|
|
|
{hasAnimations && (
|
|
|
|
<PlayPauseButton
|
|
|
|
isPaused={isPaused}
|
|
|
|
onClick={() => setIsPaused(!isPaused)}
|
|
|
|
/>
|
|
|
|
)}
|
2020-09-20 21:08:16 -07:00
|
|
|
</Box>
|
2021-02-12 14:35:14 -08:00
|
|
|
</AspectRatio>
|
2021-02-12 18:15:45 -08:00
|
|
|
<Flex gridArea="speciesColorPicker" alignSelf="start" align="center">
|
2021-02-12 14:35:14 -08:00
|
|
|
<Box
|
|
|
|
// This box grows at the same rate as the box on the right, so the
|
|
|
|
// middle box will be centered, if there's space!
|
|
|
|
flex="1 0 0"
|
2021-02-12 17:46:33 -08:00
|
|
|
/>
|
2021-02-12 14:35:14 -08:00
|
|
|
<SpeciesColorPicker
|
|
|
|
speciesId={petState.speciesId}
|
|
|
|
colorId={petState.colorId}
|
|
|
|
pose={petState.pose}
|
|
|
|
idealPose={idealPose}
|
|
|
|
onChange={(species, color, isValid, closestPose) => {
|
|
|
|
setPetStateFromUserAction({
|
|
|
|
speciesId: species.id,
|
|
|
|
colorId: color.id,
|
|
|
|
pose: closestPose,
|
|
|
|
isValid,
|
|
|
|
appearanceId: null,
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
speciesIsDisabled={isProbablySpeciesSpecific}
|
|
|
|
size="sm"
|
|
|
|
showPlaceholders
|
|
|
|
/>
|
|
|
|
<Box flex="1 0 0" lineHeight="1" paddingLeft="1">
|
|
|
|
{
|
|
|
|
// Wait for us to start _requesting_ the appearance, and _then_
|
|
|
|
// for it to load, and _then_ check compatibility.
|
|
|
|
!loadingGQL &&
|
|
|
|
!appearance.loading &&
|
|
|
|
petState.isValid &&
|
|
|
|
!isCompatible && (
|
|
|
|
<Tooltip
|
|
|
|
label={
|
|
|
|
couldProbablyModelMoreData
|
|
|
|
? "Item needs models"
|
|
|
|
: "Not compatible"
|
|
|
|
}
|
|
|
|
placement="top"
|
|
|
|
>
|
|
|
|
<WarningIcon
|
|
|
|
color={errorColor}
|
|
|
|
transition="color 0.2"
|
|
|
|
marginLeft="2"
|
|
|
|
borderRadius="full"
|
|
|
|
tabIndex="0"
|
|
|
|
_focus={{ outline: "none", boxShadow: "outline" }}
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
</Box>
|
2021-02-12 18:15:45 -08:00
|
|
|
</Flex>
|
2021-02-12 14:35:14 -08:00
|
|
|
<Box
|
|
|
|
gridArea="speciesFacesPicker"
|
|
|
|
paddingTop="2"
|
|
|
|
overflow="auto"
|
|
|
|
padding="8px"
|
|
|
|
>
|
2021-02-02 16:31:55 -08:00
|
|
|
<SpeciesFacesPicker
|
|
|
|
selectedSpeciesId={petState.speciesId}
|
2021-02-02 23:29:06 -08:00
|
|
|
selectedColorId={petState.colorId}
|
2021-02-02 16:31:55 -08:00
|
|
|
compatibleBodies={compatibleBodies}
|
|
|
|
couldProbablyModelMoreData={couldProbablyModelMoreData}
|
2021-02-03 02:10:52 -08:00
|
|
|
onChange={({ speciesId, colorId }) => {
|
|
|
|
const validPoses = getValidPoses(valids, speciesId, colorId);
|
|
|
|
const pose = getClosestPose(validPoses, idealPose);
|
2021-02-03 14:27:02 -08:00
|
|
|
setPetStateFromUserAction({
|
2021-02-02 16:31:55 -08:00
|
|
|
speciesId,
|
|
|
|
colorId,
|
2021-02-03 02:10:52 -08:00
|
|
|
pose,
|
2021-02-09 22:31:50 -08:00
|
|
|
isValid: true,
|
2021-02-02 16:31:55 -08:00
|
|
|
appearanceId: null,
|
2021-02-03 02:10:52 -08:00
|
|
|
});
|
|
|
|
}}
|
|
|
|
isLoading={loadingGQL || loadingValids}
|
2021-02-02 16:31:55 -08:00
|
|
|
/>
|
|
|
|
</Box>
|
2021-02-12 17:46:33 -08:00
|
|
|
<Flex gridArea="zones" justifySelf="center" align="center">
|
2021-02-12 16:09:11 -08:00
|
|
|
{compatibleBodiesAndTheirZones.length > 0 && (
|
|
|
|
<ItemZonesInfo
|
|
|
|
compatibleBodiesAndTheirZones={compatibleBodiesAndTheirZones}
|
2021-02-12 18:15:45 -08:00
|
|
|
restrictedZones={data?.item?.restrictedZones || []}
|
2021-02-12 16:09:11 -08:00
|
|
|
/>
|
|
|
|
)}
|
2021-02-12 18:15:45 -08:00
|
|
|
<Box width="6" />
|
2021-02-12 17:46:33 -08:00
|
|
|
<Flex
|
|
|
|
// Avoid layout shift while loading
|
|
|
|
minWidth="54px"
|
|
|
|
>
|
|
|
|
<HTML5Badge
|
|
|
|
usesHTML5={usesHTML5}
|
|
|
|
// If we're not compatible, act the same as if we're loading:
|
|
|
|
// don't change the badge, but don't show one yet if we don't
|
|
|
|
// have one yet.
|
|
|
|
isLoading={appearance.loading || !isCompatible}
|
|
|
|
/>
|
|
|
|
</Flex>
|
|
|
|
</Flex>
|
2021-02-12 14:35:14 -08:00
|
|
|
</Grid>
|
2020-09-12 17:56:31 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-09 22:31:50 -08:00
|
|
|
function CustomizeMoreButton({ speciesId, colorId, pose, itemId, isDisabled }) {
|
2021-01-26 15:02:11 -08:00
|
|
|
const url =
|
|
|
|
`/outfits/new?species=${speciesId}&color=${colorId}&pose=${pose}&` +
|
|
|
|
`objects[]=${itemId}`;
|
|
|
|
|
|
|
|
// The default background is good in light mode, but in dark mode it's a
|
|
|
|
// very subtle transparent white... make it a semi-transparent black, for
|
|
|
|
// better contrast against light-colored background items!
|
2021-02-06 15:46:10 -08:00
|
|
|
const backgroundColor = useColorModeValue(undefined, "blackAlpha.700");
|
|
|
|
const backgroundColorHover = useColorModeValue(undefined, "blackAlpha.900");
|
2021-01-26 15:02:11 -08:00
|
|
|
|
|
|
|
return (
|
2021-02-06 15:46:10 -08:00
|
|
|
<Button
|
2021-02-09 22:31:50 -08:00
|
|
|
as={isDisabled ? "button" : Link}
|
|
|
|
to={isDisabled ? null : url}
|
2021-02-06 15:46:10 -08:00
|
|
|
role="group"
|
|
|
|
position="absolute"
|
|
|
|
top="2"
|
|
|
|
right="2"
|
|
|
|
size="sm"
|
|
|
|
background={backgroundColor}
|
|
|
|
_hover={{ backgroundColor: backgroundColorHover }}
|
|
|
|
_focus={{ backgroundColor: backgroundColorHover, boxShadow: "outline" }}
|
|
|
|
boxShadow="sm"
|
2021-02-09 22:31:50 -08:00
|
|
|
isDisabled={isDisabled}
|
2021-02-06 15:46:10 -08:00
|
|
|
>
|
|
|
|
<ExpandOnGroupHover paddingRight="2">Customize more</ExpandOnGroupHover>
|
|
|
|
<EditIcon />
|
|
|
|
</Button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ExpandOnGroupHover starts at width=0, and expands to full width when a
|
|
|
|
* parent with role="group" gains hover or focus state.
|
|
|
|
*/
|
|
|
|
function ExpandOnGroupHover({ children, ...props }) {
|
|
|
|
const [measuredWidth, setMeasuredWidth] = React.useState(null);
|
|
|
|
const measurerRef = React.useRef(null);
|
|
|
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
|
|
|
|
|
|
React.useLayoutEffect(() => {
|
|
|
|
if (!measurerRef) {
|
|
|
|
// I don't think this is possible, but I'd like to know if it happens!
|
|
|
|
logAndCapture(
|
|
|
|
new Error(
|
|
|
|
`Measurer node not ready during effect. Transition won't be smooth.`
|
|
|
|
)
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (measuredWidth != null) {
|
|
|
|
// Skip re-measuring when we already have a measured width. This is
|
|
|
|
// mainly defensive, to prevent the possibility of loops, even though
|
|
|
|
// this algorithm should be stable!
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const newMeasuredWidth = measurerRef.current.offsetWidth;
|
|
|
|
setMeasuredWidth(newMeasuredWidth);
|
|
|
|
}, [measuredWidth]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Flex
|
|
|
|
// In block layout, the overflowing children would _also_ be constrained
|
|
|
|
// to width 0. But in flex layout, overflowing children _keep_ their
|
|
|
|
// natural size, so we can measure it even when not visible.
|
|
|
|
width="0"
|
|
|
|
overflow="hidden"
|
|
|
|
// Right-align the children, to keep the text feeling right-aligned when
|
|
|
|
// we expand. (To support left-side expansion, make this a prop!)
|
|
|
|
justify="flex-end"
|
|
|
|
// If the width somehow isn't measured yet, expand to width `auto`, which
|
|
|
|
// won't transition smoothly but at least will work!
|
|
|
|
_groupHover={{ width: measuredWidth ? measuredWidth + "px" : "auto" }}
|
|
|
|
_groupFocus={{ width: measuredWidth ? measuredWidth + "px" : "auto" }}
|
|
|
|
transition={!prefersReducedMotion && "width 0.2s"}
|
|
|
|
>
|
|
|
|
<Box ref={measurerRef} {...props}>
|
|
|
|
{children}
|
|
|
|
</Box>
|
|
|
|
</Flex>
|
2021-01-26 15:02:11 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-01-25 10:24:39 -08:00
|
|
|
function PlayPauseButton({ isPaused, onClick }) {
|
|
|
|
return (
|
|
|
|
<IconButton
|
|
|
|
icon={isPaused ? <MdPlayArrow /> : <MdPause />}
|
|
|
|
aria-label={isPaused ? "Play" : "Pause"}
|
|
|
|
onClick={onClick}
|
|
|
|
borderRadius="full"
|
|
|
|
boxShadow="md"
|
|
|
|
color="gray.50"
|
|
|
|
backgroundColor="blackAlpha.700"
|
|
|
|
position="absolute"
|
|
|
|
bottom="2"
|
|
|
|
left="2"
|
|
|
|
_hover={{ backgroundColor: "blackAlpha.900" }}
|
|
|
|
_focus={{ backgroundColor: "blackAlpha.900" }}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-02 14:47:17 -08:00
|
|
|
function SpeciesFacesPicker({
|
|
|
|
selectedSpeciesId,
|
2021-02-02 23:29:06 -08:00
|
|
|
selectedColorId,
|
2021-02-02 15:22:08 -08:00
|
|
|
compatibleBodies,
|
2021-02-02 16:29:20 -08:00
|
|
|
couldProbablyModelMoreData,
|
2021-02-02 14:47:17 -08:00
|
|
|
onChange,
|
|
|
|
isLoading,
|
|
|
|
}) {
|
2021-02-02 23:29:06 -08:00
|
|
|
// For basic colors (Blue, Green, Red, Yellow), we just use the hardcoded
|
|
|
|
// data, which is part of the bundle and loads super-fast. For other colors,
|
|
|
|
// we load in all the faces of that color, falling back to basic colors when
|
|
|
|
// absent!
|
|
|
|
//
|
|
|
|
// TODO: Could we move this into our `build-cached-data` script, and just do
|
|
|
|
// the query all the time, and have Apollo happen to satisfy it fast?
|
|
|
|
// The semantics of returning our colorful random set could be weird…
|
2021-02-03 15:24:12 -08:00
|
|
|
const selectedColorIsBasic = colorIsBasic(selectedColorId);
|
2021-02-02 23:29:06 -08:00
|
|
|
const { loading: loadingGQL, error, data } = useQuery(
|
|
|
|
gql`
|
|
|
|
query SpeciesFacesPicker($selectedColorId: ID!) {
|
|
|
|
color(id: $selectedColorId) {
|
|
|
|
id
|
|
|
|
appliedToAllCompatibleSpecies {
|
|
|
|
id
|
|
|
|
neopetsImageHash
|
|
|
|
species {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
body {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
{
|
|
|
|
variables: { selectedColorId },
|
|
|
|
skip: selectedColorId == null || selectedColorIsBasic,
|
|
|
|
onError: (e) => console.error(e),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-02-02 15:22:08 -08:00
|
|
|
const allBodiesAreCompatible = compatibleBodies.some(
|
|
|
|
(body) => body.representsAllBodies
|
|
|
|
);
|
|
|
|
const compatibleBodyIds = compatibleBodies.map((body) => body.id);
|
|
|
|
|
2021-02-02 23:29:06 -08:00
|
|
|
const speciesFacesFromData = data?.color?.appliedToAllCompatibleSpecies || [];
|
|
|
|
|
|
|
|
const allSpeciesFaces = DEFAULT_SPECIES_FACES.map((defaultSpeciesFace) => {
|
|
|
|
const providedSpeciesFace = speciesFacesFromData.find(
|
|
|
|
(f) => f.species.id === defaultSpeciesFace.speciesId
|
|
|
|
);
|
2021-02-03 01:47:39 -08:00
|
|
|
if (providedSpeciesFace) {
|
2021-02-02 23:29:06 -08:00
|
|
|
return {
|
|
|
|
...defaultSpeciesFace,
|
|
|
|
colorId: selectedColorId,
|
|
|
|
bodyId: providedSpeciesFace.body.id,
|
2021-02-03 01:47:39 -08:00
|
|
|
// If this species/color pair exists, but without an image hash, then
|
|
|
|
// we want to provide a face so that it's enabled, but use the fallback
|
|
|
|
// image even though it's wrong, so that it looks like _something_.
|
|
|
|
neopetsImageHash:
|
|
|
|
providedSpeciesFace.neopetsImageHash ||
|
|
|
|
defaultSpeciesFace.neopetsImageHash,
|
2021-02-02 23:29:06 -08:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return defaultSpeciesFace;
|
|
|
|
}
|
|
|
|
});
|
2021-02-02 14:47:17 -08:00
|
|
|
|
|
|
|
return (
|
2021-02-02 23:29:06 -08:00
|
|
|
<Box>
|
2021-02-12 14:35:14 -08:00
|
|
|
<Wrap spacing="0" justify="center">
|
2021-02-02 14:47:17 -08:00
|
|
|
{allSpeciesFaces.map((speciesFace) => (
|
|
|
|
<WrapItem key={speciesFace.speciesId}>
|
|
|
|
<SpeciesFaceOption
|
|
|
|
speciesId={speciesFace.speciesId}
|
|
|
|
speciesName={speciesFace.speciesName}
|
|
|
|
colorId={speciesFace.colorId}
|
|
|
|
neopetsImageHash={speciesFace.neopetsImageHash}
|
2021-02-03 01:41:03 -08:00
|
|
|
isSelected={speciesFace.speciesId === selectedSpeciesId}
|
|
|
|
// If the face color doesn't match the current color, this is a
|
|
|
|
// fallback face for an invalid species/color pair.
|
|
|
|
isValid={
|
|
|
|
speciesFace.colorId === selectedColorId || selectedColorIsBasic
|
|
|
|
}
|
|
|
|
bodyIsCompatible={
|
2021-02-02 15:22:08 -08:00
|
|
|
allBodiesAreCompatible ||
|
|
|
|
compatibleBodyIds.includes(speciesFace.bodyId)
|
|
|
|
}
|
2021-02-02 16:29:20 -08:00
|
|
|
couldProbablyModelMoreData={couldProbablyModelMoreData}
|
2021-02-02 14:47:17 -08:00
|
|
|
onChange={onChange}
|
2021-02-02 23:29:06 -08:00
|
|
|
isLoading={isLoading || loadingGQL}
|
2021-02-02 14:47:17 -08:00
|
|
|
/>
|
|
|
|
</WrapItem>
|
|
|
|
))}
|
|
|
|
</Wrap>
|
2021-02-02 23:29:06 -08:00
|
|
|
{error && (
|
|
|
|
<Flex
|
|
|
|
color="yellow.500"
|
|
|
|
fontSize="xs"
|
|
|
|
marginTop="1"
|
|
|
|
textAlign="center"
|
|
|
|
width="100%"
|
|
|
|
align="flex-start"
|
|
|
|
justify="center"
|
|
|
|
>
|
|
|
|
<WarningTwoIcon marginTop="0.4em" marginRight="1" />
|
|
|
|
<Box>
|
2021-02-03 02:10:52 -08:00
|
|
|
Error loading this color's pet photos.
|
2021-02-02 23:29:06 -08:00
|
|
|
<br />
|
|
|
|
Check your connection and try again.
|
|
|
|
</Box>
|
|
|
|
</Flex>
|
|
|
|
)}
|
|
|
|
</Box>
|
2021-02-02 14:47:17 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function SpeciesFaceOption({
|
|
|
|
speciesId,
|
|
|
|
speciesName,
|
|
|
|
colorId,
|
|
|
|
neopetsImageHash,
|
|
|
|
isSelected,
|
2021-02-03 01:41:03 -08:00
|
|
|
bodyIsCompatible,
|
|
|
|
isValid,
|
2021-02-02 16:29:20 -08:00
|
|
|
couldProbablyModelMoreData,
|
2021-02-02 14:47:17 -08:00
|
|
|
onChange,
|
|
|
|
isLoading,
|
|
|
|
}) {
|
2021-01-25 10:24:39 -08:00
|
|
|
const selectedBorderColor = useColorModeValue("green.600", "green.400");
|
|
|
|
const selectedBackgroundColor = useColorModeValue("green.200", "green.600");
|
2021-02-02 13:31:57 -08:00
|
|
|
const focusBorderColor = "blue.400";
|
|
|
|
const focusBackgroundColor = "blue.100";
|
2021-01-25 10:24:39 -08:00
|
|
|
const [
|
|
|
|
selectedBorderColorValue,
|
|
|
|
selectedBackgroundColorValue,
|
2021-02-02 13:31:57 -08:00
|
|
|
focusBorderColorValue,
|
|
|
|
focusBackgroundColorValue,
|
|
|
|
] = useToken("colors", [
|
|
|
|
selectedBorderColor,
|
|
|
|
selectedBackgroundColor,
|
|
|
|
focusBorderColor,
|
|
|
|
focusBackgroundColor,
|
|
|
|
]);
|
2021-02-02 14:47:17 -08:00
|
|
|
const xlShadow = useToken("shadows", "xl");
|
2021-01-25 10:24:39 -08:00
|
|
|
|
2021-02-02 15:43:36 -08:00
|
|
|
const [labelIsHovered, setLabelIsHovered] = React.useState(false);
|
|
|
|
const [inputIsFocused, setInputIsFocused] = React.useState(false);
|
|
|
|
|
2021-02-03 01:41:03 -08:00
|
|
|
const isDisabled = isLoading || !isValid || !bodyIsCompatible;
|
|
|
|
const isHappy = isLoading || (isValid && bodyIsCompatible);
|
2021-02-02 14:47:17 -08:00
|
|
|
const emotionId = isHappy ? "1" : "2";
|
2021-02-03 01:41:03 -08:00
|
|
|
const cursor = isLoading ? "wait" : isDisabled ? "not-allowed" : "pointer";
|
|
|
|
|
|
|
|
let disabledExplanation = null;
|
2021-02-03 01:53:09 -08:00
|
|
|
if (isLoading) {
|
|
|
|
// If we're still loading, don't try to explain anything yet!
|
|
|
|
} else if (!isValid) {
|
2021-02-03 01:41:03 -08:00
|
|
|
disabledExplanation = "(Can't be this color)";
|
|
|
|
} else if (!bodyIsCompatible) {
|
|
|
|
disabledExplanation = couldProbablyModelMoreData
|
2021-02-03 15:44:53 -08:00
|
|
|
? "(Item needs models)"
|
2021-02-03 01:41:03 -08:00
|
|
|
: "(Not compatible)";
|
|
|
|
}
|
2021-02-02 14:47:17 -08:00
|
|
|
|
2021-02-02 15:43:36 -08:00
|
|
|
const tooltipLabel = (
|
|
|
|
<div style={{ textAlign: "center" }}>
|
|
|
|
{speciesName}
|
2021-02-03 01:41:03 -08:00
|
|
|
{disabledExplanation && (
|
2021-02-02 15:22:08 -08:00
|
|
|
<div style={{ fontStyle: "italic", fontSize: "0.75em" }}>
|
2021-02-03 01:41:03 -08:00
|
|
|
{disabledExplanation}
|
2021-02-02 15:22:08 -08:00
|
|
|
</div>
|
2021-02-02 15:43:36 -08:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
2021-01-25 10:24:39 -08:00
|
|
|
|
2021-02-02 16:56:26 -08:00
|
|
|
// NOTE: Because we render quite a few of these, avoiding using Chakra
|
|
|
|
// elements like Box helps with render performance!
|
2021-01-25 10:24:39 -08:00
|
|
|
return (
|
|
|
|
<ClassNames>
|
|
|
|
{({ css }) => (
|
2021-02-02 17:08:39 -08:00
|
|
|
<DeferredTooltip
|
2021-02-02 15:22:08 -08:00
|
|
|
label={tooltipLabel}
|
|
|
|
placement="top"
|
2021-02-02 16:31:55 -08:00
|
|
|
gutter={-10}
|
2021-02-02 15:43:36 -08:00
|
|
|
// We track hover and focus state manually for the tooltip, so that
|
|
|
|
// keyboard nav to switch between options causes the tooltip to
|
|
|
|
// follow. (By default, the tooltip appears on the first tab focus,
|
|
|
|
// but not when you _change_ options!)
|
|
|
|
isOpen={labelIsHovered || inputIsFocused}
|
2021-02-02 15:22:08 -08:00
|
|
|
>
|
2021-02-02 16:56:26 -08:00
|
|
|
<label
|
|
|
|
style={{ cursor }}
|
2021-02-02 15:43:36 -08:00
|
|
|
onMouseEnter={() => setLabelIsHovered(true)}
|
|
|
|
onMouseLeave={() => setLabelIsHovered(false)}
|
|
|
|
>
|
2021-02-02 16:56:26 -08:00
|
|
|
<input
|
2021-02-02 14:47:17 -08:00
|
|
|
type="radio"
|
|
|
|
aria-label={speciesName}
|
|
|
|
name="species-faces-picker"
|
|
|
|
value={speciesId}
|
|
|
|
checked={isSelected}
|
2021-02-02 16:29:20 -08:00
|
|
|
// It's possible to get this selected via the SpeciesColorPicker,
|
|
|
|
// even if this would normally be disabled. If so, make this
|
|
|
|
// option enabled, so keyboard users can focus and change it.
|
2021-02-03 01:41:03 -08:00
|
|
|
disabled={isDisabled && !isSelected}
|
2021-02-02 14:47:17 -08:00
|
|
|
onChange={() => onChange({ speciesId, colorId })}
|
2021-02-02 15:43:36 -08:00
|
|
|
onFocus={() => setInputIsFocused(true)}
|
|
|
|
onBlur={() => setInputIsFocused(false)}
|
2021-02-02 16:56:26 -08:00
|
|
|
className={css`
|
|
|
|
/* Copied from Chakra's <VisuallyHidden /> */
|
|
|
|
border: 0px;
|
|
|
|
clip: rect(0px, 0px, 0px, 0px);
|
|
|
|
height: 1px;
|
|
|
|
width: 1px;
|
|
|
|
margin: -1px;
|
|
|
|
padding: 0px;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
position: absolute;
|
|
|
|
`}
|
2021-02-02 14:47:17 -08:00
|
|
|
/>
|
2021-02-02 16:56:26 -08:00
|
|
|
<div
|
2021-02-02 14:47:17 -08:00
|
|
|
className={css`
|
2021-02-02 16:56:26 -08:00
|
|
|
overflow: hidden;
|
|
|
|
transition: all 0.2s;
|
|
|
|
position: relative;
|
|
|
|
|
2021-02-02 14:47:17 -08:00
|
|
|
input:checked + & {
|
|
|
|
background: ${selectedBackgroundColorValue};
|
|
|
|
border-radius: 6px;
|
|
|
|
box-shadow: ${xlShadow},
|
|
|
|
${selectedBorderColorValue} 0 0 2px 2px;
|
|
|
|
transform: scale(1.2);
|
|
|
|
z-index: 1;
|
|
|
|
}
|
2021-02-02 13:31:57 -08:00
|
|
|
|
2021-02-02 14:47:17 -08:00
|
|
|
input:focus + & {
|
|
|
|
background: ${focusBackgroundColorValue};
|
|
|
|
box-shadow: ${xlShadow}, ${focusBorderColorValue} 0 0 0 3px;
|
|
|
|
}
|
|
|
|
`}
|
|
|
|
>
|
2021-02-03 01:16:19 -08:00
|
|
|
<CrossFadeImage
|
2021-02-02 14:47:17 -08:00
|
|
|
src={`https://pets.neopets-asset-proxy.openneo.net/cp/${neopetsImageHash}/${emotionId}/1.png`}
|
|
|
|
srcSet={
|
|
|
|
`https://pets.neopets-asset-proxy.openneo.net/cp/${neopetsImageHash}/${emotionId}/1.png 1x, ` +
|
|
|
|
`https://pets.neopets-asset-proxy.openneo.net/cp/${neopetsImageHash}/${emotionId}/6.png 2x`
|
|
|
|
}
|
|
|
|
alt={speciesName}
|
2021-02-03 16:08:02 -08:00
|
|
|
width={55}
|
|
|
|
height={55}
|
2021-02-03 01:27:16 -08:00
|
|
|
data-is-loading={isLoading}
|
2021-02-03 01:41:03 -08:00
|
|
|
data-is-disabled={isDisabled}
|
2021-02-02 14:47:17 -08:00
|
|
|
className={css`
|
2021-02-02 16:29:20 -08:00
|
|
|
filter: saturate(90%);
|
|
|
|
opacity: 0.9;
|
2021-02-02 16:56:26 -08:00
|
|
|
transition: all 0.2s;
|
2021-02-02 16:29:20 -08:00
|
|
|
|
2021-02-03 01:41:03 -08:00
|
|
|
&[data-is-disabled="true"] {
|
2021-02-02 16:29:20 -08:00
|
|
|
filter: saturate(0%);
|
|
|
|
opacity: 0.6;
|
|
|
|
}
|
|
|
|
|
2021-02-03 01:27:16 -08:00
|
|
|
&[data-is-loading="true"] {
|
|
|
|
animation: 0.8s linear 0s infinite alternate none running
|
|
|
|
pulse;
|
|
|
|
}
|
|
|
|
|
2021-02-03 01:41:03 -08:00
|
|
|
input:checked + * &[data-body-is-disabled="false"] {
|
2021-02-02 14:47:17 -08:00
|
|
|
opacity: 1;
|
|
|
|
filter: saturate(110%);
|
|
|
|
}
|
2021-02-03 01:27:16 -08:00
|
|
|
|
2021-02-03 01:41:03 -08:00
|
|
|
input:checked + * &[data-body-is-disabled="true"] {
|
|
|
|
opacity: 0.85;
|
|
|
|
}
|
|
|
|
|
2021-02-03 01:27:16 -08:00
|
|
|
@keyframes pulse {
|
|
|
|
from {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
to {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-02 16:35:54 -08:00
|
|
|
/* Alt text for when the image fails to load! We hide it
|
2021-02-03 01:16:19 -08:00
|
|
|
* while still loading though! */
|
2021-02-02 16:35:54 -08:00
|
|
|
font-size: 0.75rem;
|
|
|
|
text-align: center;
|
|
|
|
&:-moz-loading {
|
|
|
|
visibility: hidden;
|
|
|
|
}
|
|
|
|
&:-moz-broken {
|
|
|
|
padding: 0.5rem;
|
|
|
|
}
|
2021-02-02 14:47:17 -08:00
|
|
|
`}
|
|
|
|
/>
|
2021-02-02 16:56:26 -08:00
|
|
|
</div>
|
|
|
|
</label>
|
2021-02-02 17:08:39 -08:00
|
|
|
</DeferredTooltip>
|
|
|
|
)}
|
|
|
|
</ClassNames>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-12 18:15:45 -08:00
|
|
|
function ItemZonesInfo({ compatibleBodiesAndTheirZones, restrictedZones }) {
|
2021-02-12 16:09:11 -08:00
|
|
|
// Reorganize the body-and-zones data, into zone-and-bodies data. Also, we're
|
|
|
|
// merging zones with the same label, because that's how user-facing zone UI
|
|
|
|
// generally works!
|
|
|
|
const zoneLabelsAndTheirBodiesMap = {};
|
|
|
|
for (const { body, zones } of compatibleBodiesAndTheirZones) {
|
|
|
|
for (const zone of zones) {
|
|
|
|
if (!zoneLabelsAndTheirBodiesMap[zone.label]) {
|
|
|
|
zoneLabelsAndTheirBodiesMap[zone.label] = {
|
|
|
|
zoneLabel: zone.label,
|
|
|
|
bodies: [],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
zoneLabelsAndTheirBodiesMap[zone.label].bodies.push(body);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const zoneLabelsAndTheirBodies = Object.values(zoneLabelsAndTheirBodiesMap);
|
|
|
|
|
|
|
|
const sortedZonesAndTheirBodies = [...zoneLabelsAndTheirBodies].sort((a, b) =>
|
|
|
|
buildSortKeyForZoneLabelsAndTheirBodies(a).localeCompare(
|
|
|
|
buildSortKeyForZoneLabelsAndTheirBodies(b)
|
|
|
|
)
|
2021-02-12 15:18:54 -08:00
|
|
|
);
|
|
|
|
|
2021-02-12 18:15:45 -08:00
|
|
|
const restrictedZoneLabels = [
|
|
|
|
...new Set(restrictedZones.map((z) => z.label)),
|
|
|
|
].sort();
|
|
|
|
|
2021-02-12 15:18:54 -08:00
|
|
|
// We only show body info if there's more than one group of bodies to talk
|
|
|
|
// about. If they all have the same zones, it's clear from context that any
|
|
|
|
// preview available in the list has the zones listed here.
|
|
|
|
const bodyGroups = new Set(
|
2021-02-12 16:09:11 -08:00
|
|
|
zoneLabelsAndTheirBodies.map(({ bodies }) =>
|
|
|
|
bodies.map((b) => b.id).join(",")
|
|
|
|
)
|
2021-02-12 15:18:54 -08:00
|
|
|
);
|
|
|
|
const showBodyInfo = bodyGroups.size > 1;
|
|
|
|
|
2021-02-12 14:35:14 -08:00
|
|
|
return (
|
2021-02-12 18:15:45 -08:00
|
|
|
<Flex
|
|
|
|
fontSize="sm"
|
|
|
|
textAlign="center"
|
|
|
|
// If the text gets too long, wrap Restricts onto another line, and center
|
|
|
|
// them relative to each other.
|
|
|
|
wrap="wrap"
|
|
|
|
justify="center"
|
|
|
|
data-test-id="item-zones-info"
|
|
|
|
>
|
|
|
|
<Box flex="0 0 auto" maxWidth="100%">
|
|
|
|
<Box as="header" fontWeight="bold" display="inline">
|
|
|
|
Occupies:
|
|
|
|
</Box>{" "}
|
|
|
|
<Box as="ul" listStyleType="none" display="inline">
|
|
|
|
{sortedZonesAndTheirBodies.map(({ zoneLabel, bodies }) => (
|
|
|
|
<Box
|
|
|
|
key={zoneLabel}
|
|
|
|
as="li"
|
|
|
|
display="inline"
|
|
|
|
_notLast={{ _after: { content: '", "' } }}
|
|
|
|
>
|
2021-02-12 18:25:08 -08:00
|
|
|
<Box
|
|
|
|
as="span"
|
|
|
|
// Don't wrap any of the list item content. But, by putting
|
|
|
|
// this in an extra container element, we _do_ allow wrapping
|
|
|
|
// _between_ list items.
|
|
|
|
whiteSpace="nowrap"
|
|
|
|
>
|
|
|
|
<ItemZonesInfoListItem
|
|
|
|
zoneLabel={zoneLabel}
|
|
|
|
bodies={bodies}
|
|
|
|
showBodyInfo={showBodyInfo}
|
|
|
|
/>
|
|
|
|
</Box>
|
2021-02-12 18:15:45 -08:00
|
|
|
</Box>
|
|
|
|
))}
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
<Box width="4" flex="0 0 auto" />
|
|
|
|
<Box flex="0 0 auto" maxWidth="100%">
|
|
|
|
<Box as="header" fontWeight="bold" display="inline">
|
|
|
|
Restricts:
|
|
|
|
</Box>{" "}
|
|
|
|
{restrictedZoneLabels.length > 0 ? (
|
|
|
|
<Box as="ul" listStyleType="none" display="inline">
|
|
|
|
{restrictedZoneLabels.map((zoneLabel) => (
|
|
|
|
<Box
|
|
|
|
key={zoneLabel}
|
|
|
|
as="li"
|
|
|
|
display="inline"
|
|
|
|
_notLast={{ _after: { content: '", "' } }}
|
|
|
|
>
|
2021-02-12 18:25:08 -08:00
|
|
|
<Box
|
|
|
|
as="span"
|
|
|
|
// Don't wrap any of the list item content. But, by putting
|
|
|
|
// this in an extra container element, we _do_ allow wrapping
|
|
|
|
// _between_ list items.
|
|
|
|
whiteSpace="nowrap"
|
|
|
|
>
|
|
|
|
{zoneLabel}
|
|
|
|
</Box>
|
2021-02-12 18:15:45 -08:00
|
|
|
</Box>
|
|
|
|
))}
|
2021-02-12 15:18:54 -08:00
|
|
|
</Box>
|
2021-02-12 18:15:45 -08:00
|
|
|
) : (
|
|
|
|
<Box as="span" fontStyle="italic" opacity="0.8">
|
|
|
|
N/A
|
|
|
|
</Box>
|
|
|
|
)}
|
2021-02-12 15:18:54 -08:00
|
|
|
</Box>
|
2021-02-12 18:15:45 -08:00
|
|
|
</Flex>
|
2021-02-12 14:35:14 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-12 16:09:11 -08:00
|
|
|
function ItemZonesInfoListItem({ zoneLabel, bodies, showBodyInfo }) {
|
|
|
|
let content = zoneLabel;
|
2021-02-12 15:18:54 -08:00
|
|
|
|
|
|
|
if (showBodyInfo) {
|
|
|
|
if (bodies.some((b) => b.representsAllBodies)) {
|
|
|
|
content = <>{content} (all species)</>;
|
|
|
|
} else {
|
|
|
|
// TODO: This is a bit reductive, if it's different for like special
|
|
|
|
// colors, e.g. Blue Acara vs Mutant Acara, this will just show
|
|
|
|
// "Acara" in either case! (We are at least gonna be defensive here
|
|
|
|
// and remove duplicates, though, in case both the Blue Acara and
|
|
|
|
// Mutant Acara body end up in the same list.)
|
|
|
|
const speciesNames = new Set(bodies.map((b) => b.species.name));
|
|
|
|
const speciesListString = [...speciesNames].sort().join(", ");
|
|
|
|
|
|
|
|
content = (
|
|
|
|
<>
|
|
|
|
{content}{" "}
|
2021-02-12 18:35:16 -08:00
|
|
|
<Tooltip
|
|
|
|
label={speciesListString}
|
|
|
|
textAlign="center"
|
|
|
|
placement="bottom"
|
|
|
|
>
|
2021-02-12 15:18:54 -08:00
|
|
|
<Box
|
|
|
|
as="span"
|
|
|
|
tabIndex="0"
|
|
|
|
_focus={{ outline: "none", boxShadow: "outline" }}
|
2021-02-12 18:31:12 -08:00
|
|
|
fontStyle="italic"
|
2021-02-12 15:18:54 -08:00
|
|
|
textDecoration="underline"
|
2021-02-12 18:31:12 -08:00
|
|
|
style={{ textDecorationStyle: "dotted" }}
|
|
|
|
opacity="0.8"
|
2021-02-12 15:18:54 -08:00
|
|
|
>
|
|
|
|
{/* Show the speciesNames count, even though it's less info,
|
|
|
|
* because it's more important that the tooltip content matches
|
|
|
|
* the count we show! */}
|
|
|
|
({speciesNames.size} species)
|
|
|
|
</Box>
|
|
|
|
</Tooltip>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
2021-02-12 16:09:11 -08:00
|
|
|
function buildSortKeyForZoneLabelsAndTheirBodies({ zoneLabel, bodies }) {
|
|
|
|
// Sort by "represents all bodies", then by body count descending, then
|
|
|
|
// alphabetically.
|
2021-02-12 15:18:54 -08:00
|
|
|
const representsAllBodies = bodies.some((body) => body.representsAllBodies);
|
2021-02-12 16:09:11 -08:00
|
|
|
|
|
|
|
// To sort by body count _descending_, we subtract it from a large number.
|
|
|
|
// Then, to make it work in string comparison, we pad it with leading zeroes.
|
|
|
|
// Hacky but solid!
|
|
|
|
const inverseBodyCount = (9999 - bodies.length).toString().padStart(4, "0");
|
|
|
|
|
|
|
|
return `${representsAllBodies ? "A" : "Z"}-${inverseBodyCount}-${zoneLabel}`;
|
2021-02-12 15:18:54 -08:00
|
|
|
}
|
|
|
|
|
2021-02-03 01:16:19 -08:00
|
|
|
/**
|
|
|
|
* CrossFadeImage is like <img>, but listens for successful load events, and
|
|
|
|
* fades from the previous image to the new image once it loads.
|
|
|
|
*
|
|
|
|
* We treat `src` as a unique key representing the image's identity, but we
|
|
|
|
* also carry along the rest of the props during the fade, like `srcSet` and
|
|
|
|
* `className`.
|
|
|
|
*/
|
|
|
|
function CrossFadeImage(incomingImageProps) {
|
|
|
|
const [prevImageProps, setPrevImageProps] = React.useState(null);
|
|
|
|
const [currentImageProps, setCurrentImageProps] = React.useState(null);
|
|
|
|
|
|
|
|
const incomingImageIsCurrentImage =
|
|
|
|
incomingImageProps.src === currentImageProps?.src;
|
|
|
|
|
|
|
|
const onLoadNextImage = () => {
|
|
|
|
setPrevImageProps(currentImageProps);
|
|
|
|
setCurrentImageProps(incomingImageProps);
|
|
|
|
};
|
|
|
|
|
|
|
|
// The main trick to this component is using React's `key` feature! When
|
|
|
|
// diffing the rendered tree, if React sees two nodes with the same `key`, it
|
|
|
|
// treats them as the same node and makes the prop changes to match.
|
|
|
|
//
|
|
|
|
// We usually use this in `.map`, to make sure that adds/removes in a list
|
|
|
|
// don't cause our children to shift around and swap their React state or DOM
|
|
|
|
// nodes with each other.
|
|
|
|
//
|
|
|
|
// But here, we use `key` to get React to transition the same <img> DOM node
|
|
|
|
// between 3 different states!
|
|
|
|
//
|
|
|
|
// The image starts its life as the last in the list, from
|
|
|
|
// `incomingImageProps`: it's invisible, and still loading. We use its `src`
|
|
|
|
// as the `key`.
|
|
|
|
//
|
|
|
|
// When it loads, we update the state so that this `key` now belongs to the
|
|
|
|
// _second_ node, from `currentImageProps`. React will see this and make the
|
|
|
|
// correct transition for us: it sets opacity to 0, sets z-index to 2,
|
|
|
|
// removes aria-hidden, and removes the `onLoad` handler.
|
|
|
|
//
|
|
|
|
// Then, when another image is ready to show, we update the state so that
|
|
|
|
// this key now belongs to the _first_ node, from `prevImageProps` (and the
|
|
|
|
// second node is showing something new). React sees this, and makes the
|
|
|
|
// transition back to invisibility, but without the `onLoad` handler this
|
|
|
|
// time! (And transitions the current image into view, like it did for this
|
|
|
|
// one.)
|
|
|
|
//
|
|
|
|
// Finally, when yet _another_ image is ready to show, we stop rendering any
|
|
|
|
// images with this key anymore, and so React unmounts the image entirely.
|
|
|
|
//
|
|
|
|
// Thanks, React, for handling our multiple overlapping transitions through
|
|
|
|
// this little state machine! This could have been a LOT harder to write,
|
|
|
|
// whew!
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ClassNames>
|
|
|
|
{({ css }) => (
|
|
|
|
<div
|
|
|
|
className={css`
|
|
|
|
display: grid;
|
|
|
|
grid-template-areas: "shared-overlapping-area";
|
|
|
|
isolation: isolate; /* Avoid z-index conflicts with parent! */
|
|
|
|
|
|
|
|
> div {
|
|
|
|
grid-area: shared-overlapping-area;
|
|
|
|
transition: opacity 0.2s;
|
|
|
|
}
|
|
|
|
`}
|
|
|
|
>
|
|
|
|
{prevImageProps && (
|
|
|
|
<div
|
|
|
|
key={prevImageProps.src}
|
|
|
|
className={css`
|
|
|
|
z-index: 3;
|
|
|
|
opacity: 0;
|
|
|
|
`}
|
|
|
|
>
|
|
|
|
{/* eslint-disable-next-line jsx-a11y/alt-text */}
|
|
|
|
<img {...prevImageProps} aria-hidden />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{currentImageProps && (
|
|
|
|
<div
|
|
|
|
key={currentImageProps.src}
|
|
|
|
className={css`
|
|
|
|
z-index: 2;
|
|
|
|
opacity: 1;
|
|
|
|
`}
|
|
|
|
>
|
|
|
|
{/* eslint-disable-next-line jsx-a11y/alt-text */}
|
|
|
|
<img
|
|
|
|
{...currentImageProps}
|
|
|
|
// If the current image _is_ the incoming image, we'll allow
|
|
|
|
// new props to come in and affect it. But if it's a new image
|
|
|
|
// incoming, we want to stick to the last props the current
|
2021-02-03 01:41:03 -08:00
|
|
|
// image had! (This matters for e.g. `bodyIsCompatible`
|
|
|
|
// becoming true in `SpeciesFaceOption` and restoring color,
|
|
|
|
// before the new color's image loads in.)
|
2021-02-03 01:16:19 -08:00
|
|
|
{...(incomingImageIsCurrentImage ? incomingImageProps : {})}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{!incomingImageIsCurrentImage && (
|
|
|
|
<div
|
|
|
|
key={incomingImageProps.src}
|
|
|
|
className={css`
|
|
|
|
z-index: 1;
|
|
|
|
opacity: 0;
|
|
|
|
`}
|
|
|
|
>
|
|
|
|
{/* eslint-disable-next-line jsx-a11y/alt-text */}
|
|
|
|
<img
|
|
|
|
{...incomingImageProps}
|
|
|
|
aria-hidden
|
|
|
|
onLoad={onLoadNextImage}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</ClassNames>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-02 17:08:39 -08:00
|
|
|
/**
|
|
|
|
* DeferredTooltip is like Chakra's <Tooltip />, but it waits until `isOpen` is
|
|
|
|
* true before mounting it, and unmounts it after closing.
|
|
|
|
*
|
|
|
|
* This can drastically improve render performance when there are lots of
|
|
|
|
* tooltip targets to re-render… but it comes with some limitations, like the
|
|
|
|
* extra requirement to control `isOpen`, and some additional DOM structure!
|
|
|
|
*/
|
|
|
|
function DeferredTooltip({ children, isOpen, ...props }) {
|
|
|
|
const [shouldShowTooltip, setShouldShowToolip] = React.useState(isOpen);
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (isOpen) {
|
|
|
|
setShouldShowToolip(true);
|
|
|
|
} else {
|
|
|
|
const timeoutId = setTimeout(() => setShouldShowToolip(false), 500);
|
|
|
|
return () => clearTimeout(timeoutId);
|
|
|
|
}
|
|
|
|
}, [isOpen]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ClassNames>
|
|
|
|
{({ css }) => (
|
|
|
|
<div
|
|
|
|
className={css`
|
|
|
|
position: relative;
|
|
|
|
`}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
{shouldShowTooltip && (
|
|
|
|
<Tooltip isOpen={isOpen} {...props}>
|
|
|
|
<div
|
|
|
|
className={css`
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
pointer-events: none;
|
|
|
|
`}
|
|
|
|
/>
|
|
|
|
</Tooltip>
|
|
|
|
)}
|
|
|
|
</div>
|
2021-01-25 10:24:39 -08:00
|
|
|
)}
|
|
|
|
</ClassNames>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-02-03 15:24:12 -08:00
|
|
|
function colorIsBasic(colorId) {
|
|
|
|
return ["8", "34", "61", "84"].includes(colorId);
|
|
|
|
}
|
|
|
|
|
2021-01-25 10:24:39 -08:00
|
|
|
// HACK: I'm just hardcoding all this, rather than connecting up to the
|
|
|
|
// database and adding a loading state. Tbh I'm not sure it's a good idea
|
|
|
|
// to load this dynamically until we have SSR to make it come in fast!
|
|
|
|
// And it's not so bad if this gets out of sync with the database,
|
|
|
|
// because the SpeciesColorPicker will still be usable!
|
|
|
|
const colors = { BLUE: "8", RED: "61", GREEN: "34", YELLOW: "84" };
|
2021-02-02 23:29:06 -08:00
|
|
|
const DEFAULT_SPECIES_FACES = [
|
2021-01-25 10:24:39 -08:00
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Acara",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "1",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "93",
|
|
|
|
neopetsImageHash: "obxdjm88",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Aisha",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "2",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "106",
|
|
|
|
neopetsImageHash: "n9ozx4z5",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Blumaroo",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "3",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "47",
|
|
|
|
neopetsImageHash: "kfonqhdc",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Bori",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "4",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "84",
|
|
|
|
neopetsImageHash: "sc2hhvhn",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Bruce",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "5",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "146",
|
|
|
|
neopetsImageHash: "wqz8xn4t",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Buzz",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "6",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "250",
|
|
|
|
neopetsImageHash: "jc9klfxm",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Chia",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "7",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "212",
|
|
|
|
neopetsImageHash: "4lrb4n3f",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Chomby",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "8",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "74",
|
|
|
|
neopetsImageHash: "bdml26md",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Cybunny",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "9",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "94",
|
|
|
|
neopetsImageHash: "xl6msllv",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Draik",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "10",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "132",
|
|
|
|
neopetsImageHash: "bob39shq",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Elephante",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "11",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "56",
|
|
|
|
neopetsImageHash: "jhhhbrww",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Eyrie",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "12",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "90",
|
|
|
|
neopetsImageHash: "6kngmhvs",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Flotsam",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "13",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "136",
|
|
|
|
neopetsImageHash: "47vt32x2",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Gelert",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "14",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "138",
|
|
|
|
neopetsImageHash: "5nrd2lvd",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Gnorbu",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "15",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "166",
|
|
|
|
neopetsImageHash: "6c275jcg",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Grarrl",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "16",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "119",
|
|
|
|
neopetsImageHash: "j7q65fv4",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Grundo",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "17",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "126",
|
|
|
|
neopetsImageHash: "5xn4kjf8",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Hissi",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "18",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "67",
|
|
|
|
neopetsImageHash: "jsfvcqwt",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Ixi",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "19",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "163",
|
|
|
|
neopetsImageHash: "w32r74vo",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Jetsam",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "20",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "147",
|
|
|
|
neopetsImageHash: "kz43rnld",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Jubjub",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "21",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "80",
|
|
|
|
neopetsImageHash: "m267j935",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Kacheek",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "22",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "117",
|
|
|
|
neopetsImageHash: "4gsrb59g",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Kau",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "23",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "201",
|
|
|
|
neopetsImageHash: "ktlxmrtr",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Kiko",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "24",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "51",
|
|
|
|
neopetsImageHash: "42j5q3zx",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Koi",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "25",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "208",
|
|
|
|
neopetsImageHash: "ncfn87wk",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Korbat",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "26",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "196",
|
|
|
|
neopetsImageHash: "omx9c876",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Kougra",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "27",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "143",
|
|
|
|
neopetsImageHash: "rfsbh59t",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Krawk",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "28",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "150",
|
|
|
|
neopetsImageHash: "hxgsm5d4",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Kyrii",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "29",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "175",
|
|
|
|
neopetsImageHash: "blxmjgbk",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Lenny",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "30",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "173",
|
|
|
|
neopetsImageHash: "8r94jhfq",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Lupe",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "31",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "199",
|
|
|
|
neopetsImageHash: "z42535zh",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Lutari",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "32",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "52",
|
|
|
|
neopetsImageHash: "qgg6z8s7",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Meerca",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "33",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "109",
|
|
|
|
neopetsImageHash: "kk2nn2jr",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Moehog",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "34",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "134",
|
|
|
|
neopetsImageHash: "jgkoro5z",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Mynci",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "35",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "95",
|
|
|
|
neopetsImageHash: "xwlo9657",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Nimmo",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "36",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "96",
|
|
|
|
neopetsImageHash: "bx7fho8x",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Ogrin",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "37",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "154",
|
|
|
|
neopetsImageHash: "rjzmx24v",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Peophin",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "38",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "55",
|
|
|
|
neopetsImageHash: "kokc52kh",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Poogle",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "39",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "76",
|
|
|
|
neopetsImageHash: "fw6lvf3c",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Pteri",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "40",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "156",
|
|
|
|
neopetsImageHash: "tjhwbro3",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Quiggle",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "41",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "78",
|
|
|
|
neopetsImageHash: "jdto7mj4",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Ruki",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "42",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "191",
|
|
|
|
neopetsImageHash: "qsgbm5f6",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Scorchio",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "43",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "187",
|
|
|
|
neopetsImageHash: "hkjoncsx",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Shoyru",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "44",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "46",
|
|
|
|
neopetsImageHash: "mmvn4tkg",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Skeith",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "45",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "178",
|
|
|
|
neopetsImageHash: "fc4cxk3t",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Techo",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "46",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "100",
|
|
|
|
neopetsImageHash: "84gvowmj",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Tonu",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "47",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "130",
|
|
|
|
neopetsImageHash: "jd433863",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Tuskaninny",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "48",
|
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "188",
|
|
|
|
neopetsImageHash: "q39wn6vq",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Uni",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "49",
|
|
|
|
colorId: colors.GREEN,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "257",
|
|
|
|
neopetsImageHash: "njzvoflw",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Usul",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "50",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "206",
|
|
|
|
neopetsImageHash: "rox4mgh5",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Vandagyre",
|
|
|
|
speciesId: "55",
|
2021-01-25 10:24:39 -08:00
|
|
|
colorId: colors.YELLOW,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "306",
|
|
|
|
neopetsImageHash: "xkntzsww",
|
|
|
|
},
|
|
|
|
{
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesName: "Wocky",
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesId: "51",
|
|
|
|
colorId: colors.YELLOW,
|
|
|
|
bodyId: "101",
|
|
|
|
neopetsImageHash: "dnr2kj4b",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Xweetok",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "52",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "68",
|
|
|
|
neopetsImageHash: "tdkqr2b6",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Yurble",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "53",
|
|
|
|
colorId: colors.RED,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "182",
|
|
|
|
neopetsImageHash: "h95cs547",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
{
|
2021-02-02 14:47:17 -08:00
|
|
|
speciesName: "Zafara",
|
2021-01-25 10:24:39 -08:00
|
|
|
speciesId: "54",
|
|
|
|
colorId: colors.BLUE,
|
2021-02-02 14:47:17 -08:00
|
|
|
bodyId: "180",
|
|
|
|
neopetsImageHash: "x8c57g2l",
|
2021-01-25 10:24:39 -08:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2020-09-11 23:56:47 -07:00
|
|
|
export default ItemPage;
|