mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
add help to select
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import {Help} from "../index";
|
||||||
|
|
||||||
export type SelectItem = {
|
export type SelectItem = {
|
||||||
value: string,
|
value: string,
|
||||||
@@ -10,7 +11,8 @@ type Props = {
|
|||||||
label?: string,
|
label?: string,
|
||||||
options: SelectItem[],
|
options: SelectItem[],
|
||||||
value?: SelectItem,
|
value?: SelectItem,
|
||||||
onChange: string => void
|
onChange: string => void,
|
||||||
|
helpText?: string
|
||||||
};
|
};
|
||||||
|
|
||||||
class Select extends React.Component<Props> {
|
class Select extends React.Component<Props> {
|
||||||
@@ -36,12 +38,25 @@ class Select extends React.Component<Props> {
|
|||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
renderHelp = () => {
|
||||||
|
const helpText = this.props.helpText;
|
||||||
|
if(helpText){
|
||||||
|
return (
|
||||||
|
<div className="control columns is-vcentered">
|
||||||
|
<Help message={helpText} />
|
||||||
|
</div>);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { options, value } = this.props;
|
const { options, value } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="field">
|
<div className="field">
|
||||||
{this.renderLabel()}
|
{this.renderLabel()}
|
||||||
|
<div className="field is-grouped">
|
||||||
<div className="control select">
|
<div className="control select">
|
||||||
<select
|
<select
|
||||||
ref={input => {
|
ref={input => {
|
||||||
@@ -59,6 +74,8 @@ class Select extends React.Component<Props> {
|
|||||||
})}
|
})}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
{this.renderHelp()}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user