diff --git a/src/components/map/Map.js b/src/components/map/Map.js
index 6507b3a..858aaca 100644
--- a/src/components/map/Map.js
+++ b/src/components/map/Map.js
@@ -153,7 +153,6 @@ function Map({
disabledControls.push("pan");
disabledControls.push("measure");
disabledControls.push("pointer");
- disabledControls.push("timer");
}
if (!allowFogDrawing) {
disabledControls.push("fog");
diff --git a/src/components/map/MapControls.js b/src/components/map/MapControls.js
index 80c83e3..ca46ae1 100644
--- a/src/components/map/MapControls.js
+++ b/src/components/map/MapControls.js
@@ -9,7 +9,6 @@ import SelectMapButton from "./SelectMapButton";
import FogToolSettings from "./controls/FogToolSettings";
import DrawingToolSettings from "./controls/DrawingToolSettings";
import MeasureToolSettings from "./controls/MeasureToolSettings";
-import TimerToolSettings from "./controls/TimerToolSettings";
import PanToolIcon from "../../icons/PanToolIcon";
import FogToolIcon from "../../icons/FogToolIcon";
@@ -17,7 +16,6 @@ import BrushToolIcon from "../../icons/BrushToolIcon";
import MeasureToolIcon from "../../icons/MeasureToolIcon";
import ExpandMoreIcon from "../../icons/ExpandMoreIcon";
import PointerToolIcon from "../../icons/PointerToolIcon";
-import TimerToolIcon from "../../icons/TimerToolIcon";
function MapContols({
onMapChange,
@@ -63,14 +61,8 @@ function MapContols({
icon: ,
title: "Pointer Tool",
},
- timer: {
- id: "timer",
- icon: ,
- title: "Timer Tool",
- SettingsComponent: TimerToolSettings,
- },
};
- const tools = ["pan", "fog", "drawing", "measure", "pointer", "timer"];
+ const tools = ["pan", "fog", "drawing", "measure", "pointer"];
const sections = [
{
diff --git a/src/components/map/controls/TimerToolSettings.js b/src/components/map/controls/TimerToolSettings.js
deleted file mode 100644
index d7d25f0..0000000
--- a/src/components/map/controls/TimerToolSettings.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import React, { useEffect, useContext } from "react";
-import { Flex, Input, Text, IconButton } from "theme-ui";
-
-import Divider from "../../Divider";
-
-import MapInteractionContext from "../../../contexts/MapInteractionContext";
-import TimerStartIcon from "../../../icons/TimerStartIcon";
-
-function MeasureToolSettings({ settings, onSettingChange, onToolAction }) {
- const { interactionEmitter } = useContext(MapInteractionContext);
-
- // Keyboard shortcuts
- useEffect(() => {
- function handleKeyDown({ key }) {}
- interactionEmitter.on("keyDown", handleKeyDown);
-
- return () => {
- interactionEmitter.off("keyDown", handleKeyDown);
- };
- });
-
- const inputStyle = {
- width: "40px",
- border: "none",
- ":focus": {
- outline: "none",
- },
- lineHeight: 1.2,
- padding: 1,
- paddingRight: 0,
- };
-
- return (
-
-
- h:
-
- onSettingChange({ hour: parseInt(e.target.value) })}
- type="number"
- min={0}
- max={99}
- />
-
- m:
-
- onSettingChange({ minute: parseInt(e.target.value) })}
- type="number"
- min={0}
- max={59}
- />
-
- s:
-
- onSettingChange({ second: parseInt(e.target.value) })}
- type="number"
- min={0}
- max={59}
- />
- onToolAction("timerStart")}
- disabled={
- settings.hour === 0 && settings.minute === 0 && settings.second === 0
- }
- >
-
-
-
- );
-}
-
-export default MeasureToolSettings;
diff --git a/src/components/party/Party.js b/src/components/party/Party.js
index e2c436d..1caeb36 100644
--- a/src/components/party/Party.js
+++ b/src/components/party/Party.js
@@ -6,6 +6,7 @@ import Nickname from "./Nickname";
import ChangeNicknameButton from "./ChangeNicknameButton";
import StartStreamButton from "./StartStreamButton";
import SettingsButton from "../SettingsButton";
+import StartTimerButton from "./StartTimerButton";
function Party({
nickname,
@@ -16,6 +17,8 @@ function Party({
partyStreams,
onStreamStart,
onStreamEnd,
+ onTimerStart,
+ onTimerEnd,
}) {
return (
+
diff --git a/src/components/party/StartTimerButton.js b/src/components/party/StartTimerButton.js
new file mode 100644
index 0000000..2782647
--- /dev/null
+++ b/src/components/party/StartTimerButton.js
@@ -0,0 +1,32 @@
+import React, { useState } from "react";
+import { IconButton } from "theme-ui";
+
+import StartTimerModal from "../../modals/StartTimerModal";
+import StartTimerIcon from "../../icons/StartTimerIcon";
+
+function StartTimerButton() {
+ const [isTimerModalOpen, setIsTimerModalOpen] = useState(false);
+
+ function openModal() {
+ setIsTimerModalOpen(true);
+ }
+ function closeModal() {
+ setIsTimerModalOpen(false);
+ }
+
+ return (
+ <>
+
+
+
+
+ >
+ );
+}
+
+export default StartTimerButton;
diff --git a/src/icons/TimerToolIcon.js b/src/icons/StartTimerIcon.js
similarity index 89%
rename from src/icons/TimerToolIcon.js
rename to src/icons/StartTimerIcon.js
index a6c6e9c..3edbe8e 100644
--- a/src/icons/TimerToolIcon.js
+++ b/src/icons/StartTimerIcon.js
@@ -1,6 +1,6 @@
import React from "react";
-function TimerToolIcon() {
+function StartTimerIcon() {
return (
- );
-}
-
-export default TimerStartIcon;
diff --git a/src/modals/StartTimerModal.js b/src/modals/StartTimerModal.js
new file mode 100644
index 0000000..1af6c55
--- /dev/null
+++ b/src/modals/StartTimerModal.js
@@ -0,0 +1,106 @@
+import React, { useState, useRef } from "react";
+import { Box, Label, Input, Button, Flex, Text } from "theme-ui";
+
+import Modal from "../components/Modal";
+
+function StartTimerModal({ isOpen, onRequestClose }) {
+ const inputRef = useRef();
+ function focusInput() {
+ inputRef.current && inputRef.current.focus();
+ }
+
+ const [hour, setHour] = useState(0);
+ const [minute, setMinute] = useState(0);
+ const [second, setSecond] = useState(0);
+
+ function handleSubmit(event) {
+ event.preventDefault();
+ }
+
+ const inputStyle = {
+ width: "70px",
+ border: "none",
+ ":focus": {
+ outline: "none",
+ },
+ fontSize: "32px",
+ padding: 2,
+ paddingLeft: 0,
+ };
+
+ function parseValue(value, max) {
+ const num = parseInt(value);
+ if (isNaN(num)) {
+ return 0;
+ }
+ return Math.min(num, max);
+ }
+
+ return (
+
+
+
+
+
+
+ H:
+
+ setHour(parseValue(e.target.value, 24))}
+ type="number"
+ min={0}
+ max={24}
+ />
+
+ M:
+
+ setMinute(parseValue(e.target.value, 59))}
+ type="number"
+ ref={inputRef}
+ min={0}
+ max={59}
+ />
+
+ S:
+
+ setSecond(parseValue(e.target.value, 59))}
+ type="number"
+ min={0}
+ max={59}
+ />
+
+
+
+
+
+
+
+ );
+}
+
+export default StartTimerModal;