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

真のコンポーネント粒度を求めて

 真のコンポーネント粒度を求めて

Takeshi Takatsudo

August 04, 2017
Tweet

More Decks by Takeshi Takatsudo

Other Decks in Programming

Transcript

  1. 0$$44ͬͯʁ w 0CKFDU0SJFOUFE$44 w ϖʔδ͸Ϩΰͷू·Γͩ w ·ͣ͸Ϩΰʢ.PEVMFʣΛ࡞Ε w ϨΰΛ૊Έ߹ΘͤͯϖʔδΛ࡞Ε w

    ͦ͏͢Ε͹ࣅͨΑ͏ͳ$44ೋ౓ͱॻ͔ͳͯ͘ࡁΉͧ w ͦͨ͠Βແବ͕ແ͘ͳΔͷͰ$44ͷ༰ྔΊͪΌͪ͘Ό΁Δͧ
  2. #&.

  3. <section class="column"> <h3 class="column__head">About BEM</h3> <div class="column__body"> <p class="column__p">The quick

    brown...</p> <p class="column__p">The quick brown...</p> </div> </section> .column { ... } .column__head { ... } .column__body { ... } .column__p { ... }
  4. ͦΕ͸Կʁ w #SBE'SPTUஶ w ͦ΋ͦ΋·ͣϖʔδΛ࡞͍ͬͯΔͱ͍͏ೝࣝΛվΊΔඞཁ͕͋Δ w σβΠϯγεςϜΛ࡞ΓɺϖʔδΛ࡞Δͱ͍͏ྲྀΕ w σβΠϯγεςϜΛҙࣝ͠ɺӡ༻͢Δ͜ͱͰ৭ʑϋοϐʔʹͳΔ w

    ͳΜͱͯ͠Ͱ΋σβΠϯγεςϜΛ࡞Δ΂͠ w σβΠϯγεςϜ͸ྑ͍ͧɺ͜͏͋Δ΂͖ߟ͑ํͩͧ w ͱ͍͏Α͏ͳઃܭํ๏࿦ʹ͍ͭͯॻ͔Εͨ΋ͷ
  5. "UPNJD%FTJHO
 ΛಡΜͰ͜͏ࢥͬͨ w Զ͕ߟ͑Δίϯϙʔωϯτ͸͜Εɺ
 ͓લ͕ߟ͑Δίϯϙʔωϯτ͸͜Ε w ͦͷࠩΛຒΊΔʹ͸ɺ·ͣϫʔΫϑϩʔͱͯͦ͠͏͍͏ί ϯϙʔωϯτΛڞ௨ݴޠͱ͢ΔΑ͏ͳମ੍͕ඞཁ w ͍͘Β)5.-

    $44ͷஈ֊Ͱؤுͬͯ6*Λ੔ཧͨͬͯ͠׬શ ͳίϯϙʔωϯτͷηοτΛ࡞Γ্͛Δͷ͸ແཧͩ w ͳͥͳΒͦΕΑΓલͷஈ֊Ͱͦ͏ߟ͑ΒΕ͍ͯͳ͍͔Β
  6. ෼཭ʹॏ͖Λஔ͘ w ͳʹͦΕඇޮ཰͡Όͳ͍ʁ w ͍΍ɺͳΜͰ΋͔ΜͰ΋࢖͍·Θͦ͏ͱ͢Δ͔Βഁ୼͢Δͷͩ w ແݶʹϞσΟϑΝΠΞ͕૿͑ΔͩΖ͏ w Ұ౓ॻ͍ͨ$44͸ೋ౓ͱมߋ͢Δ͜ͱ͕Ͱ͖ͳ͍ͩΖ͏ w

    ಉ͡$44Λίϐϖͨ͠ͱ͜ΖͰH[JQ͢ΓΌେͯ͠༰ྔมΘΒΜ w ػೳ͝ͱ$44͕·ͱ·͍ͬͯͨΒɺͦͷػೳ͕ͳ͘ͳͬͨ࣌ɺ֘౰Օॴͷ ίʔυΛ·Δ͝ͱࣺͯΔ͜ͱ͕Ͱ͖Δ w ٯʹݴ͑͹ɺ͜ͷΑ͏ʹ͠ͳ͚Ε͹$44͸ೋ౓ͱফ͢͜ͱ͕Ͱ͖ͳ͍
  7. w ը૾΍+BWB4DSJQUͳͲͷΞηοτ΋໊લۭؒ͝ͱʹ·ͱΊΔ /* ڞ௨ common modules */ .cmn-Header { ...

    } .cmn-Footer { ... } .cmn-SideAd { ... } /* τοϓϖʔδ topPage modules */ .tp-MainVisual { ... } .tp-Carousel { ... } .tp-NewsList { ... } /* ঎඼ৄࡉ productDetail modules */ .pd-ItemDescription { ... } .pd-ItemMainPhoto { ... } .pd-Carousel { ... } /* γϣοϐϯάΧʔτ shoppingCart modules */ .sc-ItemList { ... } .sc-UserInfo { ... }
  8. <p class="wysiwyg__p">The quick brown fox jumps over the lazy dog.</p>

    <ul class="wysiwyg__ul"> <li class="wysiwyg__li">one</li> <li class="wysiwyg__li">two</li> <li class="wysiwyg__li">three</li> </ul> #&.తʹຊ౰͸͜͏͍ͨ͠ .wysiwyg__p { margin: 0 0 1.5em; } .wysiwyg__ul { margin: 0 0 1.5em; } .wysiwyg__li { margin: 0 0 0.5em; }
  9. Ͱ΋͜͏͢Δ͔͠ͳ͍ <div class="wysiwyg"> <p>The quick brown fox jumps over the

    lazy dog.</p> <ul> <li>one</li> <li>two</li> <li>three</li> </ul> </div> .wysiwyg p { margin: 0 0 1.5em; } .wysiwyg ul { margin: 0 0 1.5em; } .wysiwyg li { margin: 0 0 0.5em; }
  10. <my-app></my-app> @Component({ selector: 'my-app', template: ` <div> <h2>Hello {{name}}</h2> </div>

    `, styleUrls: ['my-component-styles.css'] }) h2 { border: 2px solid red; }