Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CSS Modules
Search
Kaneko Takeshi
May 12, 2017
0
42
CSS Modules
Kaneko Takeshi
May 12, 2017
Tweet
Share
More Decks by Kaneko Takeshi
See All by Kaneko Takeshi
オープンソースライセンスについて勉強する定期
tkckaneko
0
31
Eye Tracking on the Browser
tkckaneko
0
88
IEEE754を完全に理解した
tkckaneko
1
76
CSSのトレンドをみんなで見よう -2021年-
tkckaneko
0
93
多分これが一番早いと思います
tkckaneko
0
27
暗黒面の話
tkckaneko
0
24
CSR / SSR / SSG / JAMstack
tkckaneko
0
73
BOLT
tkckaneko
0
31
CSS Logical Properties and Values
tkckaneko
0
36
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.1k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
110
Navigating Weather and Climate Data
rabernat
0
100
Darren the Foodie - Storyboard
khoart
PRO
2
2.4k
Bash Introduction
62gerente
615
210k
The Limits of Empathy - UXLibs8
cassininazir
1
210
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
55
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
270
The Pragmatic Product Professional
lauravandoore
37
7.1k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
How to train your dragon (web standard)
notwaldorf
97
6.5k
Transcript
CSS Modules
CSS Modules 知ってますか?
None
CSSの悩みを 解決するため 考え出されました
例)命名規則について
CSSはグローバルスコープのため 予期しないコンポーネントから 参照されていることもあります
BEMの場合
Block Element Modifire
.answer__button--disabled
/*** submit-button.css ***/ .answer__button--disabled { } /*** answer.html ***/ <button
class="answer__button--disabled">submit</button>
とても良くできてます しかし、クラス名を考えたり 守っていくことは大変です
CSS Modules
/*** answer-button.css ***/ .disabled { } /*** answer-button.js ***/ import
styles from './answer-button.css' buttonElem.outerHTML = `<button class=${styles.disabled}>Submit</button>`
/*** answer.html ***/ <button class="ansewer_button__bisabled__abc12345"> submit </button>
クラス名は一意になるように コンパイル時に生成されます
実際にやってみます
https://github.com/knktkc/css-modules-examples
まとめ
CSS Modulesじゃなければ ダメってことはないけど 新しい選択肢にどうぞ