Skip to content

Instantly share code, notes, and snippets.

@gilbert
Created March 25, 2015 17:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gilbert/a45e36bda3a7de490d8c to your computer and use it in GitHub Desktop.
Save gilbert/a45e36bda3a7de490d8c to your computer and use it in GitHub Desktop.
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