Skip to content

Instantly share code, notes, and snippets.

@pygy
Forked from gilbert/widget.js
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pygy/3d175655b989053cb9b2 to your computer and use it in GitHub Desktop.
Save pygy/3d175655b989053cb9b2 to your computer and use it in GitHub Desktop.
Mithril + j2c
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