Skip to content

Commit 5300d22

Browse files
committed
add fun sound to topbar
1 parent 92b6f3a commit 5300d22

7 files changed

Lines changed: 40 additions & 4 deletions

File tree

frontend/main/package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/main/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"react-instantsearch-dom": "^6.8.2",
3737
"react-player": "^2.7.2",
3838
"reactfire": "^4.2.0",
39+
"use-sound": "^4.0.1",
3940
"video.js": "^7.11.4"
4041
},
4142
"devDependencies": {
10.6 KB
Binary file not shown.
2.28 KB
Binary file not shown.
1.72 KB
Binary file not shown.

frontend/main/src/components/global/icons/Toggle.tsx renamed to frontend/main/src/components/global/icons/ThemeToggle.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import { useTheme } from 'next-themes';
22
import { useState, useEffect } from 'react';
3+
import useSound from 'use-sound';
34

4-
export default function Toggle(): JSX.Element {
5+
export default function ThemeToggle(): JSX.Element {
56
const [loaded, setLoaded] = useState(false);
67
const { theme, setTheme } = useTheme();
8+
const [dark] = useSound('/static/sounds/switch-off.mp3');
9+
const [light] = useSound('/static/sounds/switch-on.mp3');
710

811
useEffect(() => {
912
setLoaded(true);
1013
}, []);
1114

1215
const toggle = () => {
1316
if (theme !== 'dark') {
17+
dark();
1418
setTheme('dark');
1519
} else {
20+
light();
1621
setTheme('light');
1722
}
1823
};

frontend/main/src/layout/AppTopbar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Dispatch, SetStateAction, useState } from 'react';
22
import Link from 'next/link';
33
import dynamic from 'next/dynamic';
44

5-
import Toggle from '@/components/global/icons/Toggle';
5+
import ThemeToggle from '@/components/global/icons/ThemeToggle';
66

77
import OutsideClick from '@/components/OutsideClick';
88
import AJLogoLeft from '@/components/global/icons/AJAlt';
@@ -25,7 +25,7 @@ export const AppTopbar = (props: {
2525
<header className="flex justify-between w-full h-20 p-4 lg:px-0 lg:mx-auto lg:w-80 lg:max-w-8xl">
2626
<Link href="/">
2727
<a>
28-
<div className="flex items-center content-center shrink-0 h-full">
28+
<div className="flex items-center content-center h-full shrink-0">
2929
<AJLogoLeft />
3030
<h2 className="hidden text-2xl text-basics-50 lg:block">
3131
CodingCat.dev
@@ -36,7 +36,7 @@ export const AppTopbar = (props: {
3636
{/* <div className="flex justify-between h-16"> */}
3737
<NavLinks />
3838

39-
<Toggle />
39+
<ThemeToggle />
4040
<div className="flex items-center justify-end">
4141
<div className="flex items-center w-full space-x-2">
4242
<SearchModal />

0 commit comments

Comments
 (0)