Skip to content

feat(styles): convert styles to CSS logical properties, enhance RTL support#14580

Merged
tw15egan merged 7 commits into
mainfrom
logical-properties
Sep 11, 2023
Merged

feat(styles): convert styles to CSS logical properties, enhance RTL support#14580
tw15egan merged 7 commits into
mainfrom
logical-properties

Conversation

@tw15egan

@tw15egan tw15egan commented Sep 5, 2023

Copy link
Copy Markdown
Contributor

Closes #13619

Converts all applicable layout properties to CSS Logical Properties . This will greatly enhance RTL support throughout the design system.

Changelog

New

  • stylelint-use-logical added to stylelint-config-carbon

Changed

  • Replaced all physical layout properties with logical properties.

Testing / Reviewing

Ensure there are no regressions in LTR (default) mode. Use the Layout switcher to test each component in RTL mode and ensure it renders as expected

@netlify

netlify Bot commented Sep 5, 2023

Copy link
Copy Markdown

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit 6ec1cda
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/64f7609aa2d8c8000898821b
😎 Deploy Preview https://deploy-preview-14580--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify

netlify Bot commented Sep 5, 2023

Copy link
Copy Markdown

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 6ec1cda
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/64f7609a49790600082091c7
😎 Deploy Preview https://deploy-preview-14580--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify

netlify Bot commented Sep 5, 2023

Copy link
Copy Markdown

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit 0378dc4
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/64ff339de9708800083764f4
😎 Deploy Preview https://deploy-preview-14580--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify

netlify Bot commented Sep 5, 2023

Copy link
Copy Markdown

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 9d78e2f
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/64f7610d02c80900083f3a9d
😎 Deploy Preview https://deploy-preview-14580--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify

netlify Bot commented Sep 5, 2023

Copy link
Copy Markdown

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 0378dc4
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/64ff339de14aa500085dff6d
😎 Deploy Preview https://deploy-preview-14580--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@tw15egan

tw15egan commented Sep 6, 2023

Copy link
Copy Markdown
Contributor Author

Seems like the only LTR Percy change is due to the addition of padding on TableHeaderContainer on the right side, which is needed so that when RTL mode is enabled, the text is not flush against the container. Everything else seems untouched 👍🏻

@alisonjoseph alisonjoseph left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This all looks good to me! 💪

@guidari guidari left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @tw15egan

I went throught all the components to see if I could spot something that might be missing, not sure if all the points I made are valids, but maybe it's worth taking a look!
I'm happy to help on these if needed!

Btw, awesome change in the storybook with the RTL mode!! 🚀🔥


- Checkbox - Skeleton example
When using the margin in this format: margin: 1px 1px 1px 1px the values don’t get translate to “RTL”. Maybe we won't be able to use this method to write margin, padding, etc...

Screenshot 2023-09-08 at 14 21 10
Screenshot 2023-09-08 at 14 21 42

- CodeSnippet - Multiline, Singleline
Horizontal scrollbar getting a blur in the left and right side

- Pagination
Those arrow should change directions? I search a little bit and found these examples: 

https://github.com/mui/mui-x/issues/8665

https://bootstrap.rtlcss.com/docs/4.0/components/pagination/#working-with-icons
From my understanding it shouldn’t, or am I wrong? Take PaginationNav as an example maybe. There the arrows kept the directions

- ProgressBar
The ProgressBar should switch the side where it starts or kept the same side (left)

- Slider
Seems like the Slider is getting the wrong value, maybe a logic would have to be written to switch the max and min values when in RTL mode (idk if we can track that in JS).

@tay1orjones tay1orjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looks great to me. I agree with Gui's comments above, though I think we could address those in separate PRs if you'd like. The diff on this one is pretty meaty as-is 😅

Comment on lines +318 to +319
// Need to set random key to recalculate Popover coordinates
setRandomKey(Math.floor(Math.random() * 10));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh wow great call, I hadn't thought about the need to re-render in some instances like this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks to your suggestions as a way to rerender components I thought of trying it, and it worked perfectly!

Comment on lines +93 to +94
menu.current.style.insetInlineStart = `initial`;
menu.current.style.insetInlineEnd = `${pos[0]}px`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm so glad these work with CSSOM like this 🙌

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was super happy this worked, since this seemed to resolve most of the RTL issues with Menu. I had only been looking at the stylesheets!

…rt (#14531)

* refactor(styles): update styles to use CSS logical properties

* fix(styles): change padding-inline-end to padding-inline

* fix(styles): run stylelint --fix on components

* fix(styles): run stylelint --fix on utilities

* fix(Select): test padding fix

* chore(stylelint): run styelint on files outside @carbon/styles

* fix(AspectRatio): remove unsupported float: inline-start

* fix(ContainedList): redefine tag tokens in contained list

* fix(ContainedList): keep story the same
* fix(components): fix RTL issues with components

* style(components): more fixes for RTL styles

* style(components): more fixes for RTL styles

* fix(Popover): fix popover styles in RTL mode

* fix(TreeView): fix RTL issues with TreeView

* fix(Breadcrumb): fix small issue with overflow menu variant

* fix(Popover): fix autoalign story issues
* fix(menuButton): fix RTL issues with MenuButton

* fix(Menu): adjust caret rotation

* refactor(menu): remove rtl override

* fix(Menu): adjust story positioning, add CaretLeft for RTL mode

* refactor(Menu): useLayoutContext to check if parent has direction set
@tw15egan tw15egan added this pull request to the merge queue Sep 11, 2023
Merged via the queue into main with commit abff3a5 Sep 11, 2023
@tw15egan tw15egan deleted the logical-properties branch September 11, 2023 17:10
@m4olivei m4olivei mentioned this pull request Sep 20, 2023
22 tasks
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.

Use CSS Logical Properties and Values for Styling

4 participants