Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dark mode button #38

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions who-metrics-ui/src/components/DarkModeButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use client";

Check warning

Code scanning / CodeQL

Unknown directive

Unknown directive: 'use client'.

import { useTheme } from "next-themes";
import { IconButton, useTheme as primerUseTheme } from "@primer/react";
import { MoonIcon, SunIcon } from "@primer/octicons-react";

const DarkModeButton = () => {
const { theme, setTheme } = useTheme();
const { setColorMode } = primerUseTheme();

const setThemePage = () => {
if (theme === "dark") {
setTheme("light");
setColorMode("light");
} else {
setTheme("dark");
setColorMode("dark");
}
};
return (
<IconButton
icon={theme === "dark" ? SunIcon : MoonIcon}
aria-label="Default"
sx={{ marginLeft: "auto" }}
onClick={setThemePage}
/>
);
};

export default DarkModeButton;
33 changes: 0 additions & 33 deletions who-metrics-ui/src/components/DarkModeToggle.tsx

This file was deleted.

19 changes: 15 additions & 4 deletions who-metrics-ui/src/components/DashboardExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ChartView } from "./";

import KpiCard from "./KpiCard";
import { PerformanceHistoryTable } from "./PerformanceHistoryTable";
import DarkModeButton from "./DarkModeButton";

type Kpi = {
title: string;
Expand Down Expand Up @@ -109,10 +110,20 @@ export const DashboardExample = () => {
</Box>
<Text>Lorem ipsum dolor sit amet, consetetur sadipscing elitr.</Text>
<TabGroup className="mt-6">
<TabList>
<Tab>Overview</Tab>
<Tab>Detail</Tab>
</TabList>
<Box
sx={{
display: "flex",
flexDirection: "row",
alignItems: "center",
gap: 2,
}}
>
<TabList>
<Tab>Overview</Tab>
<Tab>Detail</Tab>
</TabList>
<DarkModeButton />
</Box>
<TabPanels>
<TabPanel>
<Grid numItemsLg={3} className="mt-6 gap-6">
Expand Down