-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add options to specify default loop count and maximum duration.
- Loading branch information
Showing
6 changed files
with
160 additions
and
22 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
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,42 @@ | ||
import { Box, ListSubheader, MenuItem, Select, SelectChangeEvent, Stack } from "@mui/material"; | ||
|
||
export function NumberSelector(props: { | ||
label: string; | ||
values: number[]; | ||
value: number; | ||
valueLabelFn?: (value: number) => string; | ||
onChange: (value: number) => void; | ||
}) { | ||
const { value, values, onChange } = props; | ||
function valueToLabel(value: number) { | ||
return props.valueLabelFn?.(value) ?? value.toString(); | ||
} | ||
const items = []; | ||
for (const i in values) { | ||
items.push( | ||
<MenuItem key={i} value={values[i]}> | ||
{valueToLabel(values[i])} | ||
</MenuItem> | ||
); | ||
} | ||
return ( | ||
<Stack> | ||
<ListSubheader>{props.label}</ListSubheader> | ||
<Box sx={{ mx: 2 }}> | ||
<Select | ||
fullWidth | ||
size="small" | ||
value={value} | ||
onChange={(e) => { | ||
onChange(e.target.value as number); | ||
}} | ||
renderValue={(value) => { | ||
return <MenuItem sx={{ p: 0 }}>{valueToLabel(value)}</MenuItem>; | ||
}} | ||
> | ||
{items} | ||
</Select> | ||
</Box> | ||
</Stack> | ||
); | ||
} |