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

refactor: use transient props in various styled components #5093

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

robinpyon
Copy link
Contributor

Description

This PR migrates a number of styled components to now use transient props, and remove a number of warnings that were shown in localhost as a result of upgrading to styled-components to 6.x.

A fully exhaustive audit wasn't conducted, but this should address most of the more common / egregious examples.

What to review

Touched components should be unaffected in function or style. We should no longer see a glut of transient prop related warnings in localhost.

Notes for release

N/A

@vercel
Copy link

vercel bot commented Oct 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Oct 30, 2023 6:08pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2023 6:08pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Oct 30, 2023 6:08pm

Comment on lines -9 to -10
focus: boolean
hover: boolean
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were removed as the styled component wasn't doing anything with these values

Comment on lines -38 to -39
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similarly, this internal state has been removed as ChangeBarWrapper isn't varying on the value of hover

Comment on lines +34 to +36
// We exclude `documentId` from spread props to avoid passing it to the Card component
// eslint-disable-next-line @typescript-eslint/no-unused-vars
documentId,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would love to know if there's a more elegant way to do this!

Copy link
Member

Choose a reason for hiding this comment

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

I think you should be able to assingn it to _ and have eslint ignore it, e.g. documentId: _

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 considered this! Though I believe we need to amend our eslint config slightly to accommodate, e.g.

'@typescript-eslint/no-unused-vars': [
  'warn',
  {
    varsIgnorePattern: '^_',
  },
],

Happy to add if you feel appropriate! Otherwise we can just leave as-is

Copy link
Member

Choose a reason for hiding this comment

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

Since const {foo: _, bar: _, ...rest} = … will yell at you for redeclaring consts, will that rule allow omitting more than one property? Maybe we could configure it to be _ignore_${propertyName} (or maybe that's too much?).

There's also no-unused-vars#ignorerestsiblings, which is more specific to this particular case.

content={content}
// data-placement={restProps.placement}
portal
allowedAutoPlacements={['top', 'bottom']}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed as it's now deprecated in Sanity UI, and including it would yield similar transient prop warnings

@robinpyon robinpyon requested a review from a team October 30, 2023 18:10
@github-actions
Copy link
Contributor

No changes to documentation

@robinpyon robinpyon marked this pull request as ready for review October 30, 2023 18:12
@robinpyon robinpyon requested review from a team and removed request for bjoerge and RitaDias October 30, 2023 18:12
@github-actions
Copy link
Contributor

Component Testing Report Updated Oct 30, 2023 6:16 PM (UTC)

File Status Duration Passed Skipped Failed
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 11s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 11s 3 0 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 10s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 29s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 14s 9 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 54s 18 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 11s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 6s 3 0 0

Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

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

Great - thanks a lot @robinpyon! 🙇🏼

Comment on lines +34 to +36
// We exclude `documentId` from spread props to avoid passing it to the Card component
// eslint-disable-next-line @typescript-eslint/no-unused-vars
documentId,
Copy link
Member

Choose a reason for hiding this comment

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

I think you should be able to assingn it to _ and have eslint ignore it, e.g. documentId: _

Copy link
Contributor

@pedrobonamin pedrobonamin 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 to me. Thanks!

@robinpyon robinpyon added this pull request to the merge queue Oct 31, 2023
Merged via the queue into next with commit ae0ca14 Oct 31, 2023
31 checks passed
@robinpyon robinpyon deleted the refactor/use-transient-props branch October 31, 2023 15:58
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.

3 participants