Last active
April 13, 2020 21:42
-
-
Save florentmorin/fb384dc50777bc2217c01f5ccfec7177 to your computer and use it in GitHub Desktop.
Mode sombre et accessibilité
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 { | |
color: black; | |
} | |
@media (prefers-color-scheme: dark) { | |
h1 { | |
color: white; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<picture> | |
<source srcset="/image-sombre.svg" media="(prefers-color-scheme: dark)"> | |
<img src="/image-par-defaut.svg"> | |
</picture> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mode sombre actif ? | |
function isDarkModeEnabled() { | |
return window.matchMedia && | |
window.matchMedia('(prefers-color-scheme: dark)').matches; | |
} | |
// Exécuté lorsque le mode sombre est activé / désactivé | |
function colorSchemeChanged() { | |
// ... | |
} | |
// Mise en place du "listener" | |
if (window.matchMedia) { | |
var colorSchemeCheck = window.matchMedia('(prefers-color-scheme: dark)'); | |
colorSchemeCheck.addListener(colorSchemeChanged); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@supports (font: -apple-system-body) { | |
html { | |
font: -apple-system-body !important; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta name='viewport' content='initial-scale=1, viewport-fit=cover'> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment