Dark side of the web - making dark mode accessible for web

A presentation at EmberConf 2022 in April 2022 in by Anne-Greeth van Herwijnen

Slide 1

Slide 1

Welcome to the dark side Making dark mode for web accessible

Slide 2

Slide 2

Making dark mode accessible for web

Slide 3

Slide 3

Slide 4

Slide 4

i a.g.vanherwijnen l agvanherwijnen i Anne-Greeth z MinThaMie

Slide 5

Slide 5

Making dark mode accessible for web

Slide 6

Slide 6

https://css-tricks.com/poll-results-light-on-dark-is-preferred/

Slide 7

Slide 7

37% 63% https://css-tricks.com/poll-results-light-on-dark-is-preferred/

Slide 8

Slide 8

Slide 9

Slide 9

Slide 10

Slide 10

Slide 11

Slide 11

Slide 12

Slide 12

Slide 13

Slide 13

Slide 14

Slide 14

TODO: Add tailwind example

Slide 15

Slide 15

Slide 16

Slide 16

Slide 17

Slide 17

Slide 18

Slide 18

Media queries

Slide 19

Slide 19

@media

Slide 20

Slide 20

Media types all, print, screen

Slide 21

Slide 21

@media screen

Slide 22

Slide 22

Media features

Slide 23

Slide 23

Media features

Slide 24

Slide 24

@media screen and (prefers-colorscheme: dark) { // Insert your CSS here }

Slide 25

Slide 25

Slide 26

Slide 26

Slide 27

Slide 27

@media (prefers-color-scheme: dark) { }

Slide 28

Slide 28

@media (prefers-color-scheme: dark) { body { background-color: #1A1A2E; color: white; } }

Slide 29

Slide 29

@media (prefers-color-scheme: dark) { body { background-color: #1A1A2E; color: white; } a { color: #FBBF24; } }

Slide 30

Slide 30

@media (prefers-color-scheme: dark) { body { background-color: #1A1A2E; color: white; } a { color: #FBBF24; } .lttf-chart { background-color: #16213E; } }

Slide 31

Slide 31

@media (prefers-color-scheme: dark) { body { background-color: #1A1A2E; color: white; } a { color: #FBBF24; } .lttf-chart { background-color: #16213E; } .chart-container .axis { fill: white !important; } }

Slide 32

Slide 32

:root { —background-color: beige; —text-color: black; —border-radius: 4px; } body { background-color: var(—background-color) color: var(—text-color) } @media screen and (prefers-color-scheme: dark) { :root { —background-color: #12121; —text-color: white; } }

Slide 33

Slide 33

:root { —background-color: beige; —text-color: black; —border-radius: 4px; } body { background-color: var(—background-color) color: var(—text-color) } @media screen and (prefers-color-scheme: dark) { :root { —background-color: #12121; —text-color: white; } }

Slide 34

Slide 34

:root { —background-color: beige; —text-color: black; —border-radius: 4px; } body { background-color: var(—background-color) color: var(—text-color) } @media screen and (prefers-color-scheme: dark) { :root { —background-color: #12121; —text-color: white; } }

Slide 35

Slide 35

:root { —border-radius: 4px; } body { background-color: var(—background-color) color: var(—text-color) } @media screen and (prefers-color-scheme: dark) { :root { —background-color: #12121; —text-color: white; } } @media screen and (prefers-color-scheme: light) { :root { —background-color: beige; —text-color: black; } }

Slide 36

Slide 36

TODO: Add tailwind example

Slide 37

Slide 37

Slide 38

Slide 38

Slide 39

Slide 39

dark:

Slide 40

Slide 40

Slide 41

Slide 41

100 lines of code changed *

  • Actually 101 but 100 looked cooler on the slide :)

Slide 42

Slide 42

Slide 43

Slide 43

Slide 44

Slide 44

Slide 45

Slide 45

accessibility

Slide 46

Slide 46

a1cessibility

Slide 47

Slide 47

a2essibility

Slide 48

Slide 48

a3ssibility

Slide 49

Slide 49

a4sibility

Slide 50

Slide 50

a5ibility

Slide 51

Slide 51

a6bility

Slide 52

Slide 52

a7ility

Slide 53

Slide 53

a8lity

Slide 54

Slide 54

a9ity

Slide 55

Slide 55

a10ty

Slide 56

Slide 56

a11y

Slide 57

Slide 57

Colors

Slide 58

Slide 58

Color wheel zelf maken

Slide 59

Slide 59

Slide 60

Slide 60

Interactive version by Robert Allison on SAS Learning Post

Slide 61

Slide 61

https://enchroma.com/blogs/beyond-color/how-color-blind-see

Slide 62

Slide 62

Web Content Accessibility Guidelines WCAG

Slide 63

Slide 63

Contrast

Slide 64

Slide 64

Slide 65

Slide 65

Contrast ratios can range from 1 to 21 (commonly written 1:1 to 21:1). (L1 + 0.05) / (L2 + 0.05), whereby: • L1 is the relative luminance of the lighter of the colors, and • L2 is the relative luminance of the darker of the colors. L = 0.2126 * R + 0.7152 * G + 0.0722 * B where R, G and B are de ned as: • if R <= 0.03928 then R = R /12.92 else R = ((R +0.055)/1.055) ^ 2.4 sRGB sRGB sRGB • if G <= 0.03928 then G = G /12.92 else G = ((G +0.055)/1.055) ^ 2.4 sRGB sRGB sRGB • if B <= 0.03928 then B = B /12.92 else B = ((B +0.055)/1.055) ^ 2.4 sRGB sRGB sRGB and R , G , and B are de ned as: sRGB sRGB sRGB • R = R /255 sRGB 8bit • G = G /255 sRGB 8bit • B = B /255 8bit fi https://medium.muz.li/the-science-of-color-contrast-an-expert-designers-guide-33e84c41d156 fi sRGB

Slide 66

Slide 66

Slide 67

Slide 67

Slide 68

Slide 68

Slide 69

Slide 69

Slide 70

Slide 70

Slide 71

Slide 71

Slide 72

Slide 72

Slide 73

Slide 73

Developer tools

Slide 74

Slide 74

Slide 75

Slide 75

Slide 76

Slide 76

Slide 77

Slide 77

Slide 78

Slide 78

Slide 79

Slide 79

Slide 80

Slide 80

Slide 81

Slide 81

Slide 82

Slide 82

Slide 83

Slide 83

@media screen and (prefers-color-scheme: dark) { // Insert CSS here } @media screen and (prefers-color-scheme: light) { // Insert CSS here } i a.g.vanherwijnen l agvanherwijnen z MinThaMie

Slide 84

Slide 84

Resources • https://enchroma.com/blogs/beyond-color/how-color-blind• https://a11y-automation.dev/ • https://github.com/mansona/lint-to-the-future • https://css-tricks.com/poll-results-light-on-dark-is-preferred/ • https://sashamaps.net/docs/resources/20-colors/ • https://webaim.org/resources/contrastchecker/ • https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-colorscheme • https://linktr.ee/Agathe.Badia