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

feat: Improve web support with StyleSheet when creating styles #94

Merged
merged 1 commit into from
Nov 1, 2021

Conversation

yuriazevedo11
Copy link
Contributor

@yuriazevedo11 yuriazevedo11 commented Jun 3, 2021

Goals

The idea of this PR is to improve web support using StyleSheet when styles are built.

Basically trying to address this comment.

Implementation:

Use StyleSheet.create inside composeRestyleFunctions.buildStyle().

Tests:


Existing tests passed without any modifications.

I also tested a build on another project:

  • Deps: react-native-web ^0.13.3 and react-native ^0.63.0, works fine on both web and native;

  • Inline styles on the web are gone, now react-native-web is applying CSS classes as expected;

@ghost ghost added the cla-needed label Jun 3, 2021
@yuriazevedo11
Copy link
Contributor Author

I have accepted the CLA :)

@miguelbermudez
Copy link

Hi @yuriazevedo11, I just came across restyle and have a use case with react-native-web. Does this PR address the first point in this comment: #20 (comment), specifically:

Add a way to pass the style prop object through a CSS-in-JS processor (e.g. styled-components or StyleSheet from react-native-web) to get css classes instead of inline styles.

@yuriazevedo11
Copy link
Contributor Author

yuriazevedo11 commented Sep 11, 2021

Hi @miguelbermudez. Yes, I've updated the composeRestyleFunctions.buildStyle() function, now it uses StyleSheet to create the final styles intead of using plain object. With this approach, the inline styles on the web were replaced by classes.

@JoelBesada Can you bring some feedback of this approach?

@nandorojo
Copy link

nandorojo commented Oct 15, 2021

Using StyleSheet.create helps a lot for web performance. This PR looks like a big help. However, I think your prettier spacing is off.

@yuriazevedo11
Copy link
Contributor Author

Yeah, you're right. I'll fix it later today

@yuriazevedo11 yuriazevedo11 reopened this Oct 16, 2021
@idolize
Copy link

idolize commented Oct 25, 2021

@drmas Any idea if this will be merged or not?

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.

5 participants