Added a saved settings system that uses localstorage and versioning

This commit is contained in:
Mitchell McCaffrey
2020-08-07 17:15:16 +10:00
parent e702936c44
commit 602631f9b1
11 changed files with 205 additions and 65 deletions

View File

@@ -1,10 +1,12 @@
import React, { useState, useRef } from "react";
import React, { useRef } from "react";
import { Box, Label, Input, Button, Flex, Text } from "theme-ui";
import Modal from "../components/Modal";
import { getHMSDuration, getDurationHMS } from "../helpers/timer";
import useSetting from "../helpers/useSetting";
function StartTimerModal({
isOpen,
onRequestClose,
@@ -17,9 +19,9 @@ function StartTimerModal({
inputRef.current && inputRef.current.focus();
}
const [hour, setHour] = useState(0);
const [minute, setMinute] = useState(0);
const [second, setSecond] = useState(0);
const [hour, setHour] = useSetting("timer.hour");
const [minute, setMinute] = useSetting("timer.minute");
const [second, setSecond] = useSetting("timer.second");
function handleSubmit(event) {
event.preventDefault();