Last active
March 2, 2017 01:26
-
-
Save ishiduca/cffadbf46ed13e8b2a5c002b69cf369b to your computer and use it in GitHub Desktop.
yo-yo と csjs
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
<!doctype html><body><script src="./bundle.js"></script></body> |
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
{ | |
"dependencies": { | |
"csjs": "^1.1.0", | |
"insert-css": "^2.0.0", | |
"yo-yo": "^1.4.0" | |
}, | |
"devDependencies": { | |
"yo-yoify": "^3.5.0" | |
}, | |
"scripts": { | |
"build": "browserify app.js > bundle.js" | |
}, | |
"browserify": { | |
"transform": [ | |
"yo-yoify" | |
] | |
} | |
} |
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 yo = require('yo-yo') | |
var d = require('global/document') | |
var csjs = require('csjs') | |
var styles = csjs ` | |
.header { | |
background-color: #ffffaa; | |
border-radius: .5rm; | |
} | |
.message { | |
margin: 0; | |
padding: 6px; | |
font-size: medium; | |
} | |
` | |
var div = yo ` | |
<header class=${styles.header}> | |
<p class=${styles.message}>hello csjs</p> | |
</header> | |
` | |
var root = yo `<main>${div}</main>` | |
require('insert-css')(csjs.getCss(styles)) | |
d.body.appendChild(root) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment