diff --git a/UNRELEASED.md b/UNRELEASED.md index fa215e7a761..b800fc5c53c 100644 --- a/UNRELEASED.md +++ b/UNRELEASED.md @@ -8,6 +8,8 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f ### Enhancements +- Updated `MediaCard` to accept ReactNode as title and make `primaryAction` optional ([#3552](https://github.com/Shopify/polaris-react/pull/3552)) + ### Bug fixes ### Documentation diff --git a/src/components/MediaCard/MediaCard.tsx b/src/components/MediaCard/MediaCard.tsx index d149032ddb2..9e5c9bbc988 100644 --- a/src/components/MediaCard/MediaCard.tsx +++ b/src/components/MediaCard/MediaCard.tsx @@ -21,11 +21,11 @@ interface MediaCardProps { /** The visual media to display in the card */ children: React.ReactNode; /** Heading content */ - title: string; + title: React.ReactNode; /** Body content */ description: string; /** Main call to action, rendered as a basic button */ - primaryAction: Action; + primaryAction?: Action; /** Secondary call to action, rendered as a plain button */ secondaryAction?: Action; /** Action list items to render in ellipsis popover */ @@ -53,6 +53,13 @@ export function MediaCard({ const i18n = useI18n(); const {value: popoverActive, toggle: togglePopoverActive} = useToggle(false); + let headerMarkup = null; + if (title) { + const headerContent = + typeof title === 'string' ? {title} : title; + headerMarkup =
{headerContent}
; + } + const popoverActivator = (