-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Images in dark mode #190
Comments
Yeah have thought about this a few times: #79 in particular. It sounds like it should be trivial but there isn't an obvious route forward. Browsers have a built in solution:
It also makes a lot of sense that you could have dual img tags and mark them with a custom class "only-on-dark" "only-on-light" and use that to hide the other image, both of these work in plain html, but our syntax in the md files doesn't really have anyway of passing this property through. All we can do is pass title text and the image source. So the only viable solution that I can think of is to use the title text to encode this info and then use JS to add class to any with title text that matches a pattern:
I really didn't like the idea of a JS solution here, plus it requires content writers to provide the 2 images, so I tried to forget about this issue till now. I guess this isn't the ONLY solution as we could replace the simple title syntax with a custom directive:
OR perhaps even better syntax:
This would allow a cleaner solution in gutenberg but at the expense of making the material writing more complex: We could then support both this and standard syntax allowing people to either do a single image for both themes or provide a set of two. So I guess those are the 2 options that I can see but happy for more suggestions.
Both need material rewritten to support (obviously I guess). |
just putting it out there, is it feasible to support a text-based diagram tool like https://mermaid.js.org/ and encourage the use of that in the material? |
Often, images don't display nicely in dark mode.
They either
Could we come up with some way of displaying an alternative image (if present) if running in dark mode?
E.g. for an image
my_image.svg
, could we detect whether we're in dark mode and, if we are, render insteadmy_image_dm.svg
if that image exists?Happy to entertain other solutions if there's a better way of doing this!
The text was updated successfully, but these errors were encountered: