Skip to content
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

Merged
merged 5 commits into from Sep 26, 2023

Conversation

EnMod
Copy link
Contributor

@EnMod EnMod commented Sep 6, 2023

🎟️ 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.

  • Add Asana and Preview links above.
  • Conduct thorough self-review.
  • Add or update tests as appropriate.
  • Conduct reasonable cross browser testing for both compatibility and responsive behavior (We have a Sauce Labs account for this, if you don't have access, just ask!).
  • Conduct reasonable accessibility review (use the WAS as a guide or an axe browser plugin until we establish more formal checks).
  • Identify (in the description above) and document (add Asana tasks on this board) any technical debt that you're aware of, but are not addressing as part of this PR.

@changeset-bot
Copy link

changeset-bot bot commented Sep 6, 2023

πŸ¦‹ Changeset detected

Latest commit: dd8b04a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@hashicorp/react-card Minor
@hashicorp/react-related-content Patch

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

@vercel
Copy link

vercel bot commented Sep 6, 2023

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
react-components βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Sep 26, 2023 6:39pm

@EnMod EnMod added enhancement New feature or request release:canary Triggers a canary release for commits to this pull request and removed enhancement New feature or request labels Sep 6, 2023
@EnMod EnMod marked this pull request as ready for review September 7, 2023 14:51
@EnMod EnMod marked this pull request as draft September 7, 2023 14:51
@github-actions
Copy link
Contributor

github-actions bot commented Sep 25, 2023

πŸ“¦ Canary Packages Published

Latest commit: dd8b04a

Published 2 packages

@hashicorp/react-card@0.15.0-canary-20230926184001

npm install @hashicorp/react-card@canary

@hashicorp/react-related-content@0.3.8-canary-20230926184001

npm install @hashicorp/react-related-content@canary

@EnMod EnMod marked this pull request as ready for review September 25, 2023 21:38
@EnMod EnMod requested review from a team and nandereck and removed request for a team September 25, 2023 21:38
@@ -31,4 +31,18 @@ describe('<ResourceCard />', () => {

expect(metaElement).toContainElement(screen.getByText('|'))
})

it('should not render the date if no date is provided', () => {
defaultProps.date = ''
Copy link
Contributor

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: '' }

Copy link
Contributor Author

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)
Copy link
Contributor

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]

Copy link
Contributor Author

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
Copy link
Contributor

@nandereck nandereck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@EnMod EnMod merged commit 901bf28 into main Sep 26, 2023
7 checks passed
@EnMod EnMod deleted the nq.card/make-dates-optional-on-resource-card branch September 26, 2023 19:17
@EnMod EnMod removed the release:canary Triggers a canary release for commits to this pull request label Sep 26, 2023
@hashibot-web hashibot-web mentioned this pull request Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants