Inline Styles, optional setElement calls, - #58
Conversation
|
I know you guys have all been busy with React Router and other such things, so I went ahead and released this as a new package for now. I'm totally down with deprecating it and merging the changes in here when everything calms down. We just were starting to have too many places that depend on this particular fork so I wanted to get it up as a properly versioned package. |
|
@jackofseattle looks good. Would you mind making a couple small changes?
Thanks for the PR! |
|
@mzabriskie Sure thing, |
|
@jackofseattle it is used for accessibility. When the modal opens |
[changed] injectCSS has been changed to a warning message in preperation for a future removal. lib/components/Modal.js [changed] setAppElement method is now optional. Defaults to document.body and now allows for a css selector to be passed in rather than the whole element.
3a2274d to
4d25989
Compare
|
@mzabriskie I have addressed your comments. Also made a small change to the new style prop type to enforce it's shape. |
Inline Styles, optional setElement calls,
|
I'm not entirely happy with this change. It is forcing me to use this method of setting the inline styles, or, alternatively, overwriting everything that react-modal predefines. I want to use cssmodules, and I'm now forced to pass a custom style object to react-modal that sets all the style props to null. I don't think the default style is all that great - or useful. I could even see it being removed entirely. Or, how about a custom style object replaces the built in one completely? |
|
#74 might be a case in point. |
|
@miracle2k styling these 3rd party components is one of my biggest frustrations. I have played around with various approaches in the different components that I have built, but am not in love with any of the solutions thus far. I would really like to come up with an ideal way of doing this. In my mind, these are the goals:
If we can achieve these three things, I'm happy with whatever we can come up with. |
|
I think I have a solution. I have changed it so that by default no styles are applied. This allows you to apply your custom // No styles
<Modal/>
// Custom style
<Modal style={{overlay: {background: 'black'}}}/>
// Default styles
<Modal style={Modal.Styles}/>
// Default + custom styles
<Modal style={{overlay: [Modal.Styles.overlay, {background: 'rgba(0, 0, 0, 0.75)'}]}}/>Would love to hear your thoughts @jackofseattle @miracle2k |
|
@mzabriskie I like the idea, though I worry about what happens when people forget to have the default styles applied as well. Maybe we should dump the inline styles to a css file that can be included by the consumer if they'd prefer not to use inline styles |
|
@jackofseattle I suspect people will definitely forget to set the default styles, but it will be immediately obvious, and it's an easy fix to get the default styles in place. I will update the README to use the default styles in the example, and all the example code as well. I dislike using CSS because it requires some tooling on the consumer end. They will need to use the style-loader, and css-loader, or the CSS file needs to be copied to where ever their public files are saved. |
|
@jackofseattle @miracle2k I didn't get consensus in time, and went ahead a released a new version of react-modal without any changes to styles. I'm happy to do another release once we agree on the best approach. |
Side effect of the inline styles is that we lost the media query for small screens. I found this to be an acceptable sacrifice. If it's really a problem then we can set up a debounced resize watcher that does a window.matchMedia call and adjusts the inline styles. Optionally, use radium - though that marries this to a certain css implementation, which is not so awesome.