Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CSS Architecture
Search
yuki0410
October 18, 2021
32
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CSS Architecture
yuki0410
October 18, 2021
More Decks by yuki0410
See All by yuki0410
PlantUML
yuki0410
0
100
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
Ethics towards AI in product and experience design
skipperchong
2
430
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
Scaling GitHub
holman
464
140k
Believing is Seeing
oripsolob
1
240
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
710
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Transcript
? by yuki.ohnaka @ no4 1
CSS Architecture by yuki.ohnaka @ no4 2
About Me yuki ohnaka 株式会社ナンバーフォー Front-end / Server-side / Native-App
engineer Vue / React / TypeScript / Java / PHP / Kotlin / Swift / Python / Docker / Ansible ... Qiita / Zenn by yuki.ohnaka @ no4 3
良い CSS Architecture とは? 予測しやすい 再利用しやすい 保守しやすい 拡張しやすい 出典: CSS
Architecture by yuki.ohnaka @ no4 4
(c) 2017 niewals by yuki.ohnaka @ no4 5
CSS 設計をするときの 7 つのポイント by yuki.ohnaka @ no4 6
1. コンテンツとスタイリングは疎結合にする <!-- no good --> <article class="article"> <h2 class="article__title">title</h2>
</article> /** no good */ .article h2 { /** */ } by yuki.ohnaka @ no4 7
1. コンテンツとスタイリングは疎結合にする <!-- good --> <article class="article"> <h2 class="article__title">title</h2> </article>
/** good */ .article__title { /** */ } by yuki.ohnaka @ no4 8
2. 影響範囲を無闇に拡げない /** no good */ #main-nav > div {
/** */ } /** good */ .main-nav__section { /** */ } by yuki.ohnaka @ no4 9
3. 親に関わらず動くようにする /** no good */ #main-nav .article { /**
*/ } /** good */ .article { /** */ } by yuki.ohnaka @ no4 10
4. 詳細度を無闇にあげない /** no good */ #main-nav ul li ul
li div { /** */ } /** good */ .main-nav-sub-list__inner { /** */ } by yuki.ohnaka @ no4 11
5. 影響範囲が想像できるクラス名 <!-- no good --> <article class="article"> <h2 class="title">title</h2>
</article> /** no good */ .article .title { /** */ } by yuki.ohnaka @ no4 12
5. 影響範囲が想像できるクラス名 <!-- good --> <article class="article"> <h2 class="article__title">title</h2> </article>
/** good */ .article__title { /** */ } by yuki.ohnaka @ no4 13
6. 見た目・機能・役割が想像できるクラス名 /** no good */ .title1 { /** */
} /** good */ .page-title { /** */ } by yuki.ohnaka @ no4 14
7. コンポーネントにマージンを持たせない /** no good */ .article { margin-left: 20px;
} /** good */ .article-container { display: grid; column-gap: 20px; } .article { /** */ } by yuki.ohnaka @ no4 15
さぁ、やってみよう by yuki.ohnaka @ no4 16
チームで開発するためには、具体的なルールが 必要 by yuki.ohnaka @ no4 17
既存の CSS を設計を取り入れる BEM (MindBEMding) OOCSS SMACSS FLOCSS Enduring CSS
(ECSS) 必要に応じてカスタムする場合はある。 by yuki.ohnaka @ no4 18
ご清聴ありがとうございました by yuki.ohnaka @ no4 19
@ おまけ by yuki.ohnaka @ no4 20
CSS Architecture は必要か? by yuki.ohnaka @ no4 21
最近 CSS の周辺環境 は便利になってきている scoped CSS (Vue) CSS Modules (with
React) CSS in JS (with React) styled-components (with React) Utility first CSS FW (tailwind) with Web Components もう CSS Architecture なんてどうでもいいのでは? by yuki.ohnaka @ no4 22
引き続き CSS Architecture は必要 解決できていない課題もある モダンな開発以外の開発案件もまだたくさんある CSS Architecture で考慮していた要素が、別(コンポーネント設計 など)に移っただけなので、考えなければいけないことは一緒。
by yuki.ohnaka @ no4 23
シングルクラス VS マルチクラス by yuki.ohnaka @ no4 24
抽象的過ぎないマルチクラスがおすすめ by yuki.ohnaka @ no4 25