Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RiotJS + CSS #meguroes

mizuki_r
April 19, 2016

RiotJS + CSS #meguroes

Meguro.es #3 でのトーク内容です

mizuki_r

April 19, 2016
Tweet

More Decks by mizuki_r

Other Decks in Technology

Transcript

  1. RIOTJSͱ͸ A React-like user interface micro-library ▸ ReactͬΆ͍খ͞ͳUIϥΠϒϥϦ ▸ React͕38.56KBͰRiot͕8.61KBʢhttp://riotjs.com/ja/

    ▸ API͕গͳ͘ɺֶशίετ͕௿͍ ▸ ඞཁ࠷௿ݶͷػೳͷΈͰߏ੒͞ΕͨɺϛχϚϜελʔτΞο ϓͳײ͡ͷϥΠϒϥϦ
  2. <todo> <!-- layout --> <h3>{ opts.title }</h3> <ul> <li each={

    item, i in items }>{ item }</li> </ul> <form onsubmit={ add }> <input> <button>Add #{ items.length + 1 }</button> </form> <!-- logic --> <script> this.items = [] add(e) { var input = e.target[0] this.items.push(input.value) input.value = '' } </script> <todo>
  3. <todo> <!-- layout --> <h3>{ opts.title }</h3> <ul> <li each={

    item, i in items }>{ item }</li> </ul> <form onsubmit={ add }> <input> <button>Add #{ items.length + 1 }</button> </form> <!-- logic --> <script> this.items = [] add(e) { var input = e.target[0] this.items.push(input.value) input.value = '' } </script> <todo> ίϯϙʔωϯτΛఆٛ
  4. <todo> <!-- layout --> <h3>{ opts.title }</h3> <ul> <li each={

    item, i in items }>{ item }</li> </ul> <form onsubmit={ add }> <input> <button>Add #{ items.length + 1 }</button> </form> <!-- logic --> <script> this.items = [] add(e) { var input = e.target[0] this.items.push(input.value) input.value = '' } </script> <todo> DOMͷఆٛ
  5. <todo> <!-- layout --> <h3>{ opts.title }</h3> <ul> <li each={

    item, i in items }>{ item }</li> </ul> <form onsubmit={ add }> <input> <button>Add #{ items.length + 1 }</button> </form> <!-- logic --> <script> this.items = [] add(e) { var input = e.target[0] this.items.push(input.value) input.value = '' } </script> <todo> ৼΔ෣͍ͷఆٛ
  6. RIOTJSͱ͸ ؆୯ʹ࢖͑Δখ͞ͳϥΠϒϥϦ ▸ JavaScript in HTML ▸ ਺গͳ͍API ▸ lifecycle

    (mount, update, updated, unmount) ▸ update ▸ yield ▸ dom events
  7. RIOTJS + CSS CSSͷهड़ <todo> <!-- layout --> <h3>{ opts.title

    }</h3> <style> todo { display: block } todo h3 { font-size: 120% } </style> <todo>
  8. RIOTJS + CSS Scoped CSSͷهड़ ▸ λάͷதʹ `<style scoped>` Λهड़͢Δ

    ▸ `<style>` ͷதʹCSSΛهड़͢Δ ▸ `:scope` ͷٖࣅཁૉʹελΠϧΛ౰ͯΔ
  9. RIOTJS + CSS Scoped CSSͷهड़ <todo> <!-- layout --> <h3>{

    opts.title }</h3> <style scoped> scope: { display: block } h3 { font-size: 120% } </style> <todo>
  10. RIOTJS + CSS λάΛϕʔεͱͨ͠ελΠϦϯά ▸ ͜ͷ̎ͭͷॻ͖ํ͸ಉ݁͡ՌʹͳΔ <todo> <!-- layout -->

    <h3>{ opts.title }</h3> <style> todo { display: block } todo h3 { font-size: 120% } </style> <todo> <todo> <!-- layout --> <h3>{ opts.title }</h3> <style scoped> scope: { display: block } h3 { font-size: 120% } </style> <todo>
  11. RIOTJS + CSS headλά΁ͷૠೖ ▸ λάͷ಺෦ʹهࡌ͞Εͨ `<style>` ͸ `<head>` ͷ຤ඌʹૠ

    ೖ͞ΕΔ ▸ Ұ౓ૠೖ͞ΕͨΒɺ࠶౓͸ૠೖ͞Εͳ͍ ▸ shadow-domͰ͸ͳ͍͕ɺ͍ۙΞϓϩʔνΛऔΔ
  12. RIOTJS + CSS ·ͱΊ ▸ λάͷதʹ `<style>` Λهड़͠ɺͦ͜ʹCSSΛॻ͘ ▸ `<style>`

    ͸ `<head>` ͷ຤ඌʹૠೖ͞ΕΔ ▸ `<style scoped>` Λ࢖͏͜ͱͰɺλά໊ͷهࡌΛলུͰ͖Δ
  13. RIOTJS + CSS + WEBPACK CSS͸༷ʑͳϥΠϒϥϦʹࢧ͑ΒΕ͍ͯΔ ▸ autoprefixer ▸ meta

    css ▸ postcss ▸ etc… ͜ΕΒͷԸܙΛ͋·ͣ͞ड͚͍ͨ!!!
  14. RIOTJS + CSS + WEBPACK webpackͷར༻ module: { preLoaders: [

    { test: /\.tag$/, exclude: /node_modules/, loader: 'riotjs- loader' }, ], loaders: [ { test: /\.css$/, exclude: /node_modules/, loader: 'style-loader! css-loader!postcss-loader' } ] }, postcss: () -> return [ require('postcss-calc') require('postcss-nested') require('autoprefixer') ]
  15. RIOTJS + CSS + WEBPACK webpackͷར༻ var style = require(‘./style’)

    <todo> <!-- layout --> <h3>{ opts.title }</h3> <style>{ style }</style> <todo>
  16. RIOTJS + CSS + WEBPACK webpackΛ࢖͏ϝϦοτ ▸ λάͷఆٛͱɺελΠϧͷఆٛΛҰॹʹ؅ཧͰ͖Δ ▸ σΟϨΫτϦʹࠝแͰ͖Δ

    ▸ ίϯϙʔωϯτͱͯ͠ɺ৘ใઃܭɾৼΔ෣͍ɾσβΠϯ͕ಠ ཱ͠ɺΞϓϦέʔγϣϯ͔Βૄ݁߹ʹͳΔ