Blog: Add bad-theming.md
This commit is contained in:
parent
59db7ee48d
commit
17d7b71448
28
posts/2021-11-08-bad-theming.md
Normal file
28
posts/2021-11-08-bad-theming.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
template: post
|
||||||
|
title: Respect my damn color scheme preference
|
||||||
|
author: flewkey
|
||||||
|
timestamp: 1636400000
|
||||||
|
license: CC-BY
|
||||||
|
|
||||||
|
I recently switched from light themes to dark themes. Dark themes seem to be
|
||||||
|
supported enough that most applications seem to work with them. Many
|
||||||
|
websites don’t, but it’s not the end of the world. Theming is hard and I do not
|
||||||
|
expect developers to support it.
|
||||||
|
|
||||||
|
However, I find it inexcusable and frustrating when a website already has a dark
|
||||||
|
theme, but ignores the user’s preferences. Especially if they have a stupid
|
||||||
|
little theme selector that writes to a value in localStorage or something.
|
||||||
|
|
||||||
|
![That’s _not_ how you do that!]({root}images/theme-selector.png)
|
||||||
|
|
||||||
|
If you must use JavaScript to set your themes, consider taking your user’s color
|
||||||
|
scheme preference into consideration when choosing which theme to default to. We
|
||||||
|
will be grateful.
|
||||||
|
|
||||||
|
```
|
||||||
|
if (window.matchMedia("(prefers-color-scheme: dark)").matches)
|
||||||
|
/* Set theme */
|
||||||
|
```
|
||||||
|
|
||||||
|
Even better, you can just use a media query like a normal person. If you need
|
||||||
|
to override it with JavaScript later, you can do that.
|
BIN
static/images/theme-selector.png
Normal file
BIN
static/images/theme-selector.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
Loading…
Reference in New Issue
Block a user