Skip to content

Conversation

@pksjce
Copy link
Contributor

@pksjce pksjce commented Nov 26, 2021

Describe your changes here.

Add two new components

  • IconButton
  • ButtonLink

Change implementation of button to better accomodate sharing of code.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@pksjce pksjce requested review from a team and rezrah November 26, 2021 12:53
@changeset-bot
Copy link

changeset-bot bot commented Nov 26, 2021

⚠️ No Changeset found

Latest commit: ceb847c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2021

size-limit report 📦

Path Size
dist/browser.esm.js 57.26 KB (+0.02% 🔺)
dist/browser.umd.js 57.59 KB (-0.01% 🔽)

@@ -0,0 +1,31 @@
import React, {forwardRef} from 'react'
Copy link
Contributor

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?

Copy link
Contributor Author

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 👍

])
return (
<Base sx={sxStyles} ref={forwardedRef} {...props}>
<span hidden={true}>{iconLabel}</span>
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

default: {
color: 'btn.text',
backgroundColor: 'btn.bg',
boxShadow: `${theme?.shadows.btn.shadow}, ${theme?.shadows.btn.insetShadow}`,
Copy link
Contributor

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?

Copy link
Contributor Author

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"]': {
Copy link
Contributor

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?

Copy link
Contributor Author

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',
Copy link
Contributor

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

Copy link
Contributor Author

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.

})
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" />)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@rezrah rezrah left a 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.

@pksjce pksjce force-pushed the pk/button-enhancements branch from 3f7fb42 to ceb847c Compare December 13, 2021 22:15
@pksjce pksjce merged commit 4005d6a into main Dec 13, 2021
@pksjce pksjce deleted the pk/button-enhancements branch December 13, 2021 22:33
pksjce added a commit that referenced this pull request Dec 20, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

react skip changeset This change does not need a changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants