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

Card image/description independent of hero image/description #1244

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

dzole0311
Copy link
Collaborator

@dzole0311 dzole0311 commented Nov 6, 2024

Related Ticket: US-GHG-Center/veda-config-ghg#636

Description of Changes

  1. Introduced new cardDescription and cardMedia props to enable customizable card content
  2. Implemented a fallback background color for cases where no media (e.g image source) is provided

These updates are applied across various places where the card component is used (story cards) but also layer cards in the Data Catalog and the E&A Catalog to better control displayed descriptions and images.

Notes & Questions About Changes

Validation / Testing

  1. Add cardDescription to the 'This is the life of water' story in the MDX configuration file
  2. Verify that /stories displays the newly added cardDescription on the card
  3. Click on the story -> verify that the hero section retains its previous description, separate from the card description
  4. Try the same with cardMedia
  5. Also try to remove both the cardMedia and the media prop -> verify that there's a fallback background color shown

Verify that the behavior below (copied from the issues' acceptance criteria) is applied:

  1. Story and dataset administrators can define a hero image and a card image separately from one another, within the mdx file
  2. Story and dataset administrators can define a hero description and a card description separately from one another, within the mdx file
  3. If a story or dataset does not have any hero or card images configured, then we default to a blank space of a solid primary color (like the blue hero for Data Catalog in GHGC)
  4. If a story or dataset has a hero image defined, but no card image defined, then the card image shows the hero image (like how it currently functions)

@dzole0311 dzole0311 marked this pull request as draft November 6, 2024 12:19
Copy link

netlify bot commented Nov 6, 2024

Deploy Preview for veda-ui ready!

Name Link
🔨 Latest commit 842216d
🔍 Latest deploy log https://app.netlify.com/sites/veda-ui/deploys/672dcf5470d3590008b0a217
😎 Deploy Preview https://deploy-preview-1244--veda-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@dzole0311 dzole0311 marked this pull request as ready for review November 6, 2024 12:34
Copy link
Member

@AliceR AliceR left a comment

Choose a reason for hiding this comment

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

Yay, prettier formatting 🙌
Just leaving some thoughts I had when reading the code.

Testing the branch locally works as stated, thank you for listing the detailed verification steps!
Do you think we can consolidate the logic of when to display what in some testable functions, and actually add tests for them? Maybe unit tests, or even via playwright? This way we have a good documentation of the indented behavior as well, for future reference.

@dzole0311 dzole0311 requested a review from AliceR November 8, 2024 08:53
Copy link
Member

@AliceR AliceR left a comment

Choose a reason for hiding this comment

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

Awesome! Great to have extensive tests, love it 🙌
Tested the branch locally and run the tests, it all works perfectly.

cardDescription: ''
} as DatasetData;

expect(getDescription(data)).toBe('');
Copy link
Member

Choose a reason for hiding this comment

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

Thats an interesting one! Do we want the card title to be blank in that case, or should we treat an empty string as null and display the fallback?
Just wondering, we can discuss it once we hit the issue! Glad we have the test specifying the current behavior 🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wanted to test how the markdown parser handles empty strings, but in terms of fallbacks, there's no fallback for the description e.g. we will not show anything if description or cardDescription are empty or missing (so the test reflects the current behavior)

imgSrc={cardMedia?.src}
imgAlt={cardMedia?.alt}
description={getDescription(d)}
imgSrc={getMediaProperty(undefined, d, 'src')}
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer null instead of undefined in this case, to mark it as intentional.
We don't have to change it now, since we use undefined in several places throughout the code already, but maybe consider it for the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Noted, will consider switching to null next time 👍

@dzole0311 dzole0311 merged commit 2c7561f into main Nov 11, 2024
9 checks passed
@dzole0311 dzole0311 deleted the 636-deoucple-card-hero-content branch November 11, 2024 08:28
@AliceR AliceR mentioned this pull request Nov 11, 2024
AliceR added a commit that referenced this pull request Nov 12, 2024
## 🎉 Features
* Card image/description independent of hero image/description by
@dzole0311 in #1244

## 🚀 Improvements
* Cookie consent code cleanup by @snmln in
#1199 , and @hanbyul-here in
#1240 , and @hanbyul-here in
#1241
* Add ADR about design system change by @j08lue in
#890
* Update condition to run playwright tests on release branches by
@dzole0311 in #1228
* Update STYLE_GUIDE.md by @AliceR in
#1227
* Fix lint configuration by @AliceR in
#1219
* Add tests for the AOI feature specification by @AliceR in
#1216
* Set data catalog filters to be closed by default by @vgeorge in
#1243
* Update tsconfig and make nav interfaces exposable for consumption by
@sandrahoang686 in #1223

## 🐛 Fixes
* Hotfix to hide the external link badge from cards by @dzole0311 in
#1231

## New Contributors
* @vgeorge made their first contribution in
#1243

**Full Changelog**:
v5.9.0...v5.10.0
@dzole0311 dzole0311 mentioned this pull request Nov 20, 2024
dzole0311 added a commit that referenced this pull request Nov 21, 2024
**Related Ticket:** #1264

### Description of Changes
Removed minHeight prop to avoid undesired card behavior. The css prop
was introduced here: #1244

### Notes & Questions About Changes
_{Add additonal notes and outstanding questions here related to changes
in this pull request}_

### Validation / Testing
1. Open the stories page where there are card components
2. Verify that the images in the cards no longer have a minHeight
property
4. Verify that the card layout appears consistent and the image heights
are reduced compared to the previous behavior on v10.0.0

Or see the Air Quality card here:

- Before: https://deploy-preview-1250--veda-ui.netlify.app/stories
- After: https://deploy-preview-1265--veda-ui.netlify.app/stories
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.

2 participants