Created
March 25, 2015 17:09
-
-
Save gilbert/a45e36bda3a7de490d8c to your computer and use it in GitHub Desktop.
Mithril + JSS
This file contains 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
Widget = { | |
controller: function () { | |
this.css = Widget.stylesheet().classes | |
}, | |
view: function (ctrl) { | |
return m('.widget', [ | |
m('h3', { class: ctrl.css.head }), | |
m('div', { class: ctrl.css.body }) | |
]) | |
}, | |
styles: { | |
head: { | |
'font-size': '3rem' | |
}, | |
body: { | |
'padding': '2rem', | |
'margin': '0 0 0.5rem 0' | |
} | |
}, | |
// This could be a mixin | |
stylesheet: function () { | |
this._stylesheet || (this._stylesheet = jss.createStyleSheet(this.styles).attach()) | |
return this._stylesheet | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment