-
-
Save pygy/3d175655b989053cb9b2 to your computer and use it in GitHub Desktop.
Mithril + j2c
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
Widget = { | |
styles: j2c.scoped({ | |
title: { | |
font_size: '3rem', | |
"&:before":{ | |
color: "#888", | |
content: "#" | |
} | |
}, | |
content: { | |
padding: '2rem', | |
margin: '0 0 0.5rem 0' | |
} | |
}), | |
view: function (ctrl) { | |
return m('.widget', [ | |
m('style', {config:function(el, isInit){ | |
if (isInit) { | |
// if no IE lte8 support is required `m('style', Widget.styles)` | |
// does the trick. | |
try { el.innerText = Widget.styles } | |
catch (e) { el.styleSheet.cssText = Widget.styles } | |
} | |
}) | |
m('h3', { class: Widget.styles.title }), | |
m('div', { class: Widget.styles.content }) | |
]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment