Skip to content

Commit

Permalink
Merge pull request #111 from mlomb/light-favicon
Browse files Browse the repository at this point in the history
Light mode favicon
  • Loading branch information
mlomb authored May 30, 2024
2 parents 557ab64 + 19e9bf9 commit 2419ab3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createRoot } from "react-dom/client";

import { HomePage } from "@app/HomePage";

import "@assets/Favicon";
import { plausible } from "@assets/Plausible";

createRoot(document.getElementById("app") as HTMLElement).render(
Expand Down
13 changes: 13 additions & 0 deletions assets/Favicon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function prefersDarkColorScheme() {
return window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
}

function updateFavicon() {
const favicon = document.querySelector("link[rel=icon]") as HTMLLinkElement;
const url = "https://chatanalytics.app/";

favicon.href = url + (prefersDarkColorScheme() ? "favicon-dark.png" : "favicon.png");
}

updateFavicon();
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => updateFavicon());
Binary file added assets/public/favicon-dark.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 assets/public/favicon.ico
Binary file not shown.
Binary file modified assets/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Chat analysis report generated with chatanalytics.app">
<link rel="shortcut icon" href="https://chatanalytics.app/favicon.png">
<link rel="icon" href="https://chatanalytics.app/favicon.png">
<link rel="preconnect" href="https://p.chatanalytics.app">
<title>[[TITLE]]</title>
<script type="text/plain" id="data">[[[DATA]]]</script>
Expand Down
1 change: 1 addition & 0 deletions report/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { initBlockStore } from "@report/BlockStore";
import ReportPage from "@report/ReportPage";
import { initWorker } from "@report/WorkerWrapper";

import "@assets/Favicon";
import { plausible } from "@assets/Plausible";

document.addEventListener("DOMContentLoaded", async () => {
Expand Down

0 comments on commit 2419ab3

Please sign in to comment.