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: migrate Modal to TailwindCSS #3800

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

refactor: migrate Modal to TailwindCSS #3800

wants to merge 12 commits into from

Conversation

TomasSlama
Copy link
Contributor

@TomasSlama TomasSlama commented Aug 11, 2023

FX-4034

Description

This PR is the POC of migrating a complex component from MUI4 to TailwindCSS. We chose Modal.

This PR involves:

  • Install TailwindCSS and make it work in the Storybook
  • Apply BASE tokens to the TailwindCSS config
  • Migrate the Modal component

How to test

  • Temploy
  • FIXME: Add the steps describing how to verify your changes

Screenshots

Before. After.
Insert screenshots or screen recordings Insert screenshots or screen recordings

Development checks

Breaking change

  • codemod is created and showcased in the changeset
  • 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.

@TomasSlama TomasSlama self-assigned this Aug 11, 2023
@changeset-bot
Copy link

changeset-bot bot commented Aug 11, 2023

⚠️ No Changeset found

Latest commit: e23089f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@@ -63,6 +63,7 @@
"@changesets/get-github-info": "^0.5.1",
"@cypress/skip-test": "^2.6.1",
"@storybook/addon-a11y": "^6.5.15",
"@storybook/addon-styling": "0.3",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need to stick to the 0.x version till we update to storybook 7

@@ -216,43 +210,50 @@ export const Modal = forwardRef<HTMLElement, Props>(function Modal(props, ref) {
[disableBackdropClick, onBackdropClick, onClose]
)

useBodyScrollLock(open)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

even though Modal from mui is supporting body lock by default, it does not work when we change the container from the body to the Picasso root. It appears to be working even if we change it back to body, but I didn't want to break anything unexpectedly, so keeping the same behavior as on master

@@ -216,43 +210,50 @@ export const Modal = forwardRef<HTMLElement, Props>(function Modal(props, ref) {
[disableBackdropClick, onBackdropClick, onClose]
)

useBodyScrollLock(open)

const duration = transitionProps?.timeout || transitionDuration
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 double checked in MUI implementation that transitionProps are overriding transitionDuration

/>
<div
data-test="sentinelStart"
data-testid="sentinelStart"
tabindex="0"
/>
<div
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 decided to remove MuiDialog-container as it is not necessary and default closeOnBackdropClick works. If in the adopting phase, we realize that users are relying on the DOM structure, we can easily return the div back, but we will have to introduce a logic, that will close the modal if we click on this container, but not on the paper component

} catch (err) {
setError(true)
setLoading(false)
export const PromptModal = forwardRef<HTMLDivElement, Props>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only change is

- HTMLElement
+ HTMLDivElement

And the removal of the styles, as they were empty anyway

@toptal-devbot toptal-devbot temporarily deployed to staging August 11, 2023 17:43 Inactive
@toptal toptal deleted a comment from toptal-devbot Sep 14, 2023
@toptal toptal deleted a comment from toptal-devbot Sep 14, 2023
@toptal toptal deleted a comment from toptal-devbot Sep 14, 2023
@TomasSlama
Copy link
Contributor Author

@toptal-bot run package:alpha-release

@toptal-devbot
Copy link
Collaborator

Your alpha package is ready 🎉
yarn add @topkit/analytics-charts@49.0.1-alpha-fx-4034-6b0ba2a89.28+6b0ba2a89
yarn add @toptal/picasso@38.2.1-alpha-fx-4034-6b0ba2a89.9+6b0ba2a89
yarn add @toptal/picasso-charts@52.0.1-alpha-fx-4034-6b0ba2a89.28+6b0ba2a89
yarn add @toptal/picasso-codemod@5.5.3-alpha-fx-4034-6b0ba2a89.135+6b0ba2a89
yarn add @toptal/picasso-forms@61.1.3-alpha-fx-4034-6b0ba2a89.7+6b0ba2a89
yarn add @toptal/picasso-pictograms@1.1.2-alpha-fx-4034-6b0ba2a89.210+6b0ba2a89
yarn add @toptal/picasso-provider@3.2.1-alpha-fx-4034-6b0ba2a89.28+6b0ba2a89
yarn add @toptal/picasso-rich-text-editor@6.0.3-alpha-fx-4034-6b0ba2a89.23+6b0ba2a89
yarn add @toptal/picasso-shared@12.0.1-alpha-fx-4034-6b0ba2a89.255+6b0ba2a89

@dmaklygin
Copy link
Contributor

@toptal-bot run package:alpha-release

@toptal-devbot
Copy link
Collaborator

Your alpha package is ready 🎉
yarn add @topkit/analytics-charts@52.0.1-alpha-fx-4034-e23089f0e.58+e23089f0e
yarn add @toptal/picasso@41.1.1-alpha-fx-4034-e23089f0e.11+e23089f0e
yarn add @toptal/picasso-charts@55.1.1-alpha-fx-4034-e23089f0e.20+e23089f0e
yarn add @toptal/picasso-codemod@5.6.3-alpha-fx-4034-e23089f0e.61+e23089f0e
yarn add @toptal/picasso-forms@65.0.2-alpha-fx-4034-e23089f0e.29+e23089f0e
yarn add @toptal/picasso-pictograms@2.0.1-alpha-fx-4034-e23089f0e.79+e23089f0e
yarn add @toptal/picasso-provider@3.4.2-alpha-fx-4034-e23089f0e.70+e23089f0e
yarn add @toptal/picasso-query-builder@1.1.2-alpha-fx-4034-e23089f0e.22+e23089f0e
yarn add @toptal/picasso-rich-text-editor@9.0.2-alpha-fx-4034-e23089f0e.29+e23089f0e
yarn add @toptal/picasso-shared@13.0.1-alpha-fx-4034-e23089f0e.79+e23089f0e

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