-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
prefers-color-scheme
for custom panel favicons
#5657
prefers-color-scheme
for custom panel favicons
#5657
Conversation
200b3a9
to
fc63ba7
Compare
ee91595
to
8fe6e0a
Compare
Is it correct that the apple-touch-icon in light has a solid background but in dark is transparent? |
That's correct. Feel free to replace images π |
I have no understanding of these things, so I won't touch anything. It just seemed odd to me that one time it needs a solid fill, then in fair transparency. |
My feeling is that the transparent background makes sense for the |
I've tested on my Macbook. Favicon working but @grommasdietz could you also test this PR, please? Download kirby.zip, replace |
64a5fb3
to
f4fa14e
Compare
Neither the favicon nor the So it looks like Safari on macOS and iOS don't respect the |
At least we can keep this PR structure without dark-mode for the future. What do you think @lukasbestle ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, the refactoring by itself is already pretty nice.
But maybe we can also get the dark-mode icons working with @grommasdietz's help.
Thanks for all of your work. Iβm currently in vacation, but had a quick look. Only tested locally with valet on a project so far, it seems that Safari's cache could be a root of the problem. After switching the OS color scheme and clearing Safari's cache it works for me on version 16.6 (18615.3.12.11.2) as well as 17.0 (18617.1.8.1) with this order: <link rel="apple-touch-icon" href="/assets/icons/dark/apple-touch-icon.png">
<link rel="icon" href="/assets/icons/dark/favicon.ico" sizes="any">
<link rel="apple-touch-icon" href="/assets/icons/light/apple-touch-icon.png" media="(prefers-color-scheme: dark)">
<link rel="icon" href="/assets/icons/light/favicon.ico" sizes="any" media="(prefers-color-scheme: dark)">
<link rel="icon" href="data:image/svg+xml,%3Csvg%20viewBoxβ¦" type="image/svg+xml"> Iβll investigate further next week back in the office with a deeper look into your PR. |
I have tried that exact order, unfortunately that always gives me the light images, even after clearing the cache on macOS/deleting website data on iOS. Enjoy your vacation, it's not urgent at all. |
I tested your PR @afbora. Seems to work for me with custom favicons on Safari 17. Declared it like this in the config: return [
'panel' =>[
'favicon' => [
[
'rel' => 'apple-touch-icon',
'type' => 'image/png',
'url' => 'assets/icons/dark/apple-touch-icon.png',
],
[
'rel' => 'alternate icon',
'type' => 'image/x-icon',
'url' => 'assets/icons/dark/favicon.ico',
],
[
'rel' => 'apple-touch-icon',
'type' => 'image/png',
'url' => 'assets/icons/light/apple-touch-icon.png',
'media' => '(prefers-color-scheme: dark)',
],
[
'rel' => 'alternate icon',
'type' => 'image/x-icon',
'url' => 'assets/icons/light/favicon.ico',
'media' => '(prefers-color-scheme: dark)',
],
[
'rel' => 'shortcut icon',
'type' => 'image/svg+xml',
'url' => 'assets/icons/dynamic/icon.svg',
],
],
],
] I actually never use apple-touch-icons actively by myself, but will investigate further, as well on the default icon set. After the current test, it seems to work in a new window, after some time and/or after deleting the cache and reloading multiple times. I donβt know how the caching of favicons works exactly in Safari (maybe unrelated to the rest of the pages, since it is used in the browser UI), but it seems to work somehow and should be fine for the current preferred color scheme without a switch. |
It would be really cool to wrap this up. What's still missing to get it done? |
Co-authored-by: Lukas Bestle <lukas@getkirby.com>
caee67c
to
8772938
Compare
@lukasbestle @afbora Could we add the order in that way that even if a Safari version has issues, for that Safari it would look like the current status quo. But all browser versions without issues would get the benefits from this change? |
It didn't work properly in Safari, so we couldn't move forward. But Safari seems doesn't support SVG link icons anyway: https://caniuse.com/link-icon-svg So I think we can keep PR as it is. |
@afbora but the problem wasn't about the SVG icon, right? It was that Safari would also load the wrong PNG file if I understood @lukasbestle correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I wrote, I think this a pretty great refactoring in itself, even if the prefers-color-scheme
feature does not/would not fully work in Safari. In my tests it at least sometimes worked, so that's at least a massive improvement compared to the status quo.
This PR β¦
Related discussion is here #4691 (comment)
Not sure about images. I've created images from SVG icon π
π Features
prefers-color-scheme
for custom panel faviconsBreaking changes
AFAIK, none. Coded backward compatibility but I would appreciate it if you check it too.
Ready?
For review team