New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(card): Make date
optional on <ResourceCard />
#1001
Conversation
π¦ Changeset detectedLatest commit: dd8b04a The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
π¦ Canary Packages PublishedLatest commit: dd8b04a Published 2 packages@hashicorp/react-card@0.15.0-canary-20230926184001
@hashicorp/react-related-content@0.3.8-canary-20230926184001
|
@@ -31,4 +31,18 @@ describe('<ResourceCard />', () => { | |||
|
|||
expect(metaElement).toContainElement(screen.getByText('|')) | |||
}) | |||
|
|||
it('should not render the date if no date is provided', () => { | |||
defaultProps.date = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of modifying default props, make a new object and spread defaultProps
const defaultPropsWithoutDate = { ...defaultProps, date: '' }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, addressed here:
dd8b04a
const meta: string[] = [category] | ||
|
||
if (date) { | ||
meta.unshift(date) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of mutating an array, let's use something like this:
const meta: string[] = date ? [date, category] : [category]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, another good immutability catch π Addressed here:
dd8b04a
- Test: Spread default props into new object - meta assignment: use new arrays as values rather than mutating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
ποΈ Asana Task for request prompting the change
π’ PR on
www
implementing the canary releaseπ Preview Link
π Preview Link for example usage on
www
(see each case study library item's card)Description
This PR updates our
<ResourceCard />
component to make showing the date optional; if no date is passed in, no date (or|
separator) is shown.PR Checklist π
Items in this checklist may not may not apply to your PR, but please consider each item carefully.