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

DSD-1688: Updates StatusBadge styles and Storybook docs #1528

Merged
merged 5 commits into from
Feb 22, 2024

Conversation

oliviawongnyc
Copy link
Collaborator

Fixes JIRA ticket DSD-1688

This PR does the following:

  • Updates the StatusBadge styles so that if an icon is passed, the icon and text line up with one another (notably, changed display to flex and added an alignItems: center)
  • Update Storybook with examples

How has this been tested?

  • Locally, in Storybook

Accessibility concerns or updates

  • I added a caveat in Storybook that if an icon is passed to the StatusBadge, it should always be accompanied by text so the user knows the meaning of the badge. I am not sure if this i true, but it seemed logical. Interested to hear your thoughts.

Checklist:

  • I have updated the Storybook documentation accordingly.
  • I have added relevant accessibility documentation for this pull request.
  • All new and existing tests passed.

Front End Review:

  • Review the Vercel preview deployment once it is ready.

Copy link

vercel bot commented Feb 20, 2024

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

Name Status Preview Comments Updated (UTC)
nypl-design-system ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 22, 2024 7:14pm

@oliviawongnyc oliviawongnyc changed the title Updates StatusBadge styles and Storybook docs DSD-1688: Updates StatusBadge styles and Storybook docs Feb 20, 2024
@oliviawongnyc oliviawongnyc added the Needs Review Pull requests that are ready for peer review. label Feb 20, 2024
You may render an icon within the `StatusBadge` by passing it as a child to the component.
If you are using an icon, you should still pass text to the badge so that the user can
understand its meaning.

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a visual code snippet here to show the pattern for adding an icon and text inside of the StatusBadge?

Copy link
Member

@EdwinGuzman EdwinGuzman left a comment

Choose a reason for hiding this comment

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

This looks good. Can you try pointing this to the react 18 branch? There might be some minor conflicts.

@EdwinGuzman
Copy link
Member

Never mind my previous comment about pointing this to the react 18 branch. I forgot we were making a new 2.1.6 (right @bigfishdesign13 ?) release so this PR is fine.

Just add the code snippet in the mdx file.

Copy link
Collaborator

@bigfishdesign13 bigfishdesign13 left a comment

Choose a reason for hiding this comment

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

This looks good, but please see my comment.

And yes, we will be putting out a 2.1.6 release.

<StatusBadge level="low">
<Icon
color="ui.black"
mr="2"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Adding an icon will require some spacing between the icon and the text, which is what you have done here. However, there are a few things I would like to consider as we decide how to handle this.

The Icon component includes an align prop which adds 4px spacing to the left or right based on the prop value. I never liked this prop, but, that being said, I've never done anything about it. Ultimately, I don't think the prop would work here because the space value is less than what we need (4px vs. 8px).

Another option would be to apply styles to the StatusBadge component that would handle the spacing in a flex element. You just added display: "flex", so this option is viable. With that, we would need to also add gap: "xs" and that woudl enforce a standard spacing in the component. While I do like this idea, this runs counter what we have done in other components that can accept an icon (ex. Button and Link).

Another option would be to ask consuming apps to pass in the appropriate spacing value, like you've done here. If this will be our recommendation, please update the example to use mr="xs" instead of mr="2".

What do you think?

Cc @EdwinGuzman

Copy link
Member

Choose a reason for hiding this comment

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

Right. Let's stick to being consistent and let the dev/consuming app add the appropriate styles in the Icon when it is passed. This means we may need more code snippets if the icon is added at the end rather than at the beginning.

Do add that we highly recommend the styles when adding the example and that the "xs" value is consistent with NYPL designs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay! Take a look at what I pushed up and lmk if that is aligned with what you are thinking.

@bigfishdesign13 bigfishdesign13 added Changes Requested Pull requests where changes have been requested in peer review. and removed Needs Review Pull requests that are ready for peer review. labels Feb 21, 2024
Copy link
Collaborator

@bigfishdesign13 bigfishdesign13 left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Member

@EdwinGuzman EdwinGuzman left a comment

Choose a reason for hiding this comment

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

Thanks!

@EdwinGuzman EdwinGuzman added Ship It Pull requests that have been reviewed and approved. and removed Changes Requested Pull requests where changes have been requested in peer review. labels Feb 22, 2024
@oliviawongnyc oliviawongnyc merged commit 2bd70bb into development Feb 22, 2024
5 checks passed
@oliviawongnyc oliviawongnyc deleted the DSD-1688/StatusBadge-icon branch February 22, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ship It Pull requests that have been reviewed and approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants