-
Notifications
You must be signed in to change notification settings - Fork 645
Button: enhancements with ButtonLink and IconButton #1659
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
|
size-limit report 📦
|
| @@ -0,0 +1,31 @@ | |||
| import React, {forwardRef} from 'react' | |||
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.
Should this - and the other files that export default React components - be renamed in PascalCase? Or is this intentional?
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.
Ah I see! Will change up the file names in a followup PR 👍
src/NewButton/icon-button.tsx
Outdated
| ]) | ||
| return ( | ||
| <Base sx={sxStyles} ref={forwardedRef} {...props}> | ||
| <span hidden={true}>{iconLabel}</span> |
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.
Is hidden needed anymore? If so, should it be aria-hidden instead?
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.
Since its an icon only component, the idea was to have a visibly hidden icon label but the screenreaders will be able to access it.
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.
Okay, I believe the hidden html5 attribute will also hide it from screenreaders too though, because it prevents the semantics from getting surfaced to the accessibility api . I think you'll either need to just visually hide it with styles, or explicitly add aria-hidden="false", but the latter seems counter-productive.
19aca23 to
14ad568
Compare
e703003 to
bbc4eac
Compare
00c4034 to
d4244f6
Compare
| default: { | ||
| color: 'btn.text', | ||
| backgroundColor: 'btn.bg', | ||
| boxShadow: `${theme?.shadows.btn.shadow}, ${theme?.shadows.btn.insetShadow}`, |
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.
is theme assumed to always be defined inside the fn? If so, do we need the optional chaining? If not, should we provide a fallback?
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.
Honestly I only used it to make typescript happy. This seems common usage across our codebase.
| color: 'btn.primary.disabledText', | ||
| backgroundColor: 'btn.primary.disabledBg' | ||
| }, | ||
| '[data-component="ButtonCounter"]': { |
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.
Minor observation: I can't see it in the test file, but given we're applying design logic against DOM node attributes, shall we add some extra tests against the data-* attributes to ensure that these styles are picked up?
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, some counter tests are much needed.
|
|
||
| '&:hover': { | ||
| color: 'btn.outline.hoverText', | ||
| backgroundColor: 'btn.outline.hoverBg', |
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.
Potentially unrelated to this PR, but should this hover style be disabled?
Screen.Recording.2021-12-10.at.10.59.41.mov
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.
Thanks a ton for this catch! Fixed now.
src/__tests__/NewButton.test.tsx
Outdated
| }) | ||
| it('styles icon only button to make it a square', () => { | ||
| const IconOnlyButton = render(<Button icon={SearchIcon}>Search icon only button</Button>) | ||
| const IconOnlyButton = render(<IconButton icon={SearchIcon} iconLabel="Search icon only button" />) |
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.
One for another time, but wanted to put it on your radar. Can we move away from Enzyme to use the render from testing library instead? It's already imported here as HTMLRender. On the disabled test for example, we can instead look for disabled html attributes instead of testing the implementation props. What do you think?
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.
Good idea! Its much nicer to use testing library. Rewrote the tests in that.
rezrah
left 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.
Looks great @pksjce. I've left additional questions/recommendations but would be happy for them to be resolved later if you want to move ahead with this.
32a6b3b to
d1347f5
Compare
d258935 to
185ba3b
Compare
185ba3b to
3f7fb42
Compare
3f7fb42 to
ceb847c
Compare
* Create icon only button * Add ButtonLink and IconButton components * Lint and test * Remove react router for now. Maybe add an example later * Fix the typescript error on as prop * Fix lint issue * Fix 1. Bug with disabled 2. Tests in testing lib * lint issues
Describe your changes here.
Add two new components
Change implementation of button to better accomodate sharing of code.
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.