aboutsummaryrefslogtreecommitdiff
path: root/components/keybindselector.tsx
blob: 084d7482d5967be29f2a3156957e8e586890b7ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import FilledInput from '@material-ui/core/FilledInput';
import FormControl from '@material-ui/core/FormControl';
import InputLabel from '@material-ui/core/InputLabel';
import { useState } from 'react';
import { v4 as uuid } from 'uuid';

function Keybind(props: {
	keyName: string;
}) {
	return <span className='keybind'>{props.keyName}</span>;
}

function KeybindSelectorInner(props: {
	value: string[];
}) {
	return <div className='keybind-selector-inner'>
		{props.value.map(s => <Keybind keyName={s} />)}
	</div>;
}

export default function KeybindSelector(props: {
	label: string;
	value: string[];
	onChange?: (newValue: string[]) => any;
}) {
	var [tempID, _setTempID] = useState(uuid());

	return <FormControl variant='filled' className='keybind-selector' tabIndex={0}>
		<InputLabel htmlFor={tempID} shrink>{props.label}</InputLabel>
		<FilledInput id={tempID} inputComponent={() => <KeybindSelectorInner value={props.value} />} />
	</FormControl>;
}