From 772065815a93848e154a0b20aaa2dd574c07ab81 Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 22 Sep 2020 04:17:27 -0700 Subject: [PATCH] Badge for animated items, support only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/app/WardrobePage/Item.js | 13 ++++++++ src/app/components/ItemCard.js | 56 ++++++++++++++++++++++++++++------ 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/src/app/WardrobePage/Item.js b/src/app/WardrobePage/Item.js index 08b579e..4289cfe 100644 --- a/src/app/WardrobePage/Item.js +++ b/src/app/WardrobePage/Item.js @@ -23,12 +23,14 @@ import { ItemCardContent, ItemBadgeList, ItemBadgeTooltip, + MaybeAnimatedBadge, NcBadge, NpBadge, YouOwnThisBadge, YouWantThisBadge, } from "../components/ItemCard"; import SupportOnly from "./support/SupportOnly"; +import useSupport from "./support/useSupport"; const LoadableItemPageDrawer = loadable(() => import("../ItemPageDrawer")); const LoadableItemSupportDrawer = loadable(() => @@ -204,12 +206,16 @@ function ItemContainer({ children, isDisabled = false }) { } function ItemBadges({ item }) { + const { isSupportUser } = useSupport(); const occupiedZoneLabels = getZoneLabels( item.appearanceOn.layers.map((l) => l.zone) ); const restrictedZoneLabels = getZoneLabels( item.appearanceOn.restrictedZones.filter((z) => z.isCommonlyUsedByItems) ); + const isMaybeAnimated = item.appearanceOn.layers.some( + (l) => l.canvasMovieLibraryUrl + ); return ( @@ -224,6 +230,13 @@ function ItemBadges({ item }) { // than try to line things up like a table. )} + { + // 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 , to avoid adding extra badge list spacing + // on the additional empty child. + isMaybeAnimated && isSupportUser && + } {item.currentUserOwnsThis && } {item.currentUserWantsThis && } {occupiedZoneLabels.map((zoneLabel) => ( diff --git a/src/app/components/ItemCard.js b/src/app/components/ItemCard.js index 4846115..df4b136 100644 --- a/src/app/components/ItemCard.js +++ b/src/app/components/ItemCard.js @@ -10,6 +10,7 @@ import { useTheme, } from "@chakra-ui/core"; import { CheckIcon, StarIcon } from "@chakra-ui/icons"; +import { HiSparkles } from "react-icons/hi"; import { Link } from "react-router-dom"; import { safeImageUrl } from "../util"; @@ -239,23 +240,58 @@ export function NpBadge() { } export function YouOwnThisBadge({ variant = "long" }) { - return ( - - - {variant === "long" && <>You own this!} - {variant === "short" && <>Own} + let badge = ( + + + {variant === "long" && You own this!} ); + + if (variant === "short") { + badge = {badge}; + } + + return badge; } export function YouWantThisBadge({ variant = "long" }) { - return ( - - - {variant === "long" && <>You want this!} - {variant === "short" && <>Want} + let badge = ( + + + {variant === "long" && You want this!} ); + + if (variant === "short") { + badge = {badge}; + } + + return badge; +} + +export function MaybeAnimatedBadge() { + return ( + + + + + + ); } export default ItemCard;