1
0

feat: dark theme

This commit is contained in:
Paul Esch-Laurent
2022-08-26 17:32:40 -05:00
parent 1e274a81cc
commit bbbf5cc26d
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>