diff --git a/src/app/ItemPage.js b/src/app/ItemPage.js index 8822dcb..a67fe26 100644 --- a/src/app/ItemPage.js +++ b/src/app/ItemPage.js @@ -2,6 +2,7 @@ import React from "react"; import { css } from "emotion"; import { AspectRatio, + Badge, Button, Box, IconButton, @@ -28,7 +29,6 @@ import { useQuery, useMutation } from "@apollo/client"; import { useParams } from "react-router-dom"; import { - ItemBadge, ItemBadgeList, ItemThumbnail, NcBadge, @@ -148,7 +148,7 @@ function ItemPageBadges({ item, isEmbedded }) { const searchBadgesAreLoaded = item?.name != null && item?.isNc != null; return ( - + {item?.isNc ? : } @@ -160,14 +160,14 @@ function ItemPageBadges({ item, isEmbedded }) { // empty). isLoaded={item.createdAt !== undefined} > - {item.createdAt && } - + ) } @@ -249,7 +249,7 @@ function ItemPageBadges({ item, isEmbedded }) { function LinkBadge({ children, href, isEmbedded }) { return ( - : } - + ); } diff --git a/src/app/ModelingPage.js b/src/app/ModelingPage.js index 1208a69..7145581 100644 --- a/src/app/ModelingPage.js +++ b/src/app/ModelingPage.js @@ -1,5 +1,5 @@ import React from "react"; -import { Box, Tooltip } from "@chakra-ui/core"; +import { Badge, Box, Tooltip } from "@chakra-ui/core"; import gql from "graphql-tag"; import { useQuery } from "@apollo/client"; @@ -7,7 +7,6 @@ import { Delay } from "./util"; import HangerSpinner from "./components/HangerSpinner"; import { Heading1, Heading2, usePageTitle } from "./util"; import ItemCard, { - ItemBadge, ItemBadgeList, ItemCardList, NcBadge, @@ -174,7 +173,7 @@ function ItemModelBadges({ item, currentUserOwnsItem }) { {item.isNc && } {currentUserOwnsItem && } {item.speciesThatNeedModels.map((species) => ( - {species.name} + {species.name} ))} ); @@ -192,7 +191,7 @@ function NewItemBadge({ createdAt }) { placement="top" openDelay={400} > - New! + New! ); } diff --git a/src/app/UserItemsPage.js b/src/app/UserItemsPage.js index 6b65303..8de90f7 100644 --- a/src/app/UserItemsPage.js +++ b/src/app/UserItemsPage.js @@ -17,7 +17,7 @@ import ItemCard, { NpBadge, YouOwnThisBadge, YouWantThisBadge, - ZoneBadgeList, + getZoneBadges, } from "./components/ItemCard"; import useCurrentUser from "./components/useCurrentUser"; import WIPCallout from "./components/WIPCallout"; @@ -259,10 +259,9 @@ function ClosetList({ closetList, isCurrentUser, showHeading }) { {item.isNc ? : } {hasYouOwnThisBadge(item) && } {hasYouWantThisBadge(item) && } - + {getZoneBadges(item.allOccupiedZones, { + variant: "occupies", + })} } /> diff --git a/src/app/WardrobePage/Item.js b/src/app/WardrobePage/Item.js index cea5a02..ab262f5 100644 --- a/src/app/WardrobePage/Item.js +++ b/src/app/WardrobePage/Item.js @@ -21,7 +21,7 @@ import { NpBadge, YouOwnThisBadge, YouWantThisBadge, - ZoneBadgeList, + getZoneBadges, } from "../components/ItemCard"; import SupportOnly from "./support/SupportOnly"; import useSupport from "./support/useSupport"; @@ -231,8 +231,8 @@ function ItemBadges({ item }) { } {item.currentUserOwnsThis && } {item.currentUserWantsThis && } - - + {getZoneBadges(occupiedZones, { variant: "occupies" })} + {getZoneBadges(restrictedZones, { variant: "restricts" })} ); } diff --git a/src/app/components/ItemCard.js b/src/app/components/ItemCard.js index 7d1113e..a251345 100644 --- a/src/app/components/ItemCard.js +++ b/src/app/components/ItemCard.js @@ -199,34 +199,11 @@ export function ItemCardList({ children }) { ); } -export function ItemBadgeList({ children }) { +export function ItemBadgeList({ children, ...props }) { return ( - - ! The individual - // ItemBadges have their own `margin="1"`, which we counteract here for - // consistency. - // - // The difference between this and `Wrap` is that `Wrap` uses - // React.Children to wrap its children in containers with `margin="1"`, - // but that doesn't work when the badges aren't _direct_ children, like - // in `ZoneBadgeList`. The badges are what we want to have wrap, not - // whatever component happens to be the direct child! - margin="-1" - display="flex" - flexWrap="wrap" - > - {children} - - - ); -} - -export function ItemBadge({ children, ...props }) { - return ( - + {children} - + ); } @@ -245,9 +222,9 @@ export function ItemBadgeTooltip({ label, children }) { export function NcBadge() { return ( - + NC - + ); } @@ -257,14 +234,14 @@ export function NpBadge() { // default of inline-block. return ( - NP + NP ); } export function YouOwnThisBadge({ variant = "long" }) { let badge = ( - {variant === "long" && You own this!} - + ); if (variant === "short") { @@ -284,7 +261,7 @@ export function YouOwnThisBadge({ variant = "long" }) { export function YouWantThisBadge({ variant = "long" }) { let badge = ( - {variant === "long" && You want this!} - + ); if (variant === "short") { @@ -317,11 +294,11 @@ function ZoneBadge({ variant, zoneLabel }) { - + {shorthand} - + ); } @@ -329,15 +306,15 @@ function ZoneBadge({ variant, zoneLabel }) { if (shorthand !== zoneLabel) { return ( - {shorthand} + {shorthand} ); } - return {shorthand}; + return {shorthand}; } -export function ZoneBadgeList({ zones, variant }) { +export function getZoneBadges(zones, propsForAllBadges) { // Get the sorted zone labels. Sometimes an item occupies multiple zones of // the same name, so it's important to de-duplicate them! let labels = zones.map((z) => z.label); @@ -345,21 +322,21 @@ export function ZoneBadgeList({ zones, variant }) { labels = [...labels].sort(); return labels.map((label) => ( - + )); } export function MaybeAnimatedBadge() { return ( - - + ); }