Waka item page UI!
This commit is contained in:
parent
3ea6107f4f
commit
be816d89c9
3 changed files with 107 additions and 22 deletions
|
@ -74,6 +74,7 @@ export function ItemPageContent({ itemId, isEmbedded }) {
|
||||||
thumbnailUrl
|
thumbnailUrl
|
||||||
description
|
description
|
||||||
createdAt
|
createdAt
|
||||||
|
wakaValueText
|
||||||
|
|
||||||
# For Support users.
|
# For Support users.
|
||||||
rarityIndex
|
rarityIndex
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
Flex,
|
Flex,
|
||||||
Popover,
|
Popover,
|
||||||
PopoverArrow,
|
PopoverArrow,
|
||||||
|
PopoverBody,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
Portal,
|
Portal,
|
||||||
|
@ -12,10 +13,15 @@ import {
|
||||||
Skeleton,
|
Skeleton,
|
||||||
Spinner,
|
Spinner,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
|
useBreakpointValue,
|
||||||
useToast,
|
useToast,
|
||||||
VStack,
|
VStack,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { ExternalLinkIcon, ChevronRightIcon } from "@chakra-ui/icons";
|
import {
|
||||||
|
ExternalLinkIcon,
|
||||||
|
ChevronRightIcon,
|
||||||
|
QuestionIcon,
|
||||||
|
} from "@chakra-ui/icons";
|
||||||
import { gql, useMutation } from "@apollo/client";
|
import { gql, useMutation } from "@apollo/client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -150,6 +156,42 @@ function ItemPageBadges({ item, isEmbedded }) {
|
||||||
Jellyneo
|
Jellyneo
|
||||||
</LinkBadge>
|
</LinkBadge>
|
||||||
</SubtleSkeleton>
|
</SubtleSkeleton>
|
||||||
|
{item.isNc && (
|
||||||
|
<SubtleSkeleton
|
||||||
|
isLoaded={
|
||||||
|
// Distinguish between undefined (still loading) and null (loaded and
|
||||||
|
// empty).
|
||||||
|
item.wakaValueText !== undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{item.wakaValueText && (
|
||||||
|
<>
|
||||||
|
{/* For hover-y devices, use a hover popover over the badge. */}
|
||||||
|
<Box sx={{ "@media (hover: none)": { display: "none" } }}>
|
||||||
|
<WakaPopover trigger="hover">
|
||||||
|
<LinkBadge href="http://www.neopets.com/~waka">
|
||||||
|
Waka: {item.wakaValueText}
|
||||||
|
</LinkBadge>
|
||||||
|
</WakaPopover>
|
||||||
|
</Box>
|
||||||
|
{/* For touch-y devices, use a tappable help icon. */}
|
||||||
|
<Flex
|
||||||
|
sx={{ "@media (hover: hover)": { display: "none" } }}
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
|
<LinkBadge href="http://www.neopets.com/~waka">
|
||||||
|
Waka: {item.wakaValueText}
|
||||||
|
</LinkBadge>
|
||||||
|
<WakaPopover>
|
||||||
|
<Flex align="center" fontSize="sm" paddingX="2" tabIndex="0">
|
||||||
|
<QuestionIcon />
|
||||||
|
</Flex>
|
||||||
|
</WakaPopover>
|
||||||
|
</Flex>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</SubtleSkeleton>
|
||||||
|
)}
|
||||||
<SubtleSkeleton isLoaded={searchBadgesAreLoaded}>
|
<SubtleSkeleton isLoaded={searchBadgesAreLoaded}>
|
||||||
{!item?.isNc && !item?.isPb && (
|
{!item?.isNc && !item?.isPb && (
|
||||||
<LinkBadge
|
<LinkBadge
|
||||||
|
@ -317,9 +359,11 @@ function ItemKindBadgeWithSupportTools({ item }) {
|
||||||
return <ItemKindBadge isNc={item.isNc} isPb={item.isPb} />;
|
return <ItemKindBadge isNc={item.isNc} isPb={item.isPb} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
function LinkBadge({ children, href, isEmbedded }) {
|
const LinkBadge = React.forwardRef(
|
||||||
|
({ children, href, isEmbedded, ...props }, ref) => {
|
||||||
return (
|
return (
|
||||||
<Badge
|
<Badge
|
||||||
|
ref={ref}
|
||||||
as="a"
|
as="a"
|
||||||
href={href}
|
href={href}
|
||||||
display="flex"
|
display="flex"
|
||||||
|
@ -328,16 +372,23 @@ function LinkBadge({ children, href, isEmbedded }) {
|
||||||
// normal. But when we're on the wardrobe page, we want to avoid
|
// normal. But when we're on the wardrobe page, we want to avoid
|
||||||
// disrupting the outfit, and open in a new window instead.
|
// disrupting the outfit, and open in a new window instead.
|
||||||
target={isEmbedded ? "_blank" : undefined}
|
target={isEmbedded ? "_blank" : undefined}
|
||||||
|
_focus={{ outline: "none", boxShadow: "outline" }}
|
||||||
|
{...props}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
{
|
{
|
||||||
// We also change the icon to signal whether this will launch in a new
|
// We also change the icon to signal whether this will launch in a new
|
||||||
// window or not!
|
// window or not!
|
||||||
isEmbedded ? <ExternalLinkIcon marginLeft="1" /> : <ChevronRightIcon />
|
isEmbedded ? (
|
||||||
|
<ExternalLinkIcon marginLeft="1" />
|
||||||
|
) : (
|
||||||
|
<ChevronRightIcon />
|
||||||
|
)
|
||||||
}
|
}
|
||||||
</Badge>
|
</Badge>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const fullDateFormatter = new Intl.DateTimeFormat("en-US", {
|
const fullDateFormatter = new Intl.DateTimeFormat("en-US", {
|
||||||
dateStyle: "long",
|
dateStyle: "long",
|
||||||
|
@ -380,4 +431,36 @@ function ShortTimestamp({ when }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function WakaPopover({ children, ...props }) {
|
||||||
|
const placement = useBreakpointValue({ base: "bottom", md: "right" });
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Popover placement={placement} {...props}>
|
||||||
|
<PopoverTrigger>{children}</PopoverTrigger>
|
||||||
|
<Portal>
|
||||||
|
<PopoverContent>
|
||||||
|
<PopoverArrow />
|
||||||
|
<PopoverBody fontSize="sm">
|
||||||
|
<p>
|
||||||
|
Waka is a community resource that tracks the approximate value of
|
||||||
|
NC items, based on real-world trades.
|
||||||
|
</p>
|
||||||
|
<Box height="1em" />
|
||||||
|
<p>
|
||||||
|
Other factors, like rarity and popularity, can affect the trade
|
||||||
|
economy too—and it can change quickly!
|
||||||
|
</p>
|
||||||
|
<Box height="1em" />
|
||||||
|
<p>
|
||||||
|
Be sure to take all factors into account for your trades! And
|
||||||
|
consider asking for a "value check" on the Neoboards if you're not
|
||||||
|
sure.
|
||||||
|
</p>
|
||||||
|
</PopoverBody>
|
||||||
|
</PopoverContent>
|
||||||
|
</Portal>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default ItemPageLayout;
|
export default ItemPageLayout;
|
||||||
|
|
|
@ -102,6 +102,7 @@ function ItemTradesPage({
|
||||||
thumbnailUrl
|
thumbnailUrl
|
||||||
description
|
description
|
||||||
createdAt
|
createdAt
|
||||||
|
wakaValueText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
|
Loading…
Reference in a new issue