From f15580b28ae021b549a723847497d6f8252b3eb2 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 9 Jan 2021 01:49:39 -0500 Subject: [PATCH] favicon: Add dark mode support Closes #2538 Works as expected on latest Firefox and Chromium. --- ci/dev/gen_icons.sh | 18 ++++++++++++++++++ src/browser/media/favicon-dark-support.svg | 7 +++++++ src/browser/pages/error.html | 2 +- src/browser/pages/login.html | 2 +- src/browser/pages/vscode.html | 2 +- 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/browser/media/favicon-dark-support.svg diff --git a/ci/dev/gen_icons.sh b/ci/dev/gen_icons.sh index 432b8f62..9d27486d 100755 --- a/ci/dev/gen_icons.sh +++ b/ci/dev/gen_icons.sh @@ -21,6 +21,24 @@ main() { convert -quiet -background transparent -resize 512x512 pwa-icon.png pwa-icon-512.png # We use -quiet above to avoid https://github.com/ImageMagick/ImageMagick/issues/884 + + # The following adds dark mode support for the favicon as favicon-dark-support.svg + # There is no similar capability for pwas or .ico so we can only add support to the svg. + favicon_dark_style="" + # See https://stackoverflow.com/a/22901380/4283659 + # This escapes all newlines so that sed will accept them. + favicon_dark_style="$(printf "%s\n" "$favicon_dark_style" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g')" + sed "$( + cat -n << EOF +s% favicon-dark-support.svg } main "$@" diff --git a/src/browser/media/favicon-dark-support.svg b/src/browser/media/favicon-dark-support.svg new file mode 100644 index 00000000..06f1fa00 --- /dev/null +++ b/src/browser/media/favicon-dark-support.svg @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/src/browser/pages/error.html b/src/browser/pages/error.html index 4d24d85f..73a9599b 100644 --- a/src/browser/pages/error.html +++ b/src/browser/pages/error.html @@ -11,7 +11,7 @@ content="style-src 'self'; manifest-src 'self'; img-src 'self' data:; font-src 'self' data:;" /> {{ERROR_TITLE}} - code-server - + diff --git a/src/browser/pages/login.html b/src/browser/pages/login.html index 9f74b296..ef3f16a4 100644 --- a/src/browser/pages/login.html +++ b/src/browser/pages/login.html @@ -11,7 +11,7 @@ content="style-src 'self'; script-src 'self' 'unsafe-inline'; manifest-src 'self'; img-src 'self' data:; font-src 'self' data:;" /> code-server login - + diff --git a/src/browser/pages/vscode.html b/src/browser/pages/vscode.html index c46cb47a..ef61fa5e 100644 --- a/src/browser/pages/vscode.html +++ b/src/browser/pages/vscode.html @@ -24,7 +24,7 @@ - +