Skip to content

Export :global classes? #351

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

Closed
sprat opened this issue Oct 2, 2016 · 3 comments
Closed

Export :global classes? #351

sprat opened this issue Oct 2, 2016 · 3 comments

Comments

@sprat
Copy link

sprat commented Oct 2, 2016

I've noticed that :global classes are not exported when we require the CSS file. Is there a way/an option to allow global exports?

Thanks

@faceyspacey
Copy link

faceyspacey commented Dec 11, 2016

agreed. i'm not sure why i can't access them on styles.someGlobalClass just like local ones. Without this, the result is using multiple paradigms to access classes in your React components:

<div className={`${styles.someClass} some-global`} />

While that's not horrible, what is though is if you're using React Native Web and you expect all your styles on an importable styles object because you can't provide a className prop. If globals were properly assigned to the exported styles object you could simply use different styles between a React Native project and a React Native Web Project, while keeping the components the same.

That said, you also have to do the following thing I do so you have a View component that shares the same interface on both web and native:

<View style={[styles.someClass, styles.someGlobal]} />

I.e. you don't use the standard RNW View component (which I've found to be sub-par because it inlines all css and restricts you just to the native css features supported by native). Instead, you roll your own that accepts class strings (possibly within an array) and if it's a string moves it to the className prop or if it's an object treats it as an inline style.

TL;DR: it doesn't seem like it would hurt any backwards compatibility to just export globals as well. If apps aren't using them, nothing changes for them. It's just unused keys on the styles object. For people that were hoping to use them, it's a blessing and basically expected.

@alexander-akait
Copy link
Member

Feel free to PR

@alexander-akait
Copy link
Member

alexander-akait commented Nov 27, 2018

let's move this in one issue #258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants