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

fix(callout): allow Callout component to not have an icon #717

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

liaprins
Copy link
Contributor

@liaprins liaprins commented Nov 29, 2023

Callout component can now exist sans icon by adding icon={false} as a prop

re #577

Summary

Callout
Github issue: #577

Recommended fix (per @tihuan ), documenting here for posterity:
Change the source code from

if (icon) return icon;
to:
if (icon !== undefined) return icon;
"And then the following will work:
icon={false} - it will not take up space in the component. Similar to display: none;
icon={<></>} - it will still take up space in the component, but just empty space. Similar to visibility: hidden;
icon={null} - this is a little counter intuitive, but it will fall back to using MUI's iconMapping"

Checklist

  • Default Story in Storybook
  • LivePreview Story in Storybook
  • Test Story in Storybook
  • Tests written
  • Variables from defaultTheme.ts used wherever possible
  • If updating an existing component, depreciate flag has been used where necessary
  • Chromatic build verified by @chanzuckerberg/sds-design

Note that I am also having David Ruiz help with reviewing bug fixes for SDS Hackday (which fixing this bug was part of), but I couldn't find him listed yet when I went to add reviewers

Callout component can now exist sans icon by adding icon={false} as a prop

re 577
@DRuizCZI
Copy link

LGTM but i will feel better after @Timmy or @masoudmanson Take a look

@@ -56,7 +56,7 @@ const Callout = ({
};

const getIcon = () => {
if (icon) return icon;
if (icon !== undefined) return icon;
Copy link
Contributor

Choose a reason for hiding this comment

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

Niice! Thanks so much for the fix, @liaprins 🙏 ❤️

Can we add a comment to explain why we explicitly use icon !== undefined here please? In case someone in the future "refactors" this back to if (icon) return icon lol

Something like:

/**
 * (liaprins): Explicitly use `icon !== undefined` to fix bug in ticket: https://github.com/chanzuckerberg/sci-components/issues/577 
 */

Or something better!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, thanks for the suggestion! I have finally updated to add the comment as suggested!

Copy link
Contributor

@masoudmanson masoudmanson left a comment

Choose a reason for hiding this comment

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

Great catch, @liaprins!
Thank you for addressing this issue. The change LGTM.

However, before merging, let's ensure we add the comment mentioned by @tihuan. Once that's added, we're all set to merge this. Appreciate your quick action on this! 🎉⭐️

@masoudmanson masoudmanson added Ready for review This PR is ready for review Hackday labels Dec 5, 2023
liaprins and others added 2 commits January 12, 2024 14:12
Specified why I made the change I did and pointed to the GH ticket for context

re #578
@liaprins liaprins merged commit 4215898 into main Jan 12, 2024
@liaprins liaprins deleted the callout-icon-bug-fix branch January 12, 2024 22:41
@masoudmanson masoudmanson added Released and removed Ready for review This PR is ready for review labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants