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: create Common/BlogPostCard component #6037

Merged
merged 7 commits into from
Oct 26, 2023

Conversation

danielmarcano
Copy link
Contributor

@danielmarcano danielmarcano commented Oct 20, 2023

Description

  • Create the Common/Card component, based on these Figma designs.
    • It takes the following properties:
type Author = {
  fullName: string;
  src: string;
};

export type CardProps = {
  title: ComponentProps<typeof Preview>['title'];
  type: Required<ComponentProps<typeof Preview>>['type'];
  description: string;
  authors: Author[];
  date: Date;
};
  • The component uses the Preview and AvatarGroup components, and semantic HTML tags to keep it as accessible as possible.

The PR includes two minor fixes:

  • Common/AvatarGroup/Avatar: Update component styles as it was creating a layout shift issue, which is not accessible, as it increases Cumulative Layout Shift, a Web Core Vital that is supposed to stay as low as possible. Here's a short video demonstrating this:
delay-ms-issue.mov
  • Common/Preview: the h1 tag has been replaced with an h2 one, so as to avoid having more than one h1 tag per page, as it's not considered a good practice, and is also better for screen reader users.

Validation

  • Here's a short video showcasing the stories for this new component:
card-component.mov
  • Here's a short video showing the styles fix on the Avatar component:
delay-ms-and-layout-fixed.mov
  • Unit tests have been added to prevent regression errors on the Common/BlogPostCard component

Related Issues

Closes #6033.

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run npx turbo lint to ensure the code follows the style guide. And run npx turbo lint:fix to fix the style errors if necessary.
  • I have run npx turbo format to ensure the code follows the style guide.
  • I have run npx turbo test to check if all tests are passing.
  • I've covered new added functionality with unit tests if necessary.

@danielmarcano danielmarcano requested a review from a team as a code owner October 20, 2023 22:03
@vercel
Copy link

vercel bot commented Oct 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 25, 2023 10:55pm

@github-actions
Copy link

github-actions bot commented Oct 21, 2023

Unit Test Coverage Report

Lines Statements Branches Functions
Coverage: 94%
95.07% (309/325) 76.38% (55/72) 93.93% (62/66)

Unit Test Report

Tests Skipped Failures Errors Time
38 0 💤 0 ❌ 0 🔥 6.729s ⏱️

@ovflowd
Copy link
Member

ovflowd commented Oct 21, 2023

Common/AvatarGroup/Avatar: The delayMs prop has been removed from the RedixAvatar.Fallback component, as it was creating a layout shift issue, which is not accessible, as it increases Cumulative Layout Shift, a Web Core Vital that is supposed to stay as low as possible. Here's a short video demonstrating this:

Could you let me know if you are sure about this? According to Radix documentation, delayMs exist exactly to reduce layout shift and reduce screen flickering.

@danielmarcano
Copy link
Contributor Author

danielmarcano commented Oct 21, 2023

Common/AvatarGroup/Avatar: The delayMs prop has been removed from the RedixAvatar.Fallback component, as it was creating a layout shift issue, which is not accessible, as it increases Cumulative Layout Shift, a Web Core Vital that is supposed to stay as low as possible. Here's a short video demonstrating this:

Could you let me know if you are sure about this? According to Radix documentation, delayMs exist exactly to reduce layout shift and reduce screen flickering.

Hi, @ovflowd! Thank you for your comment.

I checked the Radix UI docs before removing the delayMs prop, and noticed that they mentioned flickering, which tends to be associated with the "swap" of two elements, in this case the RadixAvatar.Image and the RadixAvatar.Fallback ones, but does not cause a layout shift.

Here's a video showing the result of removing delayMs. You can notice the flickering issue for src values that do resolve to images:

delay-no-shift-but-flickering.mov

After reading your comment, I have come up with a better way of avoiding the layout shift. This way, we can keep the delayMs prop, and avoid both the flickering issue, and the layout shift issue.

I will push the changes now. This is how it looks like:

delay-ms-and-layout-fixed.mov

Copy link
Member

@canerakdas canerakdas left a comment

Choose a reason for hiding this comment

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

Great work and the component layout exactly matches! I have added some reviews to help 😄

components/Common/Card/index.module.css Outdated Show resolved Hide resolved
components/Common/Card/index.module.css Outdated Show resolved Hide resolved
components/Common/Card/index.tsx Outdated Show resolved Hide resolved
components/Common/Card/index.tsx Outdated Show resolved Hide resolved
components/Common/Card/index.tsx Outdated Show resolved Hide resolved
components/Common/Preview/index.tsx Show resolved Hide resolved
components/Common/Card/index.tsx Outdated Show resolved Hide resolved
components/Common/Card/index.tsx Outdated Show resolved Hide resolved
components/Common/Card/index.stories.tsx Outdated Show resolved Hide resolved
components/Common/Card/index.tsx Outdated Show resolved Hide resolved
@danielmarcano
Copy link
Contributor Author

Great work and the component layout exactly matches! I have added some reviews to help 😄

Thank you for the kind review! I have applied most of the changes you have suggested, and replied to all of them.

I have also left a couple of doubts for @ovflowd to solve, as neither of them are clear from the designs.

@danielmarcano
Copy link
Contributor Author

Hi @bmuenzenmeyer, I have just pushed the latest changes, allowing the Common/Card component to receive more than one author.

@ovflowd
Copy link
Member

ovflowd commented Oct 22, 2023

I have also left a couple of doubts for @ovflowd to solve, as neither of them are clear from the designs.

Hey there, are there still open questions for me?

@ovflowd ovflowd added hacktoberfest This Issue is meant for Hacktoberfest 2023 github_actions:pull-request Trigger Pull Request Checks labels Oct 22, 2023
@github-actions github-actions bot removed the github_actions:pull-request Trigger Pull Request Checks label Oct 22, 2023
@danielmarcano
Copy link
Contributor Author

danielmarcano commented Oct 22, 2023

I have also left a couple of doubts for @ovflowd to solve, as neither of them are clear from the designs.

Hey there, are there still open questions for me?

Hi, @ovflowd! Thanks for asking.

Just a single doubt left: should we pass a limit to the AvatarGroup?

@danielmarcano
Copy link
Contributor Author

Hi, @ovflowd.

I have pushed the changes you have suggested, along with new unit tests for the Common/BlogPostCard component.

Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

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

I know I've left a few last comments but after that I swear, this is good to go.

@danielmarcano
Copy link
Contributor Author

I know I've left a few last comments but after that I swear, this is good to go.

No worries! Thanks for your suggestions and for your feedback. I have just pushed the changes 🚀

@ovflowd ovflowd added the github_actions:pull-request Trigger Pull Request Checks label Oct 26, 2023
@github-actions github-actions bot removed the github_actions:pull-request Trigger Pull Request Checks label Oct 26, 2023
@ovflowd ovflowd added this pull request to the merge queue Oct 26, 2023
Merged via the queue into nodejs:main with commit 303cb62 Oct 26, 2023
12 checks passed
@ovflowd
Copy link
Member

ovflowd commented Oct 26, 2023

Hey @danielmarcano just wanted to again appreciate the fantastic work you've been doing. We truly appreciate it!

@danielmarcano
Copy link
Contributor Author

Hey @danielmarcano just wanted to again appreciate the fantastic work you've been doing. We truly appreciate it!

That's really kind of you, @ovflowd. Thank you for sharing these thoughts with me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest This Issue is meant for Hacktoberfest 2023
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Card Component
7 participants