Skip to content
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

Github Dark Mode Image Support #261

Closed
mwarkentin opened this issue Apr 25, 2022 · 3 comments
Closed

Github Dark Mode Image Support #261

mwarkentin opened this issue Apr 25, 2022 · 3 comments

Comments

@mwarkentin
Copy link

I was directed here from pypi/warehouse#11251 and then theacodes/cmarkgfm#48.

What's the problem this feature will solve?
Github supports rendering a specific image for light vs. dark mode by actually specifying two images. Here's an example PR: getsentry/sentry#33799

However when the .md file is rendered elsewhere (like pypi) it would show up as 2 images.

Describe the solution you'd like

I'm wondering if it would make sense to have an option that would let you specify light / dark mode when rendering and hide / show the images as they do on Github? Defaulting to rendering light mode only or ignoring the mode probably makes sense.

Additional context

@wooorm
Copy link

wooorm commented Apr 25, 2022

GH implements this very naïvely/smartly with CSS. Basically:

@media (prefers-color-scheme: light) {
  /* ^-- browser/os setting */
  :root[data-color-mode=auto] .markdown [href$="#gh-dark-mode-only"] {
    /* ^-- gh theme */
    display: none
  }
}

Perhaps y’all could do the same?

@mwarkentin
Copy link
Author

Ah interesting, thanks! I'll pass that along (I don't actually work on pypi).

@phillmv
Copy link
Member

phillmv commented May 3, 2022

Hey Mark,

As @wooorm noted, this is all CSS trickery and out of the markdown renderer's scope.

Cheers!,

@phillmv phillmv closed this as completed May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants