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

feat(button): size enum on Button, add deprecationWarning util #229

Merged
merged 4 commits into from
Jun 5, 2020

Conversation

ahobson
Copy link
Contributor

@ahobson ahobson commented Jun 4, 2020

Provide a size enum to eventually replace the small and big boolean props on Button

re #187

@ahobson ahobson added the status: wip Work in progress - not ready for code review label Jun 4, 2020
}
if (size === 'small') {
isSmall = true
}
Copy link
Contributor

@haworku haworku Jun 4, 2020

Choose a reason for hiding this comment

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

I think another way to do this logic is:

const isBig = size === 'big' || (!size && big)
const isSmall = size === 'small' || (!size && small)

Copy link
Contributor

@haworku haworku Jun 4, 2020

Choose a reason for hiding this comment

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

That's assuming we want to ignore the deprecated props if they pass down size. @suzubara I'm blanking on what we decided here... I know we said we would NOT fix if they passed down big small together ...but do we want to guard against size='big' small ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I vote we don't try to fix that; that's why we are moving to enums, right?

Copy link
Contributor Author

@ahobson ahobson Jun 4, 2020

Choose a reason for hiding this comment

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

Also, I very much like your suggestion, but I have a counter suggestion. This is slightly into code golf territory, but how would you feel about

  const isBig = big ? big : size === 'big'
  const isSmall = small ? small : size === 'small'

It changes things to prefer the old big and small in case of both e.g. big and size, but that feels appropriate to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or to prefer size

  const isBig = size ? size === 'big' : big
  const isSmall = size ? size === 'small' : small

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the last option (that prefers the size prop). I don't think we need to deal with guarding against both big small, that is their choice and will be deprecated 🤷‍♀️

Copy link
Contributor

@haworku haworku left a comment

Choose a reason for hiding this comment

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

Let's also update all of Button.stories.tsx to make sure we only show examples with size (and none with deprecated props).

🤔 Is it worth also adding tests for "ignore deprecated big/small props if size exist"? In other words if someone uses size that's what we follow first (even if big/small passed down).

@ahobson
Copy link
Contributor Author

ahobson commented Jun 4, 2020

Let's also update all of Button.stories.tsx to make sure we only show examples with size (and none with deprecated props).

🤔 Is it worth also adding tests for "ignore deprecated big/small props if size exist"? In other words if someone uses size that's what we follow first (even if big/small passed down).

I've added a commit that does both of these

@haworku haworku removed the status: wip Work in progress - not ready for code review label Jun 5, 2020
@haworku haworku changed the title feat(button): size enum on Button component feat(button): size enum on Button, add deprecationWarning Jun 5, 2020
@haworku
Copy link
Contributor

haworku commented Jun 5, 2020

updated PR title (since it generates our changelog) to note that this work also adds deprecationWarning util

@haworku haworku changed the title feat(button): size enum on Button, add deprecationWarning feat(button): size enum on Button, add deprecationWarning util Jun 5, 2020
Andrew Hobson added 4 commits June 5, 2020 12:53
Provide a size enum to eventually replace the small and big boolean props on Button

re #187
* Log deprecation warnings
* Prefer size over big/small; test that interaction
@ahobson ahobson merged commit 3b3f4e7 into develop Jun 5, 2020
@ahobson ahobson deleted the adh-button-enums-187 branch June 5, 2020 17:09
DanielMiller-agile6 pushed a commit to DanielMiller-agile6/react-uswds that referenced this pull request Jun 25, 2020
…works#229)

* feat(button): size enum on Button component

Provide a size enum to eventually replace the small and big boolean props on Button

re trussworks#187

* feat(Button): Add deprecation warnings, size preferred

* Log deprecation warnings
* Prefer size over big/small; test that interaction

* Comment deprecationWarning in production

* Button prop deprecation starts in v1.6.0
@haworku haworku mentioned this pull request Jun 29, 2020
haworku pushed a commit that referenced this pull request Jun 29, 2020
* feat(button): size enum on Button component

Provide a size enum to eventually replace the small and big boolean props on Button

re #187

* feat(Button): Add deprecation warnings, size preferred

* Log deprecation warnings
* Prefer size over big/small; test that interaction

* Comment deprecationWarning in production

* Button prop deprecation starts in v1.6.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: start using enums instead of booleans for prop variants
3 participants