diff --git a/package.json b/package.json index b4d234e..7020af4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "data.octoprint.org", - "version": "0.3.1", + "version": "0.3.2", "private": true, "dependencies": { "@emotion/react": "^11.4.1", diff --git a/src/App.js b/src/App.js index e5b92ae..9efe518 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,7 @@ import React from "react"; import useMediaQuery from "@mui/material/useMediaQuery"; -import {createTheme, ThemeProvider} from "@mui/material/styles"; +import {useTheme, createTheme, ThemeProvider} from "@mui/material/styles"; import {styled} from "@mui/material"; import CssBaseline from "@mui/material/CssBaseline"; import Box from "@mui/material/Box"; @@ -9,6 +9,11 @@ import AppBar from "@mui/material/AppBar"; import Toolbar from "@mui/material/Toolbar"; import Container from "@mui/material/Container"; import Link from "@mui/material/Link"; +import Drawer from "@mui/material/Drawer"; +import List from "@mui/material/List"; +import ListItem from "@mui/material/ListItem"; +import ListItemButton from "@mui/material/ListItemButton"; +import ListItemText from "@mui/material/ListItemText"; import DarkModeToggle from "./components/DarkModeToggle"; import DaysToggle from "./components/DaysToggle"; @@ -60,14 +65,43 @@ export default function App(props) { } function Main({darkMode, handleDarkModeToggle}) { + const theme = useTheme(); + + const isSmallScreen = useMediaQuery(theme.breakpoints.down("lg")); + const year = new Date().getFullYear(); + const NavItems = [ + {name: "Instance Stats", link: "#instances"}, + {name: "Printing Stats", link: "#printing"}, + {name: "Python Stats", link: "#python"}, + {name: "Server Stats", link: "#server"}, + {name: "Client Stats", link: "#client"}, + {name: "RPi Stats", link: "#rpi"}, + {name: "Firmware Stats", link: "#firmware"}, + {name: "Achievement Stats", link: "#achievements"} + ]; + + const DrawerList = ( + + + {NavItems.map((item, index) => ( + + + + + + ))} + + + ); + const Navbar = () => { return ( - + theme.zIndex.drawer + 1}}> - - data.octoprint.org + + {!isSmallScreen ? "data.octoprint.org" : " "} @@ -80,11 +114,21 @@ function Main({darkMode, handleDarkModeToggle}) { <> + {!isSmallScreen && ( + + + {DrawerList} + + )} *": {my: 2}}} + sx={{ + "mt": {lg: 4}, + "mb": 4, + "& > *": {my: 2} + }} > diff --git a/src/components/Stats.js b/src/components/Stats.js index cbfff8d..8732af5 100644 --- a/src/components/Stats.js +++ b/src/components/Stats.js @@ -1,16 +1,19 @@ -import React, { useState, useEffect } from "react"; -import CircularProgress from '@mui/material/CircularProgress'; -import Card from '@mui/material/Card'; -import CardHeader from '@mui/material/CardHeader'; -import CardContent from '@mui/material/CardContent'; +import React, {useState, useEffect} from "react"; +import CircularProgress from "@mui/material/CircularProgress"; +import Card from "@mui/material/Card"; +import CardHeader from "@mui/material/CardHeader"; +import CardContent from "@mui/material/CardContent"; +import {useTheme} from "@mui/material/styles"; import fetchStats from "../util/data"; -import { Typography } from "@mui/material"; +import {Typography} from "@mui/material"; export default function Stats(props) { - const [ loading, setLoading ] = useState(true); - const [ since, setSince ] = useState(); - const [ lastUpdate, setLastUpdate ] = useState(); + const theme = useTheme(); + + const [loading, setLoading] = useState(true); + const [since, setSince] = useState(); + const [lastUpdate, setLastUpdate] = useState(); useEffect(() => { fetchStats(props.stats).then((data) => { @@ -25,26 +28,36 @@ export default function Stats(props) { const Content = () => { if (loading) { return ( -
+
- ) + ); } else { return ( <> {props.children} - Based on usage data from {since} until {lastUpdate} + + Based on usage data from {since} until {lastUpdate} + - ) + ); } - } + }; return ( - + ); -} \ No newline at end of file +}