Closes #514 better map planner element locations

This commit is contained in:
Kalle (Sendou)
2021-05-22 21:19:40 +03:00
parent 4cb8904d49
commit fb83304683
2 changed files with 36 additions and 34 deletions

View File

@@ -38,7 +38,7 @@ const StageSelector: React.FC<StageSelectorProps> = ({
}) => {
const { i18n } = useLingui();
return (
<Box maxW="20rem" m="3rem auto">
<Box maxW="20rem" m="0 auto 2rem auto">
<Select value={currentBackground.stage} onChange={handleChange}>
{salmonRunStages
.concat(stages)

View File

@@ -293,6 +293,39 @@ const MapPlannerPage = () => {
color={color}
setColor={setColor}
/>
<StageSelector
handleChange={(e) => {
const stage = e.target.value;
if (stage === "") {
return;
}
if (stage === "Blank") {
setBg({ stage });
return;
}
const newIsSalmonRunStage = !stages.includes(stage as any);
const oldIsSalmonRunStage = !stages.includes(bg.stage as any);
if (newIsSalmonRunStage === oldIsSalmonRunStage) {
setBg({ ...bg, stage });
return;
}
if (newIsSalmonRunStage) {
setBg({ stage, tide: "mid" });
return;
}
setBg({ stage, mode: "SZ", view: "M" });
}}
currentBackground={bg}
changeMode={(mode) => setBg({ ...bg, mode })}
changeTide={(tide: "low" | "mid" | "high") => setBg({ ...bg, tide })}
changeView={(view: "M" | "R") => setBg({ ...bg, view })}
/>
<MapSketch
sketch={sketch}
controlledValue={controlledValue}
@@ -301,8 +334,6 @@ const MapPlannerPage = () => {
tool={tool}
/>
<ImageAdder addImageToSketch={addImageToSketch} />
<Divider mx="3" my={4} />
<Flex mt={6} mb={2} justifyContent="space-between">
<Button
onClick={() => {
@@ -340,38 +371,9 @@ const MapPlannerPage = () => {
</Button>
</ButtonGroup>
</Flex>
<StageSelector
handleChange={(e) => {
const stage = e.target.value;
if (stage === "") {
return;
}
if (stage === "Blank") {
setBg({ stage });
return;
}
const newIsSalmonRunStage = !stages.includes(stage as any);
const oldIsSalmonRunStage = !stages.includes(bg.stage as any);
if (newIsSalmonRunStage === oldIsSalmonRunStage) {
setBg({ ...bg, stage });
return;
}
if (newIsSalmonRunStage) {
setBg({ stage, tide: "mid" });
return;
}
setBg({ stage, mode: "SZ", view: "M" });
}}
currentBackground={bg}
changeMode={(mode) => setBg({ ...bg, mode })}
changeTide={(tide: "low" | "mid" | "high") => setBg({ ...bg, tide })}
changeView={(view: "M" | "R") => setBg({ ...bg, view })}
/>
<Divider mx="3" my={6} />
<ImageAdder addImageToSketch={addImageToSketch} />
<input
type="file"
accept=".json"