dart-lang / dart-lang/pub-dev

Images with dark/light tag

Open
#6,363 8 comments 4 reactions 0 assignees View on GitHub
Type: enhancement
Dominant language
Dart
Stars
944
Forks
184
Avg merge
1d 15h
Merged PRs (30d)
12

Description

On GitHub, one can specify image sources based on [light/dark theme][github_docs].

Basically that means user can define pictures like this and then its aware of when it should be light version or black one.

```html



Shows an illustrated sun in light mode and a moon with stars in dark mode.

```

Try switching your theme and see this example:



Shows an illustrated sun in light mode and a moon with stars in dark mode.

### Issue

Because majority (I suppose) of pub.dev packages are imported from GitHub, it would be very cool if pub.dev could handle theme based sources like that.

On pub.dev, it also works, but because of the site that does not change the theme, it actually does not work.

light:
image

dark:
image

Now imagine that you have only white text logo for dark theme, ergo making the logo/whatever **not visible**.

### Proposal

Make a research of what solutions is possible and set light theme as forced default for pub.dev at this moment.

Sources:

- https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
- https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme
- https://web.dev/color-scheme/
- https://www.ditdot.hr/en/dark-mode-website-tutorial

---

I updated the original issue so it contains valid up-to-date resources. ([referenced GitHub's docs][github_docs])

[github_docs]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#specifying-the-theme-an-image-is-shown-to

---

Update 2: it seems that one cannot force CSS color scheme and it would have to be done in JS.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.