-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
Callout component can now exist sans icon by adding icon={false} as a prop re 577
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; |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specified why I made the change I did and pointed to the GH ticket for context re #578
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
defaultTheme.ts
used wherever possibleNote 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