Created
August 7, 2014 13:19
-
-
Save bensmithett/20063151bfe8f173d2d7 to your computer and use it in GitHub Desktop.
Trying out react-style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @jsx React.DOM | |
*/ | |
"use strict"; | |
var React = require("react/addons"); | |
var ReactStyle = require("react-style"); | |
var MyComponent = React.createClass({ | |
css: ReactStyle(function () { | |
return { | |
backgroundColor: "green", | |
"> b": { | |
fontStyle: "italic" | |
} | |
}; | |
}), | |
css__subcomponent: ReactStyle(function () { | |
return { | |
backgroundColor: "blue", | |
color: "white" | |
}; | |
}), | |
render: function () { | |
return( | |
<div styles={this.css()}> | |
This is a <b styles={this.css__subcomponent()}>Rad Component!!!</b> | |
</div> | |
); | |
} | |
}); | |
module.exports = MyComponent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="a" data-reactid=".0"> | |
<span data-reactid=".0.0">This is a </span> | |
<b class="b" data-reactid=".0.1">Rad Component!!!</b> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.a { background-color: green; } | |
.a > b { font-style: italic; } | |
.b { background-color: blue; color: white; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I see that you are using a feature I didn't know we had - cascading (tnx css-builder!). Due to the problems that come with it, which is mostly caused by implicit behaviour, this will be disabled in the next version. Sorry for the inconvenience.
I am thinking of adding a form of cascading that is more explicit, and therefore easier to maintain. Something in the direction of: