Skip to content

Commit

Permalink
Merge pull request #12 from aldbr/main_add-dark-mode
Browse files Browse the repository at this point in the history
feat: add dark mode
  • Loading branch information
chrisburr authored Oct 18, 2023
2 parents 30bab2b + 257d000 commit 4fd77ae
Show file tree
Hide file tree
Showing 22 changed files with 555 additions and 170 deletions.
9 changes: 2 additions & 7 deletions src/app/dashboard/jobmonitor/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { JobDataGrid } from "@/components/data/JobDataGrid";
import JobMonitor from "@/components/applications/JobMonitor";

export default async function Page() {
return (
<div style={{ width: "100%", height: 400 }}>
<h2>Job Monitor</h2>
<JobDataGrid />
</div>
);
return <JobMonitor />;
}
8 changes: 3 additions & 5 deletions src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import UserDashboard from "@/components/applications/UserDashboard";

export default function Page() {
return (
<div>
<span>Hello User</span>
</div>
);
return <UserDashboard />;
}
23 changes: 0 additions & 23 deletions src/app/globals.css
Original file line number Diff line number Diff line change
@@ -1,23 +0,0 @@
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 255, 255, 255;
--background-end-rgb: 255, 255, 255;
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}
6 changes: 4 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./globals.css";
import { Inter } from "next/font/google";
import { OIDCProvider } from "@/components/auth/OIDCUtils";
import { ThemeProvider } from "@/contexts/ThemeProvider";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -21,7 +21,9 @@ export default function RootLayout({
return (
<html lang="en">
<body className={inter.className}>
<OIDCProvider>{children}</OIDCProvider>
<OIDCProvider>
<ThemeProvider>{children}</ThemeProvider>
</OIDCProvider>
</body>
</html>
);
Expand Down
32 changes: 32 additions & 0 deletions src/components/applications/JobMonitor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";
import * as React from "react";
import CssBaseline from "@mui/material/CssBaseline";
import { Box } from "@mui/material";
import { useMUITheme } from "@/hooks/theme";
import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles";
import { JobDataGrid } from "../ui/JobDataGrid";

/**
* Build the Job Monitor application
* @returns Job Monitor content
*/
export default function JobMonitor() {
const theme = useMUITheme();

return (
<React.Fragment>
<MUIThemeProvider theme={theme}>
<CssBaseline />
<Box
sx={{
ml: "5%",
mr: "5%",
}}
>
<h2>Job Monitor</h2>
<JobDataGrid />
</Box>
</MUIThemeProvider>
</React.Fragment>
);
}
32 changes: 32 additions & 0 deletions src/components/applications/UserDashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";
import * as React from "react";
import CssBaseline from "@mui/material/CssBaseline";
import { Box } from "@mui/material";
import { useMUITheme } from "@/hooks/theme";
import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles";
import { useOidcAccessToken } from "@axa-fr/react-oidc";

/**
* Build the User Dashboard page
* @returns User Dashboard content
*/
export default function UserDashboard() {
const theme = useMUITheme();
const { accessTokenPayload } = useOidcAccessToken();

return (
<React.Fragment>
<MUIThemeProvider theme={theme}>
<CssBaseline />
<Box
sx={{
ml: "5%",
mr: "5%",
}}
>
<span>Hello {accessTokenPayload["preferred_username"]}</span>
</Box>
</MUIThemeProvider>
</React.Fragment>
);
}
120 changes: 64 additions & 56 deletions src/components/layout/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import Toolbar from "@mui/material/Toolbar";
import Stack from "@mui/material/Stack";
import { LoginButton } from "../ui/LoginButton";
import DashboardDrawer from "../ui/DashboardDrawer";
import { useMUITheme } from "@/hooks/theme";
import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles";
import { ThemeToggleButton } from "../ui/ThemeToggleButton";

interface DashboardProps {
children: React.ReactNode;
Expand All @@ -22,6 +25,7 @@ interface DashboardProps {
* @return an dashboard layout
*/
export default function Dashboard(props: DashboardProps) {
const theme = useMUITheme();
/** State management for mobile drawer */
const [mobileOpen, setMobileOpen] = React.useState(false);
const handleDrawerToggle = () => {
Expand All @@ -34,66 +38,70 @@ export default function Dashboard(props: DashboardProps) {
return (
<Box sx={{ display: "flex" }}>
<CssBaseline />
<AppBar
position="fixed"
elevation={0}
sx={{
width: { sm: `calc(100% - ${drawerWidth}px)` },
ml: { sm: `${drawerWidth}px` },
bgcolor: "white",
}}
>
<Stack direction="row">
<Toolbar>
<IconButton
aria-label="open drawer"
edge="start"
onClick={handleDrawerToggle}
sx={{ mr: 2, display: { sm: "none" } }}
data-testid="drawer-toggle-button"
<MUIThemeProvider theme={theme}>
<AppBar
position="fixed"
elevation={0}
sx={{
width: { sm: `calc(100% - ${drawerWidth}px)` },
ml: { sm: `${drawerWidth}px` },
}}
>
<Stack direction="row">
<Toolbar>
<IconButton
aria-label="open drawer"
edge="start"
onClick={handleDrawerToggle}
sx={{ mr: 2, display: { sm: "none" } }}
data-testid="drawer-toggle-button"
>
<MenuIcon />
</IconButton>
</Toolbar>
<Toolbar
sx={{
justifyContent: "space-between",
flexGrow: 1,
}}
>
<MenuIcon />
</IconButton>
</Toolbar>
<Toolbar
sx={{
justifyContent: "space-between",
flexGrow: 1,
}}
>
<div />
<LoginButton />
</Toolbar>
</Stack>
</AppBar>
<Box
component="nav"
sx={{ width: { sm: drawerWidth }, flexShrink: { sm: 0 } }}
aria-label="side bar"
>
{/* Here two types of drawers are rendered:
<div />
<Stack direction="row">
<ThemeToggleButton />
<LoginButton />
</Stack>
</Toolbar>
</Stack>
</AppBar>
<Box
component="nav"
sx={{ width: { sm: drawerWidth }, flexShrink: { sm: 0 } }}
aria-label="side bar"
>
{/* Here two types of drawers are rendered:
1. Temporary drawer: Visible on small screens (xs) and is collapsible.
2. Permanent drawer: Visible on larger screens (sm) and stays fixed.
Depending on the screen size, only one will be visible at a time. */}
<DashboardDrawer
variant="temporary"
mobileOpen={mobileOpen}
width={drawerWidth}
handleDrawerToggle={handleDrawerToggle}
/>
<DashboardDrawer
variant="permanent"
mobileOpen={mobileOpen}
width={drawerWidth}
handleDrawerToggle={handleDrawerToggle}
/>
</Box>
<Box
component="main"
sx={{ pt: 10, px: 3, width: { sm: `calc(100% - ${drawerWidth}px)` } }}
>
{props.children}
</Box>
<DashboardDrawer
variant="temporary"
mobileOpen={mobileOpen}
width={drawerWidth}
handleDrawerToggle={handleDrawerToggle}
/>
<DashboardDrawer
variant="permanent"
mobileOpen={mobileOpen}
width={drawerWidth}
handleDrawerToggle={handleDrawerToggle}
/>
</Box>
<Box
component="main"
sx={{ pt: 10, px: 3, width: { sm: `calc(100% - ${drawerWidth}px)` } }}
>
{props.children}
</Box>
</MUIThemeProvider>
</Box>
);
}
Loading

0 comments on commit 4fd77ae

Please sign in to comment.