-
Notifications
You must be signed in to change notification settings - Fork 14
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
Separate out LTR/RTL create and resolve methods #37
Separate out LTR/RTL create and resolve methods #37
Conversation
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.
LGTM! So much cleaner!
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.
Seems reasonable to me! Just asked for a bit of clarification.
src/aphroditeInterfaceFactory.js
Outdated
return StyleSheet.create(styleHash); | ||
}, | ||
|
||
createRTL(styleHash) { | ||
const styleHashRTL = {}; | ||
Object.entries(styleHash).forEach(([styleKey, styleDef]) => { |
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.
to confirm, do we need/have a shim for Object.entries
?
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.
@ljharb would know.
I didn't think so? We were using it before.
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.
We should probably use https://npmjs.com/object.entries; otherwise we have an implicit dependency on people using https://npmjs.com/airbnb-js-shims (which isn't terrible, but isn't ideal).
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.
Sounds good. I can add that.
src/utils/resolveRTL.js
Outdated
|
||
// Styles is an array of properties returned by `create()`, a POJO, or an | ||
// array thereof. POJOs are treated as inline styles. This version of the | ||
// resolve function explicitly does no work to flip styles for an RTL context. |
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.
nit: this comment seems incorrect about RTL
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.
Good call!
} | ||
|
||
if (hasInlineStyles) { | ||
result.style = rtlCSSJS(inlineStyles); |
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.
Could you remind me, why isn't this already captured by the interfaceFactory's call to rtlCSSJS
in the createRTL
function? (sorry i'm not super familiar with how this interface works)
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.
Right so the create
method deals with stylesheets, e.g. styles that you define in the thunk that gets passed to withStyles
. Inline styles can be defined on the fly and are passed in as an object to the css method itself... they are explicitly not part of the stylesheet definition and so don't get handled by the create. That's why we have to do this here as well. :)
(notice that the aphrodite styles are chill tho because the create took care of those)
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.
thanks for explaining! 👍
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.
LGTM pending adding a peer dep on react-with-styles at ^3
and a release of airbnb/react-with-styles#124
dae26e5
to
80c8536
Compare
80c8536
to
d734546
Compare
This is a breaking change. It pairs with airbnb/react-with-styles#124.
This change removes the
with-rtl
aphrodite interface and adds that functionality in the default (but only if you use the CSS/resolve method that will be passed down via props). You will still be able to import a non-directional css method fromreact-with-styles
.to: @ljharb @garrettberg @yzimet @lencioni