Skip to content

Commit 12dc473

Browse files
committed
system theme favicon
1 parent 1b4a7ab commit 12dc473

File tree

8 files changed

+13
-1
lines changed

8 files changed

+13
-1
lines changed

pages/_app.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@ import '../styles/globals.css';
33
import { Header } from '../components';
44
import SEO from '@bradgarropy/next-seo';
55
import { motion } from 'framer-motion';
6+
import { useEffect, useState } from 'react';
67

78
function MyApp({ Component, pageProps, router }) {
9+
const [favicon, setFavicon] = useState("/faviconLight.ico");
10+
const changeFavicon = () => {
11+
const isDark = window.matchMedia("(prefers-color-scheme: dark)");
12+
if (!isDark.matches)
13+
return setFavicon("/faviconDark.ico");
14+
};
15+
16+
useEffect(() => {
17+
changeFavicon();
18+
}, []);
819
return (
920
<motion.div
1021
key={router.route}
@@ -22,7 +33,7 @@ function MyApp({ Component, pageProps, router }) {
2233
<SEO
2334
title="Web APIs Playground - Create, Share, Learn JavaScript Web APIs"
2435
description="The Web APIs Playground is a project to showcase the JavaScript Web APIs with examples and demonstrations. Client-side JavaScript APIs provides wrapper functions for many low-level tasks."
25-
icon="/favicon2.ico"
36+
icon={favicon}
2637
keywords={[
2738
'javascript',
2839
'web apis',

public/assets/Logo.png

-28.5 KB
Binary file not shown.

public/assets/png/faviconDark.png

22.2 KB
Loading

public/assets/png/faviconLight.png

20.5 KB
Loading
File renamed without changes.

public/assets/svg/logoLight.svg

Lines changed: 1 addition & 0 deletions
Loading

public/faviconDark.ico

218 KB
Binary file not shown.

public/faviconLight.ico

218 KB
Binary file not shown.

0 commit comments

Comments
 (0)