Add chapter name autocomplete

This commit is contained in:
Ajay Ramachandran
2021-11-07 01:05:32 -04:00
parent 9e6e3b023d
commit a3e67b6cde
5 changed files with 174 additions and 15 deletions

View File

@@ -0,0 +1,55 @@
import * as React from "react";
export interface SelectorOption {
label: string;
}
export interface SelectorProps {
id: string;
options: SelectorOption[];
onChange: (value: string) => void;
}
export interface SelectorState {
}
class SelectorComponent extends React.Component<SelectorProps, SelectorState> {
constructor(props: SelectorProps) {
super(props);
// Setup state
this.state = {
}
}
render(): React.ReactElement {
return (
<div id={this.props.id}
className="sbSelector">
<div className="sbSelectorBackground">
{this.getOptions()}
</div>
</div>
);
}
getOptions(): React.ReactElement[] {
const result: React.ReactElement[] = [];
for (const option of this.props.options) {
result.push(
<div className="sbSelectorOption"
onClick={() => this.props.onChange(option.label)}
key={option.label}>
{option.label}
</div>
);
}
return result;
}
}
export default SelectorComponent;