FormidableLabs / radium

A toolchain for React component styling.
http://formidable.com/open-source/radium/
MIT License
7.39k stars 308 forks source link

Working example of Material UI + Radium? #964

Open kaycebasques opened 6 years ago

kaycebasques commented 6 years ago

I'm having a heck of a time getting Radium and Material UI to play nicely. Can you help me point out where I'm going wrong?

Live: https://materialui-radium.glitch.me/ Source: https://glitch.com/edit/#!/materialui-radium (edit the code and it automatically forks)

Expected:

Actual:

Questions:

  1. When I use StyleRoot on my top-level component, do I need to wrap that component in Radium, also?
...

class App extends React.Component {
  render() {
    return (
      <StyleRoot>
        <div>
          <Card/>
          <Card/>
        </div>
      </StyleRoot>
    );
  }
}

export default Radium(App);
  1. Or should I be wrapping the top-level component in my entry file?
...
ReactDOM.render(<StyleRoot><App/></StyleRoot>, document.getElementById('main'));

Sorry if it ends up being pilot-error, I'm new to it all (React / Material UI / Radium), so it's quite likely something silly on my side. But I figure this is a potentially popular combo, so you might be willing to help getting some boilerplate up and running.

kaycebasques commented 6 years ago

cc @oliviertassinari maybe you'd be willing to take a poke at it

oliviertassinari commented 6 years ago

@kaycebasques I'm happy you are trying radium with Material-UI. I haven't tried. Yeah, I would love to see Radium under https://material-ui-next.com/guides/interoperability/.

you'd be willing to take a poke at it

I'm not sure how I can help. I can reproduce the issue with (no Material-UI involved):

import React from 'react';
import Radium, {StyleRoot} from 'radium';

const styles = {
  card: {
    backgroundColor: 'blue',
    '@media (min-width: 600px)': { backgroundColor: 'red' }
  },
};

function Paper(props) {
  return <div {...props} />
}

class Card extends React.Component {
  render() {
    return (
      <Paper style={styles.card}>
        Card
      </Paper>  
    );
  }
}

export default Radium(Card);

https://glitch.com/edit/#!/fluff-brush