-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[pigment-css][react] RTL Support #41570
Conversation
Netlify deploy previewhttps://deploy-preview-41570--material-ui.netlify.app/ Bundle size report |
Also implements built-in RTL support. See the added test files.
Agree, we should add it as an item for the stable milestone. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests looks good to me 👍
👍 Great to see this coming! For API, I think it can be refined a bit. Here is what I can think of RTL usage start with the simplest need:
{
theme: …,
direction: {
defaultDirection: 'rtl',
},
} the output CSS should switch to RTL
{
theme: …,
direction: {
output: ['ltr', 'rtl'],
defaultDirection: 'rtl',
},
} The output CSS contains
{
theme: …,
direction: {
output: ['ltr', 'rtl'],
defaultDirection: 'rtl',
getDirSelector(dir: string) {
// return your own selector that you'd like to use.
return `:dir(${dir})`;
}
},
}
{
theme: …,
direction: {
output: ['ltr', 'rtl'], // since `defaultDirection` is not specified, there is no default CSS output
},
} The CSS output will be: [dir="ltr"] .hashed { … };
[dir="rtl"] .hashed { … }; |
@siriwatknp One point to note here is that if your app only supports one direction (either css`
margin-left: 10px;
margin-right: 20px;
` and same for rtl would be css`
margin-left: 20px;
margin-right: 10px;
` I don't think there would be a case where you are only supporting Also, if you are only supporting one direction, then there is nothing extra in the plugin configuration that you need to do. |
@brijeshb42 please tag me for a copyediting review when adding documentation. 🙏 I'll open a new PR to iterate on these changes. Edit: @danilo-leal beat me to it 😁 #41576 |
RtlProvider
from@mui/system
Note: There is one optimization that we can pick-up later is to only add properties that actually changed in the output from ltr to rtl, ie, for:
The output should not include the
display
property since it's common in both.