meteor-mantra-kickstarter icon indicating copy to clipboard operation
meteor-mantra-kickstarter copied to clipboard

Inline styling

Open philohelp opened this issue 9 years ago • 7 comments

As mantra's mission is dedicated to modularity and high maintainability, it feels strange that all styles in the app are locked in a big old fashioned centralized .css.

I changed that for Radium which I didn't know and it works like a charm - just wrap the default layout and then you get clever inline styles wherever you want in the app.

export default class extends React.Component  {
render() {
  const styles = {
    myfavoritebutton: {
      color-background: 'fuschia'
      }
   };
etc.

then :

<Button style={styles.myfavoritebutton}></Button>

There are plenty of other solutions which I didn't try - this one appearing to be the most popular.

philohelp avatar Mar 04 '16 21:03 philohelp

I think this is an interesting issue and fix. Another way to keep it modular would be to put a styles.css (or less/...) in the module.

Is there an agreed way handling this in the React community? I started learning React when trying out Mantra, so I don't know.

sandervanhooft avatar Mar 05 '16 18:03 sandervanhooft

When I originally started working on this the objective was to pull in a minimal bootstrap theme and make it work. I agree we should consider a more modular approach. Will think on this

makstr avatar Mar 07 '16 13:03 makstr

Radium works pretty well here too, doing something like Component = Radium(Component) with Component being stateless.

jiku avatar Mar 07 '16 15:03 jiku

I'll look into that. I've tried to get react-bootstrap to work, but no success. Posted an issue at the Mantra repo for that.

sandervanhooft avatar Mar 07 '16 15:03 sandervanhooft

your issue was closed (maybe misunderstood "solves the issue" ?)

I like this too - with react-styling :

const style = styler
`
  card
    padding-bottom: 0
`

philohelp avatar Mar 08 '16 19:03 philohelp

Did you get that to work with this kickstarter?

sandervanhooft avatar Mar 09 '16 08:03 sandervanhooft

Yes apparently the react-styling lib works fine with radium, both from NPM. For bootstrap I got both bootstrap sass as Meteor package and react bootstrap as NPM. I will try and change that soon. I do import Grid from 'react-bootstrap/lib/Grid';

philohelp avatar Mar 09 '16 15:03 philohelp