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

Rename and deprecate Breadcrumb to Breadcrumbs #1448

Merged
merged 14 commits into from
Sep 23, 2021

Conversation

SferaDev
Copy link
Contributor

@SferaDev SferaDev commented Sep 21, 2021

Closes #1393

  • Rename Breadcrum to Breadcrums and BreadcrumItem to BreadcrumsItem with their types.
  • Keep and deprecate existing exports
  • Update tests to the new name

Screenshots

Merge checklist

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

Notes

Not sure if we should update the existing codemods to include this rename. Also as an outsider the documentation for the codemods is very limited (aside from the migrating.md file).

@SferaDev SferaDev requested review from a team and colebemis September 21, 2021 18:51
@changeset-bot
Copy link

changeset-bot bot commented Sep 21, 2021

🦋 Changeset detected

Latest commit: a5c775a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/components Major

Not sure what this means? Click here to learn what changesets are.

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

@colebemis colebemis changed the title Rename and deprecate Breadcrum to Breadcrums Rename and deprecate Breadcrumb to Breadcrumbs Sep 21, 2021
* @deprecated Use the Breadcrumbs component instead (i.e. <Breadcrumb> → <Breadcrumbs>)
*/
export const Breadcrumb = Object.assign(Breadcrumbs, {Item: BreadcrumbsItem})
export type BreadcrumbProps = ComponentProps<typeof BreadcrumbsBase>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add deprecation warnings for these types as well?

Copy link
Contributor Author

@SferaDev SferaDev Sep 21, 2021

Choose a reason for hiding this comment

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

Sure thing! I followed the same approach as when Position subcomponents where deprecated (component had deprecation warning but not the props types). In any case makes sense to see the message in the IDE if you're importing the outdated types.

function Breadcrumb({className, children, theme, ...rest}: React.PropsWithChildren<BreadcrumbProps>) {
const classes = classnames(className, 'Breadcrumb')
function Breadcrumbs({className, children, theme, ...rest}: React.PropsWithChildren<BreadcrumbsProps>) {
const classes = classnames(className, 'Breadcrumbs')
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why we need to add this classname 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Git blame tells it has been there since the very beginning, don't think it's used for anything though.

Copy link
Contributor

Choose a reason for hiding this comment

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

If there are no references it anywhere else in the codebase, let's go ahead and remove it

Copy link
Contributor Author

@SferaDev SferaDev Sep 21, 2021

Choose a reason for hiding this comment

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

There's a specific test case that validates a Breadcrum class exists, so it was done on purpose for what it seems. There're other primer react components with readable classes injected to them. But I don't think it's a convention as most components do not add them.

Either the removal or rename to Breadcrums will be breaking if someone relies on the class name for their tests (although it's not a good practice).

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go ahead and remove it (and the test case) and add a changeset to indicate that it's a breaking change

Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

Looks good 👍 Thank you, @SferaDev!

@colebemis colebemis enabled auto-merge (squash) September 21, 2021 21:36
src/Breadcrumbs.tsx Outdated Show resolved Hide resolved
src/Breadcrumbs.tsx Outdated Show resolved Hide resolved
src/Breadcrumbs.tsx Outdated Show resolved Hide resolved
@colebemis colebemis enabled auto-merge (squash) September 23, 2021 00:29
@colebemis colebemis merged commit 1a39fb0 into primer:main Sep 23, 2021
@primer-css primer-css mentioned this pull request Sep 23, 2021
@SferaDev SferaDev deleted the rename-breadcrum branch September 23, 2021 00:44
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.

Rename Breadcrumb to Breadcrumbs
2 participants