Dark mode implementation
Resolve issue #18.
| Light mode | Dark mode |
|---|---|
My dark mode implementation is based on 3 techniques, as follows:
- Using this CSS design pattern to add theme classes and dynamic variables inside
main.csswhose value is changed based on the changes ofprefer-color-scheme: light|darkmedia query. These variables are referenced in other CSS files. - For SVG images that can't be dark-moded using CSS
filter:, I've used this approach on W3School to create<picture>wraps around multiple<source media="(prefer-color-scheme: light|dark)" >inindex.html. - Technique 1 and 2 are OS-level, they applied when system color scheme is changed via OS setting or browser dev tool. Based on someland2's answer on SOF, I've added a toggle button in the playground's header that when clicked can change theme at browser-level.
P/s: I've changed some nitty-gritty stuffs such as padding, margin, copyright year, id name, class name, ... hope it didn't cause much problem :")
P/s 2: There are 2 bugs, 1 at editor.js#L82 and 1 at modal.css#L65
That's impossible, I've changed the background color of the outer code snippet.
Would you mind pasting a screenshot of what it looks like locally on this branch on your machine and a screenshot of prod?
| Local | Prod |
|---|---|
Ah yes, the shadow and the bold title was something I've changed. My bad. They are changed according to #18's original design.
After changes:
| Local | Prod |
|---|---|
@alixander I don't understand why the latex has two \\ instead of one, although I've checked in snippets.js:
It should be one \, if you check in master, it has the right version
It should be one
\, if you check in master, it has the right version
Yeah I've changed to one \, but somehow my local doesn't reflect that.
Okay, I give up. Maybe this is something that's only happened on my machine only. I will push the code and you can test it on your machine and tell me if there are any differences.
Since the light version changed, I'll have to take some time to incorporate the dark mode implementation without affecting light mode version. Will set aside some time for it after some stuff.
finally picking this back up, sorry for the delay and thanks again for this contribution. continued here: https://github.com/terrastruct/d2-playground/pull/79