diff --git a/.changeset/old-comics-argue.md b/.changeset/old-comics-argue.md
new file mode 100644
index 000000000..352829fa6
--- /dev/null
+++ b/.changeset/old-comics-argue.md
@@ -0,0 +1,5 @@
+---
+'@hashicorp/react-card': minor
+---
+
+Makes the `date` prop optional, preventing it and the `|` separator from rendering if not set.
diff --git a/package-lock.json b/package-lock.json
index 378216c57..4b0980c58 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -39694,7 +39694,7 @@
},
"packages/card": {
"name": "@hashicorp/react-card",
- "version": "0.12.0",
+ "version": "0.14.0",
"license": "MPL-2.0",
"dependencies": {
"@hashicorp/react-expandable-arrow": "^0.1.0",
@@ -39722,7 +39722,7 @@
},
"packages/checkbox-input": {
"name": "@hashicorp/react-checkbox-input",
- "version": "5.0.3",
+ "version": "6.0.0",
"license": "MPL-2.0",
"dependencies": {
"classnames": "^2.3.1"
@@ -39746,7 +39746,7 @@
},
"packages/code-block": {
"name": "@hashicorp/react-code-block",
- "version": "6.3.0",
+ "version": "6.4.0",
"license": "MPL-2.0",
"dependencies": {
"@hashicorp/react-inline-svg": "^6.0.3",
@@ -40405,7 +40405,7 @@
},
"packages/inline-video": {
"name": "@hashicorp/react-inline-video",
- "version": "0.4.0",
+ "version": "0.5.0",
"license": "MPL-2.0",
"dependencies": {
"classnames": "^2.3.1",
@@ -40859,10 +40859,10 @@
},
"packages/related-content": {
"name": "@hashicorp/react-related-content",
- "version": "0.3.5",
+ "version": "0.3.7",
"license": "MPL-2.0",
"dependencies": {
- "@hashicorp/react-card": "^0.12.0",
+ "@hashicorp/react-card": "^0.14.0",
"@hashicorp/react-standalone-link": "^0.4.0",
"classnames": "^2.3.1"
},
@@ -41088,7 +41088,7 @@
},
"packages/text-input": {
"name": "@hashicorp/react-text-input",
- "version": "5.0.2",
+ "version": "6.0.0",
"license": "MPL-2.0",
"dependencies": {
"classnames": "^2.3.1"
@@ -41169,7 +41169,7 @@
},
"packages/textarea-input": {
"name": "@hashicorp/react-textarea-input",
- "version": "1.1.0",
+ "version": "2.0.0",
"license": "MPL-2.0",
"dependencies": {
"clsx": "^1.1.1"
@@ -41222,11 +41222,11 @@
},
"packages/video-feature": {
"name": "@hashicorp/react-video-feature",
- "version": "0.2.1",
+ "version": "0.2.2",
"license": "MPL-2.0",
"dependencies": {
"@hashicorp/react-author-byline": "^0.4.0",
- "@hashicorp/react-inline-video": "^0.4.0",
+ "@hashicorp/react-inline-video": "^0.5.0",
"classnames": "^2.3.1"
},
"peerDependencies": {
diff --git a/packages/card/docs.mdx b/packages/card/docs.mdx
index 0d0594398..fcfb61124 100644
--- a/packages/card/docs.mdx
+++ b/packages/card/docs.mdx
@@ -316,7 +316,6 @@ A component used to promote and link to marketing pages, always using a descript
appearance="dark"
heading="Display 5 - 4 lines with character limit of 130. Leo mauris fermentum pharetra blandit tellus"
category="Category"
- date="August 15, 2022"
thumbnail={{
src: 'https://www.datocms-assets.com/19447/1648680074-screenshot-2022-03-31-at-00-40-47.png',
alt: 'HashiConf Europe 2022 Recap',
diff --git a/packages/card/resource-card/index.test.tsx b/packages/card/resource-card/index.test.tsx
index b9f29f4c2..7faf30488 100644
--- a/packages/card/resource-card/index.test.tsx
+++ b/packages/card/resource-card/index.test.tsx
@@ -18,7 +18,7 @@ const defaultProps = {
}
describe('', () => {
- it('should render the provided metadata correctly', () => {
+ it('should render the provided date and category with separator', () => {
const expectedMeta = [defaultProps.date, defaultProps.category]
render()
@@ -31,4 +31,18 @@ describe('', () => {
expect(metaElement).toContainElement(screen.getByText('|'))
})
+
+ it('should not render the date if no date is provided', () => {
+ defaultProps.date = ''
+
+ render()
+
+ const metaElement = screen.getByTestId('wpl-card-meta')
+
+ expect(metaElement).toContainElement(
+ screen.getByText(defaultProps.category)
+ )
+
+ expect(metaElement).not.toContainElement(screen.queryByText('|'))
+ })
})
diff --git a/packages/card/resource-card/index.tsx b/packages/card/resource-card/index.tsx
index 6d2a44ddb..3a351181b 100644
--- a/packages/card/resource-card/index.tsx
+++ b/packages/card/resource-card/index.tsx
@@ -8,7 +8,7 @@ import type { CardProps, ThumbnailProps } from '../types'
export interface ResourceCardProps {
heading: string
- date: string
+ date?: string
category: string
link: string
productBadges?: CardProps['productBadges']
@@ -25,6 +25,12 @@ export function ResourceCard({
thumbnail,
appearance,
}: ResourceCardProps): JSX.Element {
+ const meta: string[] = [category]
+
+ if (date) {
+ meta.unshift(date)
+ }
+
return (
-
+
{heading}
{productBadges && productBadges?.length > 0 ? (