-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Full RTL support #1674
Full RTL support #1674
Conversation
Travis build failed because of a network issue or something apparently. |
@louy maybe try pushing an empty commit to re-start the Travis build? |
@shaurya947 I believe admins can restart a build manually. It would be much cleaner than an empty commit. |
@shaurya947 can I get any feedback on this? |
@@ -83,6 +83,14 @@ const MenuItem = React.createClass({ | |||
}, | |||
|
|||
getStyles() { | |||
const isRtl = this.context.muiTheme.isRtl; |
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.
I think that is should be this.state.muiTheme.isRtl
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.
Fixed. This was written before state.muiTheme
was introduced. I've just seen that feature.
@oliviertassinari do you think adding another function to StylePropable that flips the direction automatically for all components might be a better approach? |
Well, If you want to add the support of RTL on a large set of component, yes I would use a different approach. |
Sorry @louy, I've been a little MIA on this issue. I don't think using the mixin is the best option. But I agree with @oliviertassinari that having something on the theme-level is a good approach. Take a look at |
For instance, when we contruct the theme we can compute a LTR variable that we add to the theme. if (isRtl) {
LTR = {
right: 'left',
left: 'right',
marginRight: 'marginLeft',
paddingLeft: 'paddingRight',
}
} else {
LTR = {
right: 'right',
left: 'left',
marginRight: 'marginRight',
paddingLeft: 'paddingLeft',
}
} |
👍 |
Hi, To see it in action, just uncomment the line in docs/src/components/master.jsx. A few things to be careful about:
|
WOW, I love it 👍 👍 ❤️ ❤️ |
I also wasn't able to add rtl support to all docs pages because they're written in es6 class style and I need to use mixins. That shouldn’t be a big issue. |
}, style); | ||
} | ||
|
||
if (!muiTheme.isRtl) return style; // Performance hack! |
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.
Performance hack!
I would rather say Left to right is the default
.
What do you think?
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.
Left to right is the default
doesn't imply that this line of code is there for optimization. Maybe:
Skip further processing to improve performance, since ltr is the default.
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.
My point is that this line isn't for optimisation. It's there because the default style is for LTR. Hence, we shouldn't invert the style properties if isRtl
is false.
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.
Done!
I like this approach. I'm wondering if this can work with flexbox. |
Awesome! It's working fine with |
@shaurya947 can we get this merged soon? |
@@ -18,4 +18,5 @@ module.exports = { | |||
borderColor: ColorManipulator.fade(Colors.fullWhite, 0.3), | |||
disabledColor: ColorManipulator.fade(Colors.fullWhite, 0.3), | |||
}, | |||
isRtl: false, |
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.
I feel like this shouldn't be part of the rawTheme
, semantically speaking.
@louy see the comments above and let me know what you think. Also, there's a lot of changes here. Can you make sure that nothing breaks when Good job consolidating all this btw 👍 |
Hi @shaurya947, Just did some cleanup and the a quick look through the whole docs to make nothing is broken. Everything looks fine. Thanks :) |
I'll go ahead and merge this then, and we can tackle any issues that come along the way. Thanks @louy |
return newStyle; | ||
}, | ||
|
||
prepareStyles(muiTheme, ...styles) { |
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.
muiTheme
is not passed as parameter when used.
I had to revert this commit in this PR #1882.
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.
(for reference) This is not a bug.
See src/mixins/style-propable.js#L35-L37
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.
Oh sorry, I overlooked this.
@andreychev Can you submit a PR to fix this ? |
Closes #1661.