diff --git a/src/App.js b/src/App.js index 9bc1166..486ccba 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,7 @@ import listenToACT from "./ACTListener" import "./css/App.css" import Action from "./Action" import RotationContainer from "./Rotation" +import OpenerContainer from "./Opener" import ReactDOM from "react-dom" const handleCodes = new Set(["00", "01", "02", "21", "22", "33"]) @@ -10,6 +11,9 @@ const handleCodes = new Set(["00", "01", "02", "21", "22", "33"]) export default function App() { const [actionList, setActionList] = React.useState([]) const [encounterList, setEncounterList] = React.useState([]) + const [openerActionList, setOpenerActionList] = React.useState( + JSON.parse(localStorage.getItem("openerActionList")) || [] + ) React.useEffect(() => { let selfId @@ -123,6 +127,24 @@ export default function App() { } }, []) + + let saveOpenerFn = (actionList) => { + setOpenerActionList([...actionList]); + localStorage.setItem("openerActionList", JSON.stringify(actionList)) + } + + let opener + if (encounterList[0]) + { + opener = + ( + + ) + } + return ( <>
@@ -135,12 +157,14 @@ export default function App() { /> ))}
+ {opener} {encounterList.map((encounter, i) => ( ))} diff --git a/src/Opener.js b/src/Opener.js new file mode 100644 index 0000000..e9092ad --- /dev/null +++ b/src/Opener.js @@ -0,0 +1,68 @@ +import React from "react" +import "./css/Rotation.css" +import "./css/Opener.css" +import Action from "./Action" + +export default function OpenerContainer({ openerActionList, actionList }) { + const [open, setOpen] = React.useState(true) + + if (openerActionList.length === 0) return null + let header = ( + + ) + + if (!open) + { + return (<> {header} ) + } + + return ( + <> + {header} +

Reference

+ +

Execution

+ + + ) +} + +function OpenerReference({ openerActionList }) { + return ( +
+ {openerActionList.map((action, i) => { + return () + })} +
+ ) +} + +function OpenerExecution({ openerActionList, actionList }) { + return ( +
+ {openerActionList.map((openerAction, i) => { + let executedAction = actionList[i] + let classes = ["action-rotation"] + let action = openerAction + if (executedAction) + { + classes.push(openerAction === executedAction ? "opener-correct" : "opener-incorrect") + action = executedAction + } + else + { + classes.push("opener-unexecuted") + action = openerAction + } + return () + })} +
+ ) +} diff --git a/src/Rotation.js b/src/Rotation.js index 9d6e7e9..b91250b 100644 --- a/src/Rotation.js +++ b/src/Rotation.js @@ -2,7 +2,7 @@ import React from "react" import "./css/Rotation.css" import Action from "./Action" -export default function RotationContainer({ encounterId, name, actionList }) { +export default function RotationContainer({ encounterId, name, actionList, saveOpenerFn }) { const [open, setOpen] = React.useState(false) return ( @@ -16,6 +16,7 @@ export default function RotationContainer({ encounterId, name, actionList }) { {encounterId === 0 ? "Current Rotation" : name} + ) } @@ -31,3 +32,18 @@ function RotationContents({ expanded, actionList }) { ) } + +function SaveAsOpener({ expanded, actionList, saveOpenerFn }) { + if (!expanded) return null + + return ( + + ) +} diff --git a/src/css/Opener.css b/src/css/Opener.css new file mode 100644 index 0000000..332614d --- /dev/null +++ b/src/css/Opener.css @@ -0,0 +1,26 @@ +.opener-header { + padding: 0.2em; + margin: 0; + background-color: rgba(100, 100, 100, 0.3); + color: rgba(255, 255, 255, 0.5); + font-size: 13px; + border: 1px solid gray; + border-left: 0; + border-right: 0; + text-align: center; + font-weight: normal; +} + +.opener-correct { + box-sizing: border-box; + border: 3px solid lime; +} + +.opener-incorrect { + box-sizing: border-box; + border: 3px solid red; +} + +.opener-unexecuted { + opacity: 0.4; +} diff --git a/src/css/Rotation.css b/src/css/Rotation.css index 2016f5a..a9f79ca 100644 --- a/src/css/Rotation.css +++ b/src/css/Rotation.css @@ -29,4 +29,9 @@ .rotation-button.expanded:after { content: "\25B2"; -} \ No newline at end of file +} + +.save-opener-button { + width: 200px; + margin: 0 auto; +}