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

Separate out LTR/RTL create and resolve methods #37

Merged
merged 1 commit into from
Feb 6, 2018

Conversation

majapw
Copy link
Collaborator

@majapw majapw commented Feb 6, 2018

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 from react-with-styles.

to: @ljharb @garrettberg @yzimet @lencioni

Copy link

@garrettberg garrettberg left a 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!

Copy link
Contributor

@yzimet yzimet left a 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.

return StyleSheet.create(styleHash);
},

createRTL(styleHash) {
const styleHashRTL = {};
Object.entries(styleHash).forEach(([styleKey, styleDef]) => {
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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).

Copy link
Collaborator Author

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.


// 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.
Copy link
Contributor

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

Copy link
Collaborator Author

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);
Copy link
Contributor

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)

Copy link
Collaborator Author

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)

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for explaining! 👍

Copy link
Collaborator

@ljharb ljharb left a 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

@majapw majapw force-pushed the maja-add-separate-resolve-methods-for-rtl-and-ltr branch 3 times, most recently from dae26e5 to 80c8536 Compare February 6, 2018 21:31
@majapw majapw force-pushed the maja-add-separate-resolve-methods-for-rtl-and-ltr branch from 80c8536 to d734546 Compare February 6, 2018 21:32
@majapw majapw merged commit 44257f7 into master Feb 6, 2018
@majapw majapw deleted the maja-add-separate-resolve-methods-for-rtl-and-ltr branch February 6, 2018 21:35
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.

4 participants