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
Démystifions les CSS Custom Properties
Search
Audrey Garreau
June 13, 2018
Programming
56
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Démystifions les CSS Custom Properties
Audrey Garreau
June 13, 2018
More Decks by Audrey Garreau
See All by Audrey Garreau
Donner du sens à vos pages web avec Schema.org
agarreau
0
340
Other Decks in Programming
See All in Programming
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.8k
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.4k
「人を評価する AI」の設計と実装
ryoyanara
0
220
Hono + Inertia + React で LP を構築した話
oukayuka
2
140
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
500
Flow は今どうなっているか
mizdra
PRO
0
670
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
140
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
590
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
170
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
240
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
990
リアルな遅延を測る仕様
kota_yata
1
120
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
9
970
ラッコキーワード サービス紹介資料
rakko
1
4.5M
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
440
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
Color Theory Basics | Prateek | Gurzu
gurzu
0
430
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Rails Girls Zürich Keynote
gr2m
96
14k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
KATA
mclloyd
PRO
35
15k
Code Reviewing Like a Champion
maltzj
528
40k
Leo the Paperboy
mayatellez
8
2.2k
Transcript
Démystifions les CSS Custom properties
CSS Variables Non, on dit CSS Custom Properties ! 1
Déclaration // Déclaration * { --myvar : #FFF; } //
Utilisation body { background : var(--myvar); }
Déclaration // Déclaration * { --myvar : #FFF; } //
Utilisation body { background : var(--myvar); }
Demo Time ! Attention, vous allez en avoir plein le
css ! https://bit.ly/2LCyfK8
Compatibilité des navigateurs Custom Properties 49 31 16 9.1 @Support
28 22 13 9 Polyfill IE 11 : ShadyCSS
Gestion avec @Support body { background : red; } @support(--color)
{ :root { --color : #FFF; } body { background : var(--color, red); } }
Gestion avec @Support body { background : red; } @support(--color)
{ :root { --color : #FFF; } body { background : var(--color, red); } }
Limites Et oui, on peut pas tout faire avec... 2
Demo Time ! C’est aussi par ce qu’on aime le
risque https://bit.ly/2kWlIWy
Les utilisations avancées = Et vos pages sont plus réactives
3
Demo Time ! Une démo qui ne plante pas n’est
pas une vrai démo ! https://bit.ly/2Jrg3X6
Et ensuite C’est quoi la suite ? 4
Le problème de surchage <my-component> #shadow-root <!-- Overridable part--> <div>
<span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // Style my-component :root { --a-color
: orange; } span { color : var(--a-color); } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // index.css my-component span:hover { --a-color
: red } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // Style my-component :root { --a-color
: orange; } span { color : var(--a-color); } :root span:hover { color : var(--a-color-hover); //red } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // index.css my-component{ --a-color-hover : red
} <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // index.css my-component:focus span:hover { --a-color
: blue } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // Style my-component :root { --a-color
: orange;} span { color : var(--a-color); } :root:hover span { color : var(--a-color-hover); } :root:focus span:hover { color : var(--a-color-hover-focus); //blue } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
Le problème de surchage // index.css my-component{ --a-color-hover : red;
--a-color-hover-focus : blue; } <my-component> #shadow-root <!-- Overridable part--> <div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
::part & ::theme la relève <my-component> #shadow-root <!-- Overridable part-->
<div> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
::part & ::theme la relève <my-component> #shadow-root <!-- Overridable part-->
<div part=”part-name”> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
::part & ::theme la relève <my-component> #shadow-root <!-- Overridable part-->
<div part=”part-name”> <span>...</span> </div> <!-- Non overridable part--> <section>...</section> </my-component> Override Me Don’t Override Me
::part & ::theme la relève // index.css my-component::part(part-name) { --my-color:
blue; } my-component::part(part-name):hover { --my-color: red; font-style: italic; } Override Me Don’t Override Me Override Me Don’t Override Me
Custom Type le problème // main.css body { --my-color: orange;
--my-color: url("https://web2day.co/logo.svg"); color: var(--my-color); }
Custom Type pour typer // main.js CSS.registerProperty({ name: "--my-color", syntax:
"<color>", initialValue: "black" });
Merci ! Des questions ? Audrey Garreau CEO Yumigo -
@garreau_audrey - @yumigoteam Jean-François Garreau CTO Sfeir Nantes / GDE Web Technology - @jefbinomed