-
Notifications
You must be signed in to change notification settings - Fork 1k
Button - allow caller to specify icon for kind in theme and enhance kind padding #6297
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
Conversation
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.
Looks good. Just a minor typo in a comment
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.
It seems odd to me that we would need to set if I don't want to modify it from its base:
active: {
'cta-alternate': {
icon: <Hpe color="brand" />,
},
},
My expectation would be that if this is undefined, the active state would inherit the kind's base icon color.
Thoughts? Investigate getIconColor logic?
I would agree if it doesn't deviate from its base then I don't think we should have to define it again. Let me investigate the getIconColor logic. EDIT: This should be resolved in the latest commit. |
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.
Functionality and implementation are looking good. Small types / theme question.
@@ -68,7 +68,7 @@ if (process.env.NODE_ENV !== 'production') { | |||
primary: PropTypes.bool, | |||
reverse: PropTypes.bool, | |||
secondary: PropTypes.bool, | |||
size: PropTypes.oneOf(['small', 'medium', 'large']), | |||
size: PropTypes.oneOf(['small', 'medium', 'large', 'xlarge']), |
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.
Also noticing, that kind
is not in propTypes definition, nor is it documented. Is that still purposeful?
cc: @jcfilben
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.
We do have it in typescript, so it feels like adding it here would be reasonable but maybe for sake of progressing this PR we can handle that in a small standalone PR (since it's an existing thing)/
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.
Yes, I was not intending it for this PR, rather a point of awareness and stimulate discussion.
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.
Also noticing, that kind is not in propTypes definition, nor is it documented. Is that still purposeful?
Sorry for slow response, I must have missed this comment when I was originally tagged. Anyway I'm looking into this... It also looks like the TS definition for kind is 'string' but looking at the code I think it could be a 'string' or 'object'. I'm not sure why we aren't documenting this, I can check with Shimi and maybe get more context.
Co-authored-by: Eric Soderberg <eric.soderberg@hpe.com>
Co-authored-by: Matthew Glissmann <mdglissmann@gmail.com>
Co-authored-by: Matthew Glissmann <mdglissmann@gmail.com>
…to 6271-kind-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.
Thank you, @taysea.
What does this PR do?
Adds
theme.button[kind].icon
,theme.button.hover[kind].icon
,theme.button.active[kind].icon
,theme.button.disabled[kind].icon
to allow theme to include a specific icon in a button kind.Additionally, enhances
theme.button.size
to accept kind specific padding. This allows certain button kinds to take on different padding than other button kinds.Also, in addition to adding relevant tests for this functionality, I fixed a
size
test that was written incorrectly. The snapshot was not showing the desired styling --> this PR updates the test and I have verified the snapshot changes now render the desired styling.Also, adding
string
as an accepted button size -- based on need from upcoming grommet-theme-hpe changes.Where should the reviewer start?
What testing has been done on this PR?
Locally in storybook by adjusted Themed Button TS story:
How should this be manually tested?
In storybook. Can
Do Jest tests follow these best practices?
screen
is used for querying.userEvent
is used in place offireEvent
.asFragment()
is used for snapshot testing.Any background context you want to provide?
What are the relevant issues?
Closes #6271
Screenshots (if appropriate)
Do the grommet docs need to be updated?
Yes.
Should this PR be mentioned in the release notes?
Yes.
Is this change backwards compatible or is it a breaking change?
Backwards compatible.