From 3e8db228ba981592c63e349a938e1643cfbd1318 Mon Sep 17 00:00:00 2001 From: cade-exygy <131277283+cade-exygy@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:40:00 -0600 Subject: [PATCH] fix: allow subheader to return passed content without wrap (#147) * fix: prevent wrap of elements with p tag * fix: contentSubheader allows return of passed element --- .../listing/ListingCard.stories.tsx | 16 ++++++++++++++++ src/page_components/listing/ListingCard.tsx | 19 ++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/page_components/listing/ListingCard.stories.tsx b/src/page_components/listing/ListingCard.stories.tsx index 53b1bd9..a5fbbed 100644 --- a/src/page_components/listing/ListingCard.stories.tsx +++ b/src/page_components/listing/ListingCard.stories.tsx @@ -110,6 +110,22 @@ export const WithHeaders = () => { ) } +export const WithElementSubHeader = () => { + return ( +
  • Test
  • Test 2
  • , isElement: true }, + }} + /> + ) +} + export const WithPillHeader = () => { return ( { } } + const getTableSubHeader = (subheader: ListingCardHeader, returnElement?: boolean) => { + return React.isValidElement(subheader.content) && returnElement ? ( + subheader.content + ) : ( +

    {subheader?.content}

    + ) + } + const getContentHeader = () => { return (
    @@ -128,7 +137,6 @@ const ListingCard = (props: ListingCardProps) => { {contentProps?.contentSubheader && (

    {contentProps?.contentSubheader?.content}

    )} - {cardTags && cardTags?.length > 0 && (
    {cardTags?.map((cardTag, index) => { @@ -171,10 +179,11 @@ const ListingCard = (props: ListingCardProps) => { contentProps?.tableHeader?.priority ?? 3, "smallWeighted" )} - - {contentProps?.tableSubheader?.content && ( -

    {contentProps?.tableSubheader?.content}

    - )} + {contentProps?.tableSubheader && + getTableSubHeader( + contentProps?.tableSubheader, + contentProps?.tableSubheader?.isElement + )}
    {children && children} {tableProps && (tableProps.data || tableProps.stackedData) && (