kristerkari / react-native-css-modules

Style React Native components using CSS, PostCSS, Sass, Less or Stylus.
MIT License
327 stars 21 forks source link

[Feature] Cascading Styles #40

Open SamuelScheit opened 3 years ago

SamuelScheit commented 3 years ago

I'm currently working on a themeable react native project and wanted to implement cascading styles with child selectors. I saw that you wrote in your FAQ, that cascading childs and complex CSS selectors are not supported:

There is no cascade, CSS properties are not inherited from parent elements. No complex CSS selectors. There is only support for simple CSS class selector that maps 1-to-1 with an element.

and wanted to add this optional feature. I had a look at the internal react properties and theoretically could make child selectors, however can't subscribe for child element updates. Do you have any idea how this feature could theoretically be implemented?

SamuelScheit commented 3 years ago

it would be very easy to support multiple classes className="button primary" if you patch the React.createElement method and add the corresponding style.props for the classNames.

SamuelScheit commented 3 years ago

oh as already mentioned in issue #3 it would also be possible with babel transform

kristerkari commented 3 years ago

It's definitely possible to implement cascading styles, but in my opinion it's much work and little benefit to do so.

React Native already provides a functioning way of applying styles, so I think that it's a good idea to stick with it.