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

Codemod to migrate from inverted prop to InvertedColorScheme component #365

Closed
nlopin opened this issue Aug 29, 2023 · 1 comment · Fixed by #368
Closed

Codemod to migrate from inverted prop to InvertedColorScheme component #365

nlopin opened this issue Aug 29, 2023 · 1 comment · Fixed by #368
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@nlopin
Copy link
Contributor

nlopin commented Aug 29, 2023

The context

With the introduction of the dark theme in Wave (#356), we decided to remove inverted props from the components where they existed:

  • Input
  • Password
  • Textarea
  • Button
  • Select
  • SelectList
  • PhoneInput
  • Datepicker
  • Tooltip
  • Breadcrumbs
  • Logo

The inverted colours were used to assemble the dark theme, which means the dark theme is fully compatible with the previous look and feel.

Problem

We have users of the inverted prop who must migrate their code to the new version. They must delete the inverted prop and wrap the piece of the interface with the FlipTheme component to switch it to the dark mode:

Before

<Box as="form">
  <Input name="hello" inverted />
  <Textarea inverted />
  <Button type="submit" inverted>Submit</Button>
</Box>

After:

<FlipTheme>
  <Box as="form">
    <Input name="hello" />
    <Textarea />
    <Button type="submit">Submit</Button>
  </Box>
</FlipTheme>

Solution

In the ideal case, our code mode can detect components with the inverted prop, find their common parent and wrap it with the FlipTheme component. At the same time, it requires precision and knowledge about the product UI, so I doubt we can provide a good migration experience and not break the UI at the same time by putting the wrapper too high up the component tree.

The solution with the okay-ish migration experience is to work on the component level and wrap each component with the inverted prop with the FilpTheme component. The downside of this approach is the potential decline in performance (the DOM becomes deeper).

We should highlight this issue in the migration guide and recommend refactoring the migrated code to keep as few FlipTheme components as possible

@nlopin nlopin added the enhancement New feature or request label Aug 29, 2023
@nlopin nlopin added this to the Wave@2 milestone Aug 29, 2023
@martimalek
Copy link
Contributor

Should Text also be in the list? I see it has an inverted prop

@martimalek martimalek self-assigned this Aug 29, 2023
@nlopin nlopin linked a pull request Aug 30, 2023 that will close this issue
6 tasks
@martimalek martimalek changed the title Codemod to migrate from inverted prop to FlipTheme component Codemod to migrate from inverted prop to InvertedColorScheme component Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

2 participants