Web フロントエンドにおけるコンポーネント化のアプローチ / Component of Web Frontend

0d605a3350dd7e91b8136aecffd5ceeb?s=47 Shogo Sensui
February 25, 2017

Web フロントエンドにおけるコンポーネント化のアプローチ / Component of Web Frontend

2017年2月25日に開催された Inside Frontend の「Web フロントエンドにおけるコンポーネント化のアプローチ」のセッション資料です。

0d605a3350dd7e91b8136aecffd5ceeb?s=128

Shogo Sensui

February 25, 2017
Tweet

Transcript

  1. *OTJEF'SPOUFOE  !DI4IPHP4FOTVJ 8FCؿٗٝزؒٝسחֶֽ׷ ؝ٝه٦طٝز⻉ך،فٗ٦ث

  2. !DI

  3. !DI ‣ 4IPHP4FOTVJ ‣ BLBDIPO*OUFSOFU ‣ $ZCFS"HFOU *OD ‣ 8FC*OJUJBUJWF$FOUFS

    ‣ 4PGUXBSF&OHJOFFS ‣ 8FCDMJFOUTJEFEFWFMPQNFOU ‣ 0QFO4PVSDF4PGUXBSF
  4. ?㼰׃⵸ך8FCחֶֽ׷ ؝ٝه٦طٝزחꟼׅ׷鑧겗

  5. أة؎ٕؖ؎س

  6. $44ךأة؎ٕؖ؎س 䔲儗 ‣ فٗآؙؑز6*ךسًُؗٝزה׃ג ‣ )5.- $44ך朐䡾׾鋅ִ׷⻉׃׋׮ך ‣ ؿٗٝزؒٝسؒٝآص،ָ؝ؾل׃ג⢪ְ׋ְ ‣

    رؠ؎ش٦הך⼿噟䩛媮ה׃ג ‣ 椚䟝فٗآؙؑز6*ך侭椚װⱄⵃ欽ך׋׭ ‣ 植㹋ًٝذشٝأׁ׸זְկ؝ؾلⵃ欽ׅ׵דֹזְ
  7. ! ⡦׾鍑寸ׅ׸לְְךַ 劤颵涸ח鋅ִגזַ׏׋

  8. ؝ٝه٦طٝزהכ ְ׏׋ְז׿זךַ ?

  9. اؿزؐؑ،חְֶגכ暴㹀ך堣腉ծ暴ח ⱄⵃ欽׾罋ִג害欽חꟚ涪ׁ׸׋׮ך չ؝ٝه٦طٝزպהכ˘

  10. ☁ 圫ղזꟚ涪؝ٝذؗأز $MJFOU4JEF #SPXTFS J04 "OESPJE 4FSWFS4JEF 8JOEPXT -JOVY 

    ̞
  11. None
  12. ؝ٝه٦طٝزך⣣⦼ ‣ رؠ؎ٝחְֶג ‣ ِ٦ؠ٦؎ٝة٦ؿؑ٦أך♧顐䚍٥害欽䚍 ‣ 堣腉ח♷ִ׷،ؿؓ٦تٝأ ‣ اؿزؐؑ،חְֶג ‣

    فؚٗٓيךⱄⵃ欽䚍٥害欽䚍 ‣ ذأةؽٔذ؍
  13. ? 8FCؙٓ؎،ٝز؟؎س חֶֽ׷؝ٝه٦طٝز

  14. 剑穄䧭卓暟ך⣣⦼׾ 䊩〸׃䖤׷׮ך "

  15. ֿ׸תדך㉏겗挿 ‣ ؝ٝه٦طٝزך盖椚䩛媮ך㉏겗 ‣ ؙٓ؎،ٝز؟؎س㹋鄲ך彘㉏겗 ‣ ؝ٝه٦طٝز׾㹋植ׅ׷♳דך䪮遭涸铬겗

  16. ? ؙٓ؎،ٝز؟؎سחֶֽ׷ ؝ٝه٦طٝزך盖椚倯岀

  17. )5.- $44ד⡲䧭ׅ׷ أة؎ٕؖ؎سכוֲזךַ

  18. رؠ؎ٝر٦ة׾⿫罋חׅ׷ رؠ؎ٝر٦ة׾刿倜ׅ׷ %FTJHO %FWFMPQ )5.- $44דⱄ植ׅ׷ أة؎ٕؖ؎س׾刿倜ׅ׷

  19. 铩ָًٝذشٝأׅ׷㉏겗 ‣ رؠ؎ش٦ָ)5.- $44׾⥜姻♶腉ז׵䝤䩛 ‣ رؠ؎ش٦͑؝ٝه٦طٝز盖椚罏ז؛٦أָ㣐⼱ ‣ ♧倯鸐遤ד֮׷ֲ׍כ䛊׵ֻٙ٦ؙ׃זְ ‣ ׉׮׉׮؝ٝه٦طٝز鏣鎘כ8FCח⣛㶷׃זְ

    ‣ J04װ"OESPJEד׮؝ٝه٦طٝزך罋ִ倯כずׄ ‣ 8FCꣲ㹀ךفٗتؙزז׵葺瘻ַ׮׃׸זְ ‣ ؝ٝه٦طٝز♧鋮׾8FCד鋅׸׷ךכ葺ְө
  20. رؠ؎ش٦הر؍كٗحػ٦ך⚕倯חծ؝ ٝه٦طٝزך鏣鎘ה麊欽ח顑⟣׾《׶竲 ֽ׷䠐陎ָ⵸䲿ח䗳銲׌׏׋ "ؙٓ؎،ٝز㹋鄲罏ך顑⹡

  21. رؠ؎ٝؿ؋؎ٕד盖椚ׅ׷ ‣ ؝ٝه٦طٝز⽃⡘דⴓⶴׅ׷ךָꅾ銲 ‣ رؠ؎ش٦ָ竰竲׃גًٝذشٝأדֹ׷ ‣ 盖椚ׅ׷♳דل٦آ歗꬗הְֲ嚊䙀כ♶銲 ‣ הכְִծل٦آؿ؋؎ٕכ䗳銲חז׷˘ ‣

    ؝ٝه٦طٝزؿ؋؎ٕ׾⿫撑׃ג圓䧭ׅ׷ ‣ 1IPUPTIPQכ㢩鿇ؿ؋؎ٕ׾⿫撑〳腉ծ4LFUDIכ♶〳腉
  22. 4LFUDI*NQPSU4ZNCPMT IUUQTHJUIVCDPNLNFSDTLFUDIJNQPSUTZNCPMT

  23. رؠ؎ٝر٦ة׾⿫罋חׅ׷ رؠ؎ٝر٦ة׾刿倜ׅ׷ %FTJHO %FWFMPQ )5.- $44דⱄ植ׅ׷ أة؎ٕؖ؎س׾刿倜ׅ׷

  24. None
  25. ? ؙٓ؎،ٝز؟؎س㹋鄲ך彘

  26. ⼿⫴ך׋׭ךرؠ؎ٝ䙼罋ךⱄ圓眠DPVME IUUQXXXZBTVIJTBDPNDPVMEBSUJDMFEEEPPVYKPC hDPVME

  27. hDPVME

  28. Ꟛ涪فٗإأ♳ך䗳搫 ‣ Ⰻ⡤⫷ך邌植ָ铬ׇ׵׸׷رؠ؎ش٦ ‣ 㹏⯓פך䲿周ծٌحؙ،حفך⡲䧭ծFUD ‣ 銲⟝♶⪒װأ؛آُ٦ٕ㖇鶕ח״׶ծ䖓䩛חז׷ ‣ 㹋鄲ך⵸䲿ד֮׶ծ㹋鄲פך⣛㶷ָ䓼ְ ‣

    歗꬗؟؎ؤװ堣腉ך罋䣁怩׸כ㹋鄲٥麊欽؝أزח湫穠ׅ׷ ‣ رؠ؎ش٦הؒٝآص،ך娄׫㺔׶ָ実׭׵׸׷
  29. رؠ؎ش٦כ㹋鄲׾椚鍑׃ ؒٝآص،כرؠ؎ٝ׾椚鍑ׇ״

  30. 8FCؿٗٝزؒٝسך $44הְֲ⡂גꬊז׷铬겗 ?

  31. فٓحزؿؓ٦ي嫣ך ؝ٝه٦طٝز׾䧭ׅ䪮遭

  32. )5.- $44 %0. 4UPSZCPBSE  7JFX GSBHNFOUYNM 'SBHNFOU 'SBHNFOU 

    "DUJWJUZ 7JFX  7JFX$POUSPMMFS #SPXTFS J04 "OESPJE 鋅׋湡ך㹋鄲 䮶׷莸ְך㹋鄲 )5.- $44 )5.- $44׌ֽأ؝٦فָזְ
  33. $44כأ؝٦فָזֻ 腚ֻ㠨׸װְׅ鎉铂

  34. أ؝٦فָזֻג鳞ְٔأز ‣ 〳䵤䚍ָזְծֿ׸ח㽴ֹ׷ ‣ ז׈ז׵$BTDBEJOH4UZMF4IFFU׌ַ׵ ‣ 㥴⡦ח⮚׸׋؝ٝه٦طٝز鏣鎘ד׮♳剅ֹ׾꣇־זְ ‣ $44鏣鎘כ剑⡚ꣲךأػ؜ذ؍㼎瘻ח麓ֺזְ ‣

    劤颵涸ח؝ٝه٦طٝز⻉׾酡⸔ׅ׷׮ךדכזְ ‣ $44ָ灶笼ׅ׷ַやַכرؠ؎ٝח⣛㶷ׅ׷
  35. $44כ鏣鎘׾䊨㣗׃ג׮ رؠ؎ٝ如痥ד灶笼ׅ׷ ˟暟✲ָծ⥜䗁׃״ֲָזְקוֲתֻ遤ַזֻז׷ֿהկ遤ֹ鑥ת׷ֿהկ

  36. הכְִأ؝٦فכ妜׃ְ

  37. $44.PEVMFTה$44JO+4 ‣ $44.PEVMFT ‣ $44ؿ؋؎ٕ׾JNQPSUד⿫撑ׅ׷ ‣ $44JO+4 ‣ +BWB4DSJQUךؔـآؙؑزד$44׾鎸鶢ׅ׷ ‣

    $44ך鎉铂涸ז䓲ׁ׾⯘剪ׅ׷،فٗ٦ث
  38. /* style.css */ .className { color: green; } import styles

    from "./style.css"; element.innerHTML = `<input class="${styles.className}">`;
  39. import jss from 'jss'; const styles = jss.createStyleSheet({ className: {

    color: green } }).attach(); element.innerHTML = `<input class="${styles.className}">`;
  40. 4IBEPX%0. ‣ أ؝٦فך㹋植 ‣ 銲稆⽃⡘ךأ؝٦ف׾㹀纏דֹ׷ ‣ ⱄꂁ䋒〳腉ז劤勻ך؝ٝه٦طٝزָ卓׋ׁ׸׷ ‣ $VTUPN&MFNFOUTח״׷銲稆ךⱄ㹀纏 ‣

    ⟣䠐ך6*װ䮶׷莸ְ׾תה׭׵׸׷ ‣ 8FC$PNQPOFOUT
  41. <template> <style> :host { display: inline-block; } </style> <input type="checkbox">

    </template> <script> class SwitchElement extends HTMLElement { constructor() { super(); const o = document.currentScript.ownerDocument; const t = o.querySelector('template'); this.attachShadow({ mode: 'open' }); this.shadowRoot.appendChild(t.content.cloneNode(true)); } } customElements.define('switch-element', SwitchElement); </script>
  42. ֿֿתדך㉏겗挿ך侭椚 ‣ ؝ٝه٦طٝزכاؿزؐؑ،ךㅷ颵חꟼ׻׷ ‣ וךأةحؙחְֶג׮ずֿׄהָ鎉ִ׷ ‣ أة؎ٕؖ؎سד겥㖈⻉׃׋㉏겗 ‣ ؝ٝه٦طٝزך盖椚倯岀ה׃ג黝ⴖז䩛媮דכזַ׏׋ ‣

    رؠ؎ش٦הؒٝآص،ך꟦ך䠐陎ך룪뤍 ‣ ؙٓ؎،ٝز؟؎س㹋鄲חꟼ׻׷➂ך⼿⸂ָ♶〳妀 ‣ 8FCؿٗٝزؒٝس㔿剣ך㹋鄲♳ך㉏겗כ鍑寸׃אא֮׷ ‣ ׻ַ׏גכְ׷ֽוծזַזַ㹋騧דֹזְ؎و؝؝
  43. ⼿噟㹋騧חぢֽ׋倯ꆙ ‣ 耵腉ず㡦ך娄׫㺔׶BU植㜥 ‣ رؠ؎ش٦כ㹋鄲׾ծؒٝآص،כرؠ؎ٝ׾㷕ע ‣ ♧倯鸐遤זꟚ涪חז׵זְ׋׭ך铡䖤勞俱ך䲿爙 ‣ Ꟛ涪♳ךًٔحزOPUؒٝآص،鿪さ ‣

    ㅷ颵♳ךًٔحزOPUؒٝآص،鿪さ ‣ ⯓➂ח㷕ע ‣ فٗإأ׾ؿٖ٦يٙ٦ؙח䔲גכ׭׷
  44. 耵腉ך娄׫㺔׶BU植㜥 ‣ 铡䖤勞俱ך❛䳔 ‣ Ꟛ涪♳ךًٔحزⱄⵃ欽䚍ծ⥂㸚䚍ծꟚ涪؝أز ‣ ㅷ颵♳ךًٔحزرؠ؎ٝװ⹛⡲ך♧顐䚍 ‣ ֶ✼ְך⡲噟׾㼭ֻׁⴓ䬐 ‣

    ✮劍ׁ׸׷䮶׷莸ְ׾ؒٝآص،ָٖؽُ٦ׅ׷הַ ‣ 6*ך邌植鿇ⴓ׾رؠ؎ش٦ָ㹋鄲׃ג׫׷הַ ‣ ꦄ䱸ׅ׷耵腉ָ実׭׷ֿהך椚鍑
  45. زحفتؐٝז鑧 ‣ أذ٦ؙمٕت٦הךさ䠐䕎䧭 ‣ ⠓爡װ穈籼ٖكٕדך《׶穈׫⻉ ‣ 넝䏝ז佟屚⸂ָ㉏׻׸׷ ‣ رؠ؎ٝءأذي׾鐰⣣ׅ׷ⵖ䏝 ‣

    穈籼װفٗآؙؑزךـٓٝر؍ؚٝ ⠓爡 鿇縭 فٗآؙؑز Ꟛ涪罏 ̕
  46. نزي،حفז鑧 ‣ 植㜥⚺㼪ך虊ך呎崞⹛ ‣ Ꟛ涪فٗإأ⻉ׅ׷ֿהדך㹀滠 ‣ 竰竲ׅ׷呎孡ָ㉏׻׸׷ ‣ 䩛岀٥ؿٖ٦يٙ٦ؙך㼪Ⰵ ‣

    Ꟛ涪鄩ꆀָ֮׷ז׵穈籼涸鍑寸״׶植㹋涸 ‣ 䧭⸆✲⢽⻉ ⠓爡 鿇縭 فٗآؙؑز Ꟛ涪罏 ̓
  47. "UPNJD%FTJHO

  48. 陎罏ח㷕ע

  49. 陎罏 َأؼ؟ׁ׿ ח㷕ע ‣ ֿך䖓ך"."ـ٦أפぢֲַ ‣ !ZIBTTZ㹂חًٝءّׅٝ׷ ‣ IUUQBVUPNBHJDGN׾耮ֻ ‣

    IUUQZBTVIJTBDPNDPVME׾鋅׷
  50. #DI $ DI %DIOFU 5IBOLZPV✨