Last active
November 19, 2015 21:17
-
-
Save StephanHoyer/58c92f3835c2b2f4b75d to your computer and use it in GitHub Desktop.
Basic example of a j2c-mithril integration - http://jsfiddle.net/qe805q4q/1/
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
var styler = require('./styler'); | |
function mainView() { | |
return [ | |
styler.view(), | |
//... | |
]; | |
} |
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
var styler = require('./styler'); | |
var m = require('mithril'); | |
var cls = styler.attach({ | |
foo: { | |
background: 'green' | |
} | |
}); | |
function someRandomView() { | |
return m('span.' + cls.foo, 'Some random content'); | |
} |
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
var m = require('mithril'); | |
var j2c = require('j2c'); | |
var styles = ''; | |
module.exports = { | |
attach: function(style) { | |
var scopedStyle = j2c.scoped(style); | |
styles += scopedStyle; | |
return scopedStyle; | |
}, | |
view: function() { | |
return m('style', styles); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
packaged: https://github.com/StephanHoyer/mithril-j2c