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

[FX-4620] Migrate Switch component #4302

Merged
merged 7 commits into from
May 14, 2024

Conversation

dmaklygin
Copy link
Contributor

@dmaklygin dmaklygin commented May 13, 2024

FX-4620

Description

Migrate Switch component to Mui/base Switch and TailwindCSS.

How to test

Video recording

This is a comparison between Temploy and production:

Screen.Recording.2024-05-14.at.10.35.37.mov

Accessibility issues.

No new accessibility issues. Current issues are related to disabled uncontrolled Switch. The same as on production.

Screenshot 2024-05-14 at 10 41 54

Development checks

Breaking change

  • N/A codemod is created and showcased in the changeset
  • N/A test alpha package of Picasso in StaffPortal

All development checks should be done and set checked to pass the
GitHub Bot: TODOLess action

PR commands

List of available commands:

  • @toptal-bot run package:alpha-release - Release alpha version
  • @toptal-anvil ping reviewers - Ping FX team for review
PR Review Guidelines

When to approve? ✅

You are OK with merging this PR and

  1. You have no extra requests.
  2. You have optional requests.
    1. Add nit: to your comment. (ex. nit: I'd rename this variable from makeCircle to getCircle)

When to request changes? ❌

You are not OK with merging this PR because

  1. Something is broken after the changes.
  2. Acceptance criteria is not reached.
  3. Code is dirty.

When to comment (neither ✅ nor ❌)

You want your comments to be addressed before merging this PR in cases like:

  1. There are leftovers like unnecessary logs, comments, etc.
  2. You have an opinionated comment regarding the code that requires a discussion.
  3. You have questions.

How to handle the comments?

  1. An owner of a comment is the only one who can resolve it.
  2. An owner of a comment must resolve it when it's addressed.
  3. A PR owner must reply with ✅ when a comment is addressed.

@dmaklygin dmaklygin self-assigned this May 13, 2024
@dmaklygin dmaklygin requested a review from a team as a code owner May 13, 2024 16:53
Copy link

changeset-bot bot commented May 13, 2024

🦋 Changeset detected

Latest commit: c15232e

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

This PR includes changesets to release 4 packages
Name Type
@toptal/picasso-tailwind Minor
@toptal/picasso Major
@toptal/picasso-switch Major
@toptal/picasso-forms 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

@dmaklygin dmaklygin changed the base branch from feat/tailwind-1 to feature/tailwind-w20 May 13, 2024 17:03
@dmaklygin
Copy link
Contributor Author

@toptal-anvil ping reviewers

Copy link
Contributor

@TomasSlama TomasSlama 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, I think we should also increase peerDependency of @toptal/picasso-tailwind on @toptal/picasso package.json as if somebody will be using import { Switch } from '@toptal/picasso' it will not work without new version

@TomasSlama TomasSlama requested a review from a team May 14, 2024 08:10
@TomasSlama TomasSlama requested a review from a team May 14, 2024 12:19
@@ -60,9 +58,38 @@ export const Switch = forwardRef<HTMLButtonElement, Props>(function Switch(
style={style}
disabled={disabled}
id={id}
onChange={onChange}
value={value}
onChange={onChangeCallback}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this change is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I said, MUI/Base Switch doesn't expect value, and expecting value in the Picasso's Swich is also odd.
It should keep only state, nothing more.
value was added unintentionally to support consistency in Field elements, so, better to remove it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am asking about onChange={onChange} why we had to change it

@@ -118,6 +118,7 @@ module.exports = {
white: '#FFFFFF',
black: '#000000',
transparent: 'transparent',
current: 'currentColor',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please explain this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this approach was migrated from the previous implementation:
we applied it to Switch: text-white bg-current: it means, we say that background-color will be the same as the text color -> white.

The default TailwindCSS configuration contains such property:

https://github.com/tailwindlabs/tailwindcss/blob/next/packages/tailwindcss/src/utils/is-color.ts#L174

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, that is what was confusing to me. Default config of tailwind has this bg-current. Why did we have to add our own?

Copy link
Collaborator

@OleksandrNechai OleksandrNechai left a comment

Choose a reason for hiding this comment

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

IMO good to go. I have only questions, ping me please when answered. Thanks! 👍

@dmaklygin
Copy link
Contributor Author

The previous version has a bug due to hidden input:
Screenshot 2024-05-14 at 17 35 11

This was a reason why happo tests were fallen

@dmaklygin dmaklygin merged commit 6018e47 into feature/tailwind-w20 May 14, 2024
14 checks passed
@dmaklygin dmaklygin deleted the fx-4620-migrate-switch branch May 14, 2024 14:53
mkrl pushed a commit that referenced this pull request May 21, 2024
* Migrate Switch component

* Update changeset

* Update changeset

* Update changeset

* Update picasso

* Change changeset

* Remove old dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants