Merge pull request #69 from Pinjasaur/dark-theme

feat: dark theme
This commit is contained in:
Zef Hemel
2022-08-27 11:13:14 +02:00
committed by GitHub
5 changed files with 67 additions and 2 deletions
+17 -1
View File
@@ -1,5 +1,6 @@
import { faRunning, faHome } from "@fortawesome/free-solid-svg-icons";
import { faRunning, faHome, faSun, faMoon } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useEffect, useState } from "react";
import { Notification } from "../types";
function prettyName(s: string | undefined): string {
@@ -14,6 +15,7 @@ export function TopBar({
unsavedChanges,
notifications,
onClick,
onThemeClick,
onHomeClick,
onActionClick,
lhs,
@@ -23,11 +25,15 @@ export function TopBar({
unsavedChanges: boolean;
notifications: Notification[];
onClick: () => void;
onThemeClick: () => void;
onHomeClick: () => void;
onActionClick: () => void;
lhs?: React.ReactNode;
rhs?: React.ReactNode;
}) {
const [theme, setTheme] = useState<string>(localStorage.theme ?? 'light');
return (
<div id="sb-top" onClick={onClick}>
{lhs}
@@ -71,6 +77,16 @@ export function TopBar({
>
<FontAwesomeIcon icon={faRunning} />
</button>
<button
onClick={(e) => {
onThemeClick();
setTheme(localStorage.theme ?? 'light');
e.stopPropagation();
}}
title="Toggle theme"
>
<FontAwesomeIcon icon={theme === 'dark' ? faSun : faMoon} />
</button>
</div>
</div>
</div>