implemented repository create form

This commit is contained in:
Sebastian Sdorra
2018-08-02 16:09:58 +02:00
parent e675bcc0fd
commit 9b62d19df5
23 changed files with 838 additions and 129 deletions

View File

@@ -0,0 +1,59 @@
//@flow
import React from "react";
export type SelectItem = {
value: string,
label: string
};
type Props = {
label?: string,
options: SelectItem[],
value?: SelectItem,
onChange: string => void
};
class Select extends React.Component<Props> {
field: ?HTMLSelectElement;
handleInput = (event: SyntheticInputEvent<HTMLSelectElement>) => {
this.props.onChange(event.target.value);
};
renderLabel = () => {
const label = this.props.label;
if (label) {
return <label className="label">{label}</label>;
}
return "";
};
render() {
const { options, value } = this.props;
return (
<div className="field">
{this.renderLabel()}
<div className="control select">
<select
ref={input => {
this.field = input;
}}
value={value}
onChange={this.handleInput}
>
{options.map(opt => {
return (
<option value={opt.value} key={opt.value}>
{opt.label}
</option>
);
})}
</select>
</div>
</div>
);
}
}
export default Select;