Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#12 Add measure selection and normalize section in state
- Loading branch information
Showing
12 changed files
with
202 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { useState } from "react"; | ||
|
||
import MeasureSelect from "./measureSelect"; | ||
|
||
export default { | ||
title: "Components|MeasureSelect", | ||
component: MeasureSelect | ||
}; | ||
|
||
export const Basic = () => { | ||
const [measure, setMeasure] = useState(4); | ||
|
||
return ( | ||
<> | ||
<MeasureSelect | ||
onChange={measure => setMeasure(measure)} | ||
value={measure} | ||
min={0} | ||
max={14} | ||
/> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from "react"; | ||
|
||
import TestEnvironment from "../../tests/TestEnvironment"; | ||
import MeasureSelect from "./measureSelect"; | ||
|
||
it("renders without crashing", () => { | ||
TestEnvironment.smokeTest( | ||
<MeasureSelect onChange={() => {}} value={4} min={0} max={14} /> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { MenuItem } from "@material-ui/core"; | ||
import Select from "@material-ui/core/Select/Select"; | ||
import React, { FunctionComponent } from "react"; | ||
|
||
const MeasureSelect: FunctionComponent<{ | ||
value: number; | ||
min: number; | ||
max: number; | ||
onChange: (value: number) => void; | ||
}> = props => { | ||
const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => { | ||
let newMeasure = event.target.value as number; | ||
props.onChange(newMeasure); | ||
}; | ||
|
||
return ( | ||
<Select | ||
value={props.value} | ||
onChange={handleChange} | ||
style={{ | ||
minWidth: "40px" | ||
}} | ||
> | ||
{new Array<number>(props.max - props.min + 1) | ||
.fill(0) | ||
.map((_, idx: number) => { | ||
return ( | ||
<MenuItem key={props.min + idx} value={props.min + idx}> | ||
{props.min + idx} | ||
</MenuItem> | ||
); | ||
})} | ||
</Select> | ||
); | ||
}; | ||
|
||
export default MeasureSelect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from "react"; | ||
|
||
import { SectionType } from "../../states/analysisSlice"; | ||
import TestEnvironment from "../../tests/TestEnvironment"; | ||
import SectionSelect from "./sectionSelect"; | ||
|
||
it("renders without crashing", () => { | ||
TestEnvironment.smokeTest( | ||
<SectionSelect onChange={() => {}} value={SectionType.BRIDGE} /> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.