Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mithril + JSS
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
You can’t perform that action at this time.