Badge for animated items, support only

This is really very cute, but too many items it turns out are lod despite not actually being animated 🙃 it's helpful for looking for test cases tho, so I'm keeping it, but support only!

I also ended up really liking the icon-badge+tooltip design as a way to summarize lil things, so I'm trying Own/Want short badges in the same style.
This commit is contained in:
Emi Matchu 2020-09-22 04:17:27 -07:00
parent ae26701be7
commit 772065815a
2 changed files with 59 additions and 10 deletions

View file

@ -23,12 +23,14 @@ import {
ItemCardContent, ItemCardContent,
ItemBadgeList, ItemBadgeList,
ItemBadgeTooltip, ItemBadgeTooltip,
MaybeAnimatedBadge,
NcBadge, NcBadge,
NpBadge, NpBadge,
YouOwnThisBadge, YouOwnThisBadge,
YouWantThisBadge, YouWantThisBadge,
} from "../components/ItemCard"; } from "../components/ItemCard";
import SupportOnly from "./support/SupportOnly"; import SupportOnly from "./support/SupportOnly";
import useSupport from "./support/useSupport";
const LoadableItemPageDrawer = loadable(() => import("../ItemPageDrawer")); const LoadableItemPageDrawer = loadable(() => import("../ItemPageDrawer"));
const LoadableItemSupportDrawer = loadable(() => const LoadableItemSupportDrawer = loadable(() =>
@ -204,12 +206,16 @@ function ItemContainer({ children, isDisabled = false }) {
} }
function ItemBadges({ item }) { function ItemBadges({ item }) {
const { isSupportUser } = useSupport();
const occupiedZoneLabels = getZoneLabels( const occupiedZoneLabels = getZoneLabels(
item.appearanceOn.layers.map((l) => l.zone) item.appearanceOn.layers.map((l) => l.zone)
); );
const restrictedZoneLabels = getZoneLabels( const restrictedZoneLabels = getZoneLabels(
item.appearanceOn.restrictedZones.filter((z) => z.isCommonlyUsedByItems) item.appearanceOn.restrictedZones.filter((z) => z.isCommonlyUsedByItems)
); );
const isMaybeAnimated = item.appearanceOn.layers.some(
(l) => l.canvasMovieLibraryUrl
);
return ( return (
<ItemBadgeList> <ItemBadgeList>
@ -224,6 +230,13 @@ function ItemBadges({ item }) {
// than try to line things up like a table. // than try to line things up like a table.
<NpBadge /> <NpBadge />
)} )}
{
// This badge is unreliable, but it's helpful for looking for animated
// items to test, so we show it only to support. We use this form
// instead of <SupportOnly />, to avoid adding extra badge list spacing
// on the additional empty child.
isMaybeAnimated && isSupportUser && <MaybeAnimatedBadge />
}
{item.currentUserOwnsThis && <YouOwnThisBadge variant="short" />} {item.currentUserOwnsThis && <YouOwnThisBadge variant="short" />}
{item.currentUserWantsThis && <YouWantThisBadge variant="short" />} {item.currentUserWantsThis && <YouWantThisBadge variant="short" />}
{occupiedZoneLabels.map((zoneLabel) => ( {occupiedZoneLabels.map((zoneLabel) => (

View file

@ -10,6 +10,7 @@ import {
useTheme, useTheme,
} from "@chakra-ui/core"; } from "@chakra-ui/core";
import { CheckIcon, StarIcon } from "@chakra-ui/icons"; import { CheckIcon, StarIcon } from "@chakra-ui/icons";
import { HiSparkles } from "react-icons/hi";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { safeImageUrl } from "../util"; import { safeImageUrl } from "../util";
@ -239,23 +240,58 @@ export function NpBadge() {
} }
export function YouOwnThisBadge({ variant = "long" }) { export function YouOwnThisBadge({ variant = "long" }) {
return ( let badge = (
<Badge colorScheme="green" display="flex" alignItems="center"> <Badge
<CheckIcon aria-label="Star" marginRight="1" /> colorScheme="green"
{variant === "long" && <>You own this!</>} display="flex"
{variant === "short" && <>Own</>} alignItems="center"
minHeight="1.5em"
>
<CheckIcon aria-label="Star" />
{variant === "long" && <Box marginLeft="1">You own this!</Box>}
</Badge> </Badge>
); );
if (variant === "short") {
badge = <ItemBadgeTooltip label="You own this">{badge}</ItemBadgeTooltip>;
}
return badge;
} }
export function YouWantThisBadge({ variant = "long" }) { export function YouWantThisBadge({ variant = "long" }) {
return ( let badge = (
<Badge colorScheme="blue" display="flex" alignItems="center"> <Badge
<StarIcon aria-label="Star" marginRight="1" /> colorScheme="blue"
{variant === "long" && <>You want this!</>} display="flex"
{variant === "short" && <>Want</>} alignItems="center"
minHeight="1.5em"
>
<StarIcon aria-label="Star" />
{variant === "long" && <Box marginLeft="1">You want this!</Box>}
</Badge> </Badge>
); );
if (variant === "short") {
badge = <ItemBadgeTooltip label="You want this">{badge}</ItemBadgeTooltip>;
}
return badge;
}
export function MaybeAnimatedBadge() {
return (
<ItemBadgeTooltip label="Maybe animated? (Support only)">
<Badge
colorScheme="orange"
display="flex"
alignItems="center"
minHeight="1.5em"
>
<Box as={HiSparkles} aria-label="Sparkles" />
</Badge>
</ItemBadgeTooltip>
);
} }
export default ItemCard; export default ItemCard;