Skip to content

Commit

Permalink
Adding dark-mode favicon capability and images
Browse files Browse the repository at this point in the history
Resolves #924

Our current theme inherits from docsy and the favicons are generates from the following template:
https://github.com/google/docsy/blob/1d126ab1bbf186fa0ea52a6d6a3f58229b2b7942/layouts/partials/favicons.html

This changes adds a new favicon layout to override the base. The new layout is the same as the base, but adds the media attribute to supply browsers with light/dark options should they choose to respect it.

White color images are included for all sizes for the dark option.
  • Loading branch information
Craig Landry committed Dec 22, 2022
1 parent 1641f05 commit 7435dd7
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions layouts/partials/favicons.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- regular/light mode -->
<link rel="shortcut icon" media="(prefers-color-scheme: light)" href="{{ "favicons/favicon.ico" | relURL }}" >
<link rel="apple-touch-icon" media="(prefers-color-scheme: light)" href="{{ "favicons/apple-touch-icon-180x180.png" | relURL }}" sizes="180x180">
<link rel="icon" media="(prefers-color-scheme: light)" type="image/png" href="{{ "favicons/favicon-16x16.png" | relURL }}" sizes="16x16">
<link rel="icon" media="(prefers-color-scheme: light)" type="image/png" href="{{ "favicons/favicon-32x32.png" | relURL }}" sizes="32x32">
<link rel="icon" media="(prefers-color-scheme: light)" type="image/png" href="{{ "favicons/android-36x36.png" | relURL }}" sizes="36x36">
<link rel="icon" media="(prefers-color-scheme: light)" type="image/png" href="{{ "favicons/android-48x48.png" | relURL }}" sizes="48x48">
<link rel="icon" media="(prefers-color-scheme: light)" type="image/png" href="{{ "favicons/android-72x72.png" | relURL }}" sizes="72x72">
<link rel="icon" media="(prefers-color-scheme: light)" type="image/png" href="{{ "favicons/android-96x96.png" | relURL }}" sizes="96x96">
<link rel="icon" media="(prefers-color-scheme: light)" type="image/png" href="{{ "favicons/android-144x144.png" | relURL }}" sizes="144x144">
<link rel="icon" media="(prefers-color-scheme: light)" type="image/png" href="{{ "favicons/android-192x192.png" | relURL }}" sizes="192x192">

<!-- dark mode -->
<link rel="shortcut icon" media="(prefers-color-scheme: dark)" href="{{ "favicons/favicon-dark.ico" | relURL }}" >
<link rel="apple-touch-icon" media="(prefers-color-scheme: dark)" href="{{ "favicons/apple-touch-icon-dark-180x180.png" | relURL }}" sizes="180x180">
<link rel="icon" media="(prefers-color-scheme: dark)" type="image/png" href="{{ "favicons/favicon-dark-16x16.png" | relURL }}" sizes="16x16">
<link rel="icon" media="(prefers-color-scheme: dark)" type="image/png" href="{{ "favicons/favicon-dark-32x32.png" | relURL }}" sizes="32x32">
<link rel="icon" media="(prefers-color-scheme: dark)" type="image/png" href="{{ "favicons/android-dark-36x36.png" | relURL }}" sizes="36x36">
<link rel="icon" media="(prefers-color-scheme: dark)" type="image/png" href="{{ "favicons/android-dark-48x48.png" | relURL }}" sizes="48x48">
<link rel="icon" media="(prefers-color-scheme: dark)" type="image/png" href="{{ "favicons/android-dark-72x72.png" | relURL }}" sizes="72x72">
<link rel="icon" media="(prefers-color-scheme: dark)" type="image/png" href="{{ "favicons/android-dark-96x96.png" | relURL }}" sizes="96x96">
<link rel="icon" media="(prefers-color-scheme: dark)" type="image/png" href="{{ "favicons/android-dark-144x144.png" | relURL }}" sizes="144x144">
<link rel="icon" media="(prefers-color-scheme: dark)" type="image/png" href="{{ "favicons/android-dark-192x192.png" | relURL }}" sizes="192x192">
Binary file added static/favicons/android-dark-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicons/android-dark-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicons/android-dark-36x36.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicons/android-dark-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicons/android-dark-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicons/android-dark-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicons/apple-touch-icon-dark-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicons/favicon-dark-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicons/favicon-dark-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/favicons/favicon-dark.ico
Binary file not shown.

0 comments on commit 7435dd7

Please sign in to comment.