diff --git a/src/components/atoms/HexagonBase.tsx b/src/components/atoms/HexagonBase.tsx new file mode 100644 index 0000000..32d4cc4 --- /dev/null +++ b/src/components/atoms/HexagonBase.tsx @@ -0,0 +1,26 @@ +import React from "react"; + +type HexagonBaseProps = { + rounded?: boolean; +} & React.ComponentPropsWithoutRef<"div">; + +export const HexagonBase: React.FunctionComponent = ( + props +) => { + const { rounded = false, ...otherProps } = props; + + // FIXME: Display the Verida Badges correctly in a rounded hexagonal shape and get rid of the 'rounded' prop + + return ( +
+ ); +}; diff --git a/src/components/atoms/index.ts b/src/components/atoms/index.ts index 218f194..0f101fd 100644 --- a/src/components/atoms/index.ts +++ b/src/components/atoms/index.ts @@ -7,6 +7,7 @@ export * from "./ButtonLink"; export * from "./ButtonLinkBase"; export * from "./ChainIconContainer"; export * from "./Chip"; +export * from "./HexagonBase"; export * from "./Icon"; export * from "./IconButton"; export * from "./IconButtonLink"; diff --git a/src/components/molecules/BadgeCard.tsx b/src/components/molecules/BadgeCard.tsx deleted file mode 100644 index 9a5f14d..0000000 --- a/src/components/molecules/BadgeCard.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React from "react"; -import { Collectible } from "lib/types"; -import { AssetMedia } from "components/atoms"; - -type BadgeCardProps = { - badge: Collectible; - variant?: "standard" | "compact"; -} & Omit, "children">; - -/** Render a card displaying a badge */ -export const BadgeCard: React.FC = (props) => { - const { badge, variant = "standard", ...otherProps } = props; - - return ( -
-
- -
-
- ); -}; diff --git a/src/components/molecules/BadgeMosaicItem.tsx b/src/components/molecules/BadgeMosaicItem.tsx new file mode 100644 index 0000000..867f336 --- /dev/null +++ b/src/components/molecules/BadgeMosaicItem.tsx @@ -0,0 +1,38 @@ +import { HexagonBase } from "components/atoms"; +import { Badge } from "lib/types"; +import React from "react"; +import { Link } from "react-router-dom"; + +type HexagonProps = { + badge: Badge; + to: string; + disableShadow?: boolean; +} & Omit, "className">; + +export const BadgeMosaicItem: React.FunctionComponent = ( + props +) => { + const { badge, to, disableShadow = false, ...otherProps } = props; + + return ( +
  • + + + {badge.tokenLabel} + + + {!disableShadow && ( +
    + +
    + )} +
  • + ); +}; diff --git a/src/components/molecules/index.ts b/src/components/molecules/index.ts index 8e2f8f7..154956d 100644 --- a/src/components/molecules/index.ts +++ b/src/components/molecules/index.ts @@ -1,7 +1,7 @@ export * from "./AssetDetailsPropertyItem"; export * from "./AssetDetailsPropertyList"; export * from "./AssetPriceChip"; -export * from "./BadgeCard"; +export * from "./BadgeMosaicItem"; export * from "./ChainIcon"; export * from "./CollectibleCard"; export * from "./CopyToClipboardButton"; diff --git a/src/components/organisms/BadgeGrid.tsx b/src/components/organisms/BadgeGrid.tsx deleted file mode 100644 index 5277362..0000000 --- a/src/components/organisms/BadgeGrid.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { BadgeCard } from "components/molecules"; -import { Badge } from "lib/types"; -import React from "react"; -import { Link } from "react-router-dom"; - -type BadgeGridProps = { - badges: Badge[]; -} & React.ComponentPropsWithoutRef<"div">; - -export const BadgeGrid: React.FC = (props) => { - const { badges, ...containerProps } = props; - return ( -
    -
      - {badges.map((badge) => ( -
    • - - - -
    • - ))} -
    -
    - ); -}; diff --git a/src/components/organisms/BadgeMosaic.tsx b/src/components/organisms/BadgeMosaic.tsx new file mode 100644 index 0000000..aedd5ac --- /dev/null +++ b/src/components/organisms/BadgeMosaic.tsx @@ -0,0 +1,30 @@ +import React from "react"; +import { Badge } from "lib/types"; +import { BadgeMosaicItem } from "components/molecules"; + +type BadgeMosaicProps = { + badges: Badge[]; +} & React.ComponentPropsWithoutRef<"div">; + +export const BadgeMosaic: React.FunctionComponent = ( + props +) => { + const { badges, ...containerProps } = props; + + // For n columns: + // grid width = (3 * n) / (3 * n + 1) * 100% + // grid margin-top = sqrt(3) / (3 * n + 1) * 100% + return ( +
    +
      + {badges.map((badge) => ( + + ))} +
    +
    + ); +}; diff --git a/src/components/organisms/BadgesSection.tsx b/src/components/organisms/BadgesSection.tsx index d09a517..4f95262 100644 --- a/src/components/organisms/BadgesSection.tsx +++ b/src/components/organisms/BadgesSection.tsx @@ -1,9 +1,9 @@ import React, { useCallback } from "react"; import { useIntl } from "react-intl"; -import { BadgeCard, ProfileSectionWrapper } from "components/molecules"; +import { BadgeMosaicItem, ProfileSectionWrapper } from "components/molecules"; import { Badge } from "lib/types"; -import { Button } from "components/atoms"; -import { Link, useNavigate } from "react-router-dom"; +import { Button, HexagonBase } from "components/atoms"; +import { useNavigate } from "react-router-dom"; import { MAX_BADGES_IN_PROFILE_SECTION } from "lib/constants"; type BadgesSectionProps = { @@ -54,30 +54,48 @@ export const BadgesSection: React.FC = ({ badges }) => { title={sectionTitle} badgeValue={badges.length} onClickMore={handleClickMore} + style={{ marginBottom: "-1rem" }} > -
      - {truncatedBadgeList.map((badge) => ( -
    • +
      +
        - - - - - ))} - {hasMore && ( -
      • - {showAllButton} -
      • - )} -
      - {hasMore &&
      {showAllButton}
      } + {truncatedBadgeList.map((badge) => ( + + ))} + {/* FIXME: Use rounded hexagonal shape, see HexagonBase */} + {hasMore && ( + <> +
    • + +
    • +
    • + + {showAllButton} + +
    • + + )} +
    + + {hasMore &&
    {showAllButton}
    } + ); }; diff --git a/src/components/organisms/CollectiblesSection.tsx b/src/components/organisms/CollectiblesSection.tsx index c6aedae..259f8d4 100644 --- a/src/components/organisms/CollectiblesSection.tsx +++ b/src/components/organisms/CollectiblesSection.tsx @@ -56,14 +56,14 @@ export const CollectiblesSection: React.FC = ( ); - // TODO: Handle click on collectible when collectible page implemented return ( -
      +
        {truncatedCollectiblesList.map((collectible) => (
      • = (
      • )}
      - {hasMore &&
      {showAllButton}
      } + {hasMore &&
      {showAllButton}
      } ); }; diff --git a/src/components/organisms/index.ts b/src/components/organisms/index.ts index 2143f36..b382912 100644 --- a/src/components/organisms/index.ts +++ b/src/components/organisms/index.ts @@ -1,6 +1,6 @@ export * from "./AssetDetailsMainInfo"; export * from "./BadgeDetailsProperties"; -export * from "./BadgeGrid"; +export * from "./BadgeMosaic"; export * from "./BadgesSection"; export * from "./CollectibleDetailsProperties"; export * from "./CollectibleGrid"; diff --git a/src/components/pages/BadgeListView.tsx b/src/components/pages/BadgeListView.tsx index 194b7ed..3ea14aa 100644 --- a/src/components/pages/BadgeListView.tsx +++ b/src/components/pages/BadgeListView.tsx @@ -1,6 +1,6 @@ import React from "react"; import { PageWrapper, RedirectionCard } from "components/molecules"; -import { BadgeGrid } from "components/organisms"; +import { BadgeMosaic } from "components/organisms"; import { useBadges, useProfileData } from "lib/hooks"; import { useIntl } from "react-intl"; import { useParams } from "react-router-dom"; @@ -47,7 +47,7 @@ export const BadgeListView: React.FunctionComponent = () => { return ( {badges?.length ? ( - + ) : (