-
Notifications
You must be signed in to change notification settings - Fork 65
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
Compatibility with React Native Web + NextJS #183
Comments
Thanks for the detailed issue @redbar0n. Happy to give a PR for this feature a good look and guide it to completion, but unfortunately we don't have the resources to work on any big new Fresnel additions right now. |
I understand. I don't have time to work on this myself now either, but maybe some time in the future. Btw, with respects to the API, then a |
Meanwhile, is there a way to add CSS to a Media via |
Ok I see How in the documentation, you have to output your own component instead of passing it as child to avoid the media generated div.
|
Closing. Will reopen if activity resumes here. |
Is there a possibility to make this work with react-native-web? Any progress on this? |
necolas/react-native-web#1688 (comment)
1: The wrapping DOM element
RNW has deprecated all uses of the
className
prop (since RNW'sstyle
will overwrite it). But Fresnel uses theclassName
prop (Media.tsx). RNW also requiresdata-*
attributes to be explicitly set with thedataSet
prop. So what I think is needed is an option to config Fresnel to work with RNW. Enabling that config could make the<Media>
components output a wrapping:Instead of:
So that on web RNW would output the final:
Which Fresnel could target using a CSS attribute selector like this:
To hide components for non-applicable breakpoints on the first render client-side.
Actually, I see that you can use the render props form, which can output a custom component other than a
<div>
.That's good. The only problem is that on web, Fresnel CSS will target the
class
attribute. But RNW doesn't allow setting this directly, as mentioned initially. So if Fresnel's CSS could targetdata-*
attributes, like<div data-fresnel-container="true" data-breakpoint="sm">
, with a CSS attribute selector, like mentioned above, it would be compatible with RNW.Is that possible? Maybe as a config option?
2: Inline responsive styles
I think speaks to the last con with using Fresnel that you mentioned in your Readme:
This makes it harder to style components conditionally.
You asked:
And gave an example:
Maybe this is a stupid question, but for cases like that example, couldn't you simply do this?
Anyway, I think that
is actually really nice to have as an optional API. Because it allows very fine-grained targeting of styles, without worrying about larger markup differences. Maybe you have only one component tree / markup, but want to simply tweak some styles for various resolutions (classic responsivity).
So what about this?
When rendering server-side, put the current breakpoints in a DOM node outside of the React tree, using a vanilla JS DOM selector. So that it is accessible on the client, and doesn't interfere with React's hydration (which has to match server-side). Then provide a hook
clientWindowMatchesBreakpoint()
that only on the client will access the breakpoints from that DOM node, and run something like this:Then when styling components conditionally developers could do:
Maybe?
The text was updated successfully, but these errors were encountered: