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(vanilla-extract): remove sprinkles usages from TS files #1257

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

marcoskolodny
Copy link
Collaborator

@marcoskolodny marcoskolodny commented Oct 1, 2024

Issue: Link

Before:

before

After:

image

Copy link

github-actions bot commented Oct 1, 2024

Size stats

master this branch diff
Total JS 12.2 MB 12.1 MB -81.4 kB
JS without icons 2.02 MB 1.94 MB -81.4 kB
Lib overhead 68.3 kB 68.2 kB -32 B
Lib overhead (gzip) 16.6 kB 16.6 kB -3 B

Copy link

github-actions bot commented Oct 1, 2024

Accessibility report
✔️ No issues found

ℹ️ You can run this locally by executing yarn audit-accessibility.

paddingRight: typeof paddingRight === 'object' ? paddingRight.mobile : paddingRight,
};
}
const paddingTopValues =
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I couldn't come up with a way to use sprinkles in Box and Grid components (because I don't know how to replicate the fallback logic with pure CSS).

The only way I was able to make this work is to use CSS vars and style() instead of sprinkles() in the corresponding CSS files.

Copy link

github-actions bot commented Oct 1, 2024

Deploy preview for mistica-web ready!

✅ Preview
https://mistica-dt7vxvn9p-flows-projects-65bb050e.vercel.app

Built with commit 6dd3540.
This pull request is being automatically deployed with vercel-action

@marcoskolodny marcoskolodny marked this pull request as draft October 1, 2024 11:49
Copy link

github-actions bot commented Oct 1, 2024

Screenshot tests report

✔️ All passing

@@ -619,15 +618,15 @@ const Tooltip = ({
return (
<BaseTooltip
content={
<Box className={styles.content}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was working just by luck. The Box component sets padding to 0 by default, and in this case the padding is being applied also through className prop.

When changing the logic in the Box CSS file to use vars instead of sprinkles, the padding from props took precedence over the one passed through className (I guess it depends on how vanilla determines the one that "wins").

In this case, given that we are not using padding props at all, it doesn't actually makes sense to use Box here. I've replaced it with a div to avoid the issue I've mentioned before

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've also detected some use cases in webapp where padding is being applied through className instead of props. These will fail because of the same reason, so we may need to fix them after merging this PR:

  • web/src/pages/cancellation-with-retention-v3/v1/components/list-offers/index.tsx
  • web/src/pages/mv-forms/forms/cancelamento-sva/commons/infos/index.tsx
  • web/src/pages/mv-forms/forms/problemas-cobrancas/commons/infos/index.tsx
  • web/src/pages/mv-forms/forms/suporte-tecnico/commons/infos/index.tsx
  • web/src/pages/mv-forms/forms/suspensao-temporaria/commons/choice/index.tsx
  • web/src/pages/mv-forms/forms/suspensao-temporaria/commons/infos/index.tsx
  • web/src/pages/update-contacts-vivo-code/components/update-contact-parcial/index.tsx

Copy link
Member

Choose a reason for hiding this comment

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

As commented in teams, I'd deprecate the className prop in the Box component. If someone wants a div with styles, then they can use a div.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, deprecated className

@marcoskolodny marcoskolodny marked this pull request as ready for review October 1, 2024 13:11
src/form.tsx Show resolved Hide resolved
Copy link
Member

@pladaria pladaria left a comment

Choose a reason for hiding this comment

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

Is is possible to add an eslint rule to forbid sprinkes imports in .tsx files?

@marcoskolodny
Copy link
Collaborator Author

Is is possible to add an eslint rule to forbid sprinkes imports in .tsx files?

Yes, I've added it here :)

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