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

[css] Support @media (prefers-color-scheme: <light|dark>) media queries #300

Open
hedyhli opened this issue Apr 20, 2024 · 0 comments
Open

Comments

@hedyhli
Copy link
Contributor

hedyhli commented Apr 20, 2024

Most websites, in my experience out of ones I browse, assume light mode by default. However, terminals are likely to be in dark mode. Following the recent trend to have websites support both light and dark modes through the prefers-color-scheme media query, I think it makes sense for elinks to support this, and have the configurable, eg document.css.prefers_color_scheme set to "dark" by default.

This allows websites that set light background colors by default, but dark background colors for dark mode, to be shown in dark mode in elinks.

Before opening this issue, I digged through the code base and played around with the CSS parser. It looks like elinks currently only support Media types (@media type1,type2,type3... {}/@media type1 {}).

Media features does not seem to be supported, but it was relatively easy to add support for only (prefers-color-scheme: <light|dark>) specifically, for now, whilst keeping the existing support (eg @media tty { ... }).

I'm not super confident my patch is robust, but it works fairly well during my testing. I'm interested in opening an PR for it.

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

1 participant