diff --git a/index.html b/index.html index 7ee9b0a..8b53bb5 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,10 @@ + + + + Vite + React + TS diff --git a/src/App.tsx b/src/App.tsx index 213d3ee..18e3896 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,9 +1,12 @@ import { useCallback, useState } from "react"; -import { Paper, Tooltip, FormControlLabel, Checkbox, - Typography, LinearProgress, Button, Box } from "@mui/material"; +import { Paper, Tooltip, FormControlLabel, Checkbox, Dialog, DialogActions, + DialogContent, DialogContentText, DialogTitle, Typography, LinearProgress, + Button, useMediaQuery, Box } from "@mui/material"; -import { basicList, storage_key, total_percent } from ":src/constants"; +import { useTheme } from '@mui/material/styles'; + +import { basicList, storage_key, tooptip_offset, total_percent } from ":src/constants"; import "./App.scss"; @@ -32,34 +35,57 @@ const calcProgress = (tasks: Task[]) => { export default function App(): JSX.Element { const [tasks, setTasks] = useState(saved_tasks ? JSON.parse(saved_tasks) : initialTasks); const [progress, setProgress] = useState(calcProgress(tasks)); - + const [open, setOpen] = useState(false); + const theme = useTheme(); + const fullScreen = useMediaQuery(theme.breakpoints.down('md')); + const updateTasks = (newTasks: Task[]) => { localStorage.setItem(storage_key, JSON.stringify(newTasks)); setTasks(newTasks); setProgress(calcProgress(newTasks)); } - const toggleTask = (index: number) => { + const toggleTask = useCallback((index: number) => { const newTasks = [...tasks]; newTasks[index] = {...newTasks[index], checked: !newTasks[index].checked}; updateTasks(newTasks); - }; + }, [tasks]); - const restartHandler = useCallback(() => { + const handleRestart = useCallback(() => { const newTasks = initialTasks; updateTasks(newTasks); + setOpen(false); }, []); + const handleDialogOpen = () => { + setOpen(true); + }; + + const handleDialogClose = () => { + setOpen(false); + }; + return ( <> -
+ Sia* -
+
@@ -77,10 +103,33 @@ export default function App(): JSX.Element { /> ))} - - + + + + + Good morning, dear! + + + + Are you ready to start a new day? + + + + + + + ); } \ No newline at end of file diff --git a/src/constants.ts b/src/constants.ts index 2a0c54e..6a79967 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,3 +1,4 @@ +/*eslint no-magic-numbers: "off"*/ export const basicList = [ "Open to-do list", "Make a bed", @@ -24,7 +25,9 @@ export const basicList = [ "Dinner", "Wash dishes", "Brush teeth before bed", + "Put phone to charge", "23:00 - go to sleep", ]; export const storage_key = "SIA_TASKS_STATE"; -export const total_percent = 100; \ No newline at end of file +export const total_percent = 100; +export const tooptip_offset = [45, -10]; \ No newline at end of file