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
36
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
The Mindset for Success: Future Career Progression
greggifford
PRO
0
550
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
The Curse of the Amulet
leimatthew05
3
16k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
How STYLIGHT went responsive
nonsquared
100
6.3k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
560
Leo the Paperboy
mayatellez
10
2.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Why Our Code Smells
bkeepers
PRO
340
58k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
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