Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2022: The Dark Side of the Web

2022: The Dark Side of the Web

Building a web-app that is accessible and respect your users preferences might be daunting. In this talk you will learn how to respect your users color scheme preferences in an accessible way.

EmberConf

April 19, 2022
Tweet

More Decks by EmberConf

Other Decks in Technology

Transcript

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

    } a { color: #FBBF24; } .lttf-chart { background-color: #16213E; } }
  2. @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; } 
 }
  3. :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; } }
  4. :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; } }
  5. :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; } }
  6. :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; } }
  7. 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 fi ned as: • if R sRGB <= 0.03928 then R = R sRGB /12.92 else R = ((R sRGB +0.055)/1.055) ^ 2.4 • if G sRGB <= 0.03928 then G = G sRGB /12.92 else G = ((G sRGB +0.055)/1.055) ^ 2.4 • if B sRGB <= 0.03928 then B = B sRGB /12.92 else B = ((B sRGB +0.055)/1.055) ^ 2.4 and R sRGB , G sRGB , and B sRGB are de fi ned as: • R sRGB = R 8bit /255 • G sRGB = G 8bit /255 • B sRGB = B 8bit /255 https://medium.muz.li/the-science-of-color-contrast-an-expert-designers-guide-33e84c41d156
  8. @media screen and (prefers-color-scheme: dark) { // Insert CSS here

    } @media screen and (prefers-color-scheme: light) { // Insert CSS here } z MinThaMie i a.g.vanherwijnen l agvanherwijnen
  9. 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-color- scheme • https://linktr.ee/Agathe.Badia