Skip to content

Commit 577e540

Browse files
committed
Added dark/light favicons and switching based on theme
1 parent 1d12632 commit 577e540

3 files changed

Lines changed: 68 additions & 1 deletion

File tree

public/dark-favicon.svg

Lines changed: 27 additions & 0 deletions
Loading

public/index.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
manifest.json provides metadata used when your web app is added to the
99
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
1010
-->
11-
<link rel="shortcut icon" href="./favicon.svg">
1211
<!--
1312
Notice the use of %PUBLIC_URL% in the tags above.
1413
It will be replaced with the URL of the `public` folder during the build.
@@ -42,6 +41,20 @@
4241
if((window.location.search || '').includes('origin=openmrs')) {
4342
window.location = '/#/search/?origin=openmrs&type=organizations'
4443
}
44+
45+
const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)');
46+
47+
if (prefersDarkMode.matches) {
48+
const darkFavicon = document.createElement('link');
49+
darkFavicon.rel = 'icon';
50+
darkFavicon.href = './dark-favicon.svg';
51+
document.head.appendChild(darkFavicon);
52+
} else {
53+
const lightFavicon = document.createElement('link');
54+
lightFavicon.rel = 'icon';
55+
lightFavicon.href = './light-favicon.svg';
56+
document.head.appendChild(lightFavicon);
57+
}
4558
</script>
4659
<title></title>
4760
</head>

public/light-favicon.svg

Lines changed: 27 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)