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

Migrate Header component to TSX #1020

Merged
merged 11 commits into from
Feb 8, 2021
Merged

Conversation

VanAnderson
Copy link
Contributor

Migrate header component to TSX

Screenshots

No visual changes

image

Merge checklist

  • Added or updated TypeScript definitions (index.d.ts) if necessary
  • 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.

@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2021

🦋 Changeset detected

Latest commit: 3524641

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 Patch

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

@vercel
Copy link

vercel bot commented Feb 5, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/primer-components/k5ehb6r29
✅ Preview: https://primer-components-git-vananderson-migrate-header-to-ts.primer.vercel.app

@VanAnderson VanAnderson force-pushed the VanAnderson/migrate-header-to-TS branch from 1170875 to 2bb6dff Compare February 5, 2021 16:25
@vercel vercel bot temporarily deployed to Preview February 5, 2021 16:25 Inactive
@vercel vercel bot temporarily deployed to Preview February 5, 2021 16:31 Inactive
@vercel vercel bot temporarily deployed to Preview February 5, 2021 16:36 Inactive
@VanAnderson VanAnderson force-pushed the VanAnderson/migrate-header-to-TS branch from e034ddf to e3732f6 Compare February 5, 2021 16:40
@vercel vercel bot temporarily deployed to Preview February 5, 2021 16:40 Inactive
@VanAnderson VanAnderson marked this pull request as ready for review February 5, 2021 16:44
@colebemis
Copy link
Contributor

Awesome 🎉 Can you also update the test file?

@VanAnderson VanAnderson mentioned this pull request Feb 5, 2021
53 tasks
@vercel vercel bot temporarily deployed to Preview February 5, 2021 16:57 Inactive
@vercel vercel bot temporarily deployed to Preview February 5, 2021 17:03 Inactive
@VanAnderson
Copy link
Contributor Author

Awesome 🎉 Can you also update the test file?

Done!

@VanAnderson
Copy link
Contributor Author

Ahh, just realized I think I forgot to do a separate export for the Header props... still getting this workflow down!

@vercel vercel bot temporarily deployed to Preview February 5, 2021 17:22 Inactive
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.

This is great, @VanAnderson 🎉 Just left a few suggestions.

src/Header.tsx Outdated Show resolved Hide resolved
src/Header.tsx Outdated Show resolved Hide resolved
src/Header.tsx Outdated Show resolved Hide resolved
src/Header.tsx Outdated
Comment on lines 10 to 11
type StyledHeaderLinkProps = SystemCommonProps & SxProp & SystemTypographyProps & SystemBorderProps & {to?: boolean}

Copy link
Contributor

Choose a reason for hiding this comment

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

The type of to should be History.LocationDescriptor.

Suggested change
type StyledHeaderLinkProps = SystemCommonProps & SxProp & SystemTypographyProps & SystemBorderProps & {to?: boolean}
type StyledHeaderLinkProps = {to?: History.LocationDescriptor} & SystemCommonProps & SxProp & SystemTypographyProps & SystemBorderProps

You'll need to the History import at the top of the file:

import * as History from 'history'

.changeset/yellow-suits-smell.md Outdated Show resolved Hide resolved
src/Header.tsx Outdated
Comment on lines 47 to 48
const HeaderLink = styled.a.attrs(({to}: StyledHeaderLinkProps) => {
const isReactRouter = typeof to === 'string'
Copy link
Contributor

Choose a reason for hiding this comment

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

When using attrs, we've been passing the props type using the <> notation:

Suggested change
const HeaderLink = styled.a.attrs(({to}: StyledHeaderLinkProps) => {
const isReactRouter = typeof to === 'string'
const HeaderLink = styled.a.attrs<StyledHeaderLinkProps>(({to}) => {
const isReactRouter = typeof to === 'string'

Line 56-57 should look like this:

})<StyledHeaderLinkProps>`
  font-weight: ${get('fontWeights.bold')};

Co-authored-by: Cole Bemis <colebemis@github.com>
@vercel vercel bot temporarily deployed to Preview February 8, 2021 15:25 Inactive
VanAnderson and others added 3 commits February 8, 2021 09:25
Co-authored-by: Cole Bemis <colebemis@github.com>
Make sure changeset is uniform for Header component

Co-authored-by: Cole Bemis <colebemis@github.com>
Co-authored-by: Cole Bemis <colebemis@github.com>
@vercel vercel bot temporarily deployed to Preview February 8, 2021 15:27 Inactive
@vercel vercel bot temporarily deployed to Preview February 8, 2021 15:35 Inactive
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.

👏

@colebemis colebemis merged commit 4069293 into main Feb 8, 2021
@colebemis colebemis deleted the VanAnderson/migrate-header-to-TS branch February 8, 2021 18:16
@github-actions github-actions bot mentioned this pull request Feb 8, 2021
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.

2 participants