From: Eric Wong <e@80x24.org>
To: "Robin H. Johnson" <robbat2@gentoo.org>
Cc: meta@public-inbox.org
Subject: Re: CSS behaviors bug report: dark/light switch non-functional
Date: Wed, 18 Sep 2024 00:04:57 +0000 [thread overview]
Message-ID: <20240918000457.M692185@dcvr> (raw)
In-Reply-To: <robbat2-20240901T045635-169490258Z@orbis-terrarum.net>
"Robin H. Johnson" <robbat2@gentoo.org> wrote:
> I wanted to include a patch, but no obvious way without it being messy
> really stood out, so this is only a bug report.
Yeah, I've been taking a stab at this in between other things but
not really making progress.
> contrib/css describes using the 'prefers-color-scheme' media query
> selector, but Gentoo got a report that the selection between light &
> dark didn't work.
I'm not even sure how that works anymore with fingerprint resistance.
Which browsers + versions + configs are they using?
Will need some testing from others here...
> One of the other devs traced it down to nuances of the HTML link media
> attribute: query expressions are not valid in the HTML variant in some
> browsers.
OK
> This is also mentioned here:
> https://stackoverflow.com/questions/69113672/loading-css-based-on-prefers-color-scheme-media-query
> > Loading CSS based on any media query expression seems to be out of specification for the media attribute.
>
> As a workaround, I merged the two files with a wrapper, but it feels
> sub-optimal, because the entire text gets injected into the PI HTML.
>
> ```
> @media(prefers-color-scheme: dark) {
> ... #content of 216dark
> }
> @media(prefers-color-scheme: light) {
> ... #content of 216light
> }
> ```
Yeah.
> I think the cleanest solution would be a variant of the above:
> clauses, but with @import statements inside them, and making PI-httpd
> expose all the CSS Files.
I think a safe way is to allow loading any CSS files present in
the same directory as an admin-specified CSS file. IOW,
public-inbox.css = /path/to/foo/216dark.css
Will allow autoloading all /path/to/foo/*.css files.
Also, I don't think @import works inside @media,
https://developer.mozilla.org/en-US/docs/Web/CSS/@import says:
| The @import CSS at-rule is used to import style rules from other valid
| stylesheets. An @import rule must be defined at the top of the stylesheet,
| before any other at-rule (except @charset and @layer) and style declarations,
| or it will be ignored.
So I think it'd have to be something like:
@import url('216dark.css') screen and (prefers-color-scheme: light)
If I'm understanding that correctly.
Hopefully I'll be back in a few hours or tomorrow with something
to test...
next prev parent reply other threads:[~2024-09-18 0:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-01 5:07 CSS behaviors bug report: dark/light switch non-functional Robin H. Johnson
2024-09-18 0:04 ` Eric Wong [this message]
2024-09-26 0:55 ` [PATCH 0/5] css improvements (hopefully) Eric Wong
2024-09-26 0:55 ` [PATCH 1/5] user_content: simplify internal API and use v5.12 Eric Wong
2024-09-26 0:55 ` [PATCH 2/5] www: don't reread CSS files Eric Wong
2024-09-26 0:55 ` [PATCH 3/5] www: load CSS files in same dir if @import is in use Eric Wong
2024-09-26 0:55 ` [PATCH 4/5] www: allow specifying CSS @import or <link> tags Eric Wong
2024-09-26 18:34 ` Štěpán Němec
2024-09-28 18:39 ` [PATCH v2] " Eric Wong
2024-09-28 19:29 ` Štěpán Němec
2024-09-28 20:42 ` Eric Wong
2024-09-29 0:22 ` Eric Wong
2024-09-26 0:55 ` [PATCH 5/5] www: use mtime as CSS cache-buster instead of ctime Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240918000457.M692185@dcvr \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
--cc=robbat2@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).