Skip to content

Commit

Permalink
updated favicon and logo according to current theme
Browse files Browse the repository at this point in the history
  • Loading branch information
novcmbro committed Jun 6, 2024
1 parent 7661ce9 commit 12698ef
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
8 changes: 3 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
<meta name="author" content="Novcmbro">
<meta name="robots" content="index, follow">
<!-- Favicon -->
<link rel="icon" href="public/favicon-light.svg" type="image/svg" media="(prefers-color-scheme: dark)">
<link rel="icon" href="public/favicon-dark.svg" type="image/svg" media="(prefers-color-scheme: light)">
<link rel="shortcut icon" href="public/favicon-light.svg" type="image/svg" media="(prefers-color-scheme: dark)">
<link rel="shortcut icon" href="public/favicon-dark.svg" type="image/svg" media="(prefers-color-scheme: light)">
<link rel="icon" name="favicon" href="public/favicon-light.svg" type="image/svg">
<link rel="shortcut icon" name="favicon" href="public/favicon-light.svg" type="image/svg">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:title" name="title" content="Decoder">
Expand Down Expand Up @@ -44,7 +42,7 @@
</head>
<body>
<header>
<img src="src/img/decoder-logo.png" alt="Decoder logo" class="logo" role="img">
<img id="logo" src="src/img/decoder-logo-light.png" alt="Decoder logo" class="logo" role="img">
</header>
<main class="container">
<section class="input-section" aria-labelledby="input-label">
Expand Down
Binary file added src/img/decoder-logo-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 src/img/decoder-logo-light.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 removed src/img/decoder-logo.png
Binary file not shown.
5 changes: 5 additions & 0 deletions src/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ const theme = {
theme.preferred = () => prefersLightTheme.matches ? "light" : "dark"

theme.update = () => {
const updateURL = (element) => theme.name() === "light" ? element.replace("dark", "light") : element.replace("light", "dark")

document.querySelectorAll("[name='favicon']").forEach(favicon => favicon.href = updateURL(favicon.href))
rootElement.classList.toggle("light", theme.name() === "light")
rootElement.classList.toggle("dark", theme.name() === "dark")
const logo = document.querySelector("#logo")
logo.src = updateURL(logo.src)
}

theme.init = () => {
Expand Down

0 comments on commit 12698ef

Please sign in to comment.