add help to input field

This commit is contained in:
Maren Süwer
2018-10-02 09:43:41 +02:00
parent 8eb2c273ca
commit 829583bdd0
4 changed files with 33 additions and 16 deletions

View File

@@ -8,7 +8,8 @@ const styles = {
display: "block" display: "block"
}, },
q: { q: {
float: "left" float: "left",
paddingLeft: "3px"
} }
}; };

View File

@@ -1,6 +1,7 @@
//@flow //@flow
import React from "react"; import React from "react";
import classNames from "classnames"; import classNames from "classnames";
import {Help, Page} from "../index";
type Props = { type Props = {
label?: string, label?: string,
@@ -12,7 +13,8 @@ type Props = {
onReturnPressed?: () => void, onReturnPressed?: () => void,
validationError: boolean, validationError: boolean,
errorMessage: string, errorMessage: string,
disabled?: boolean disabled?: boolean,
helpText?: string
}; };
class InputField extends React.Component<Props> { class InputField extends React.Component<Props> {
@@ -41,6 +43,17 @@ class InputField 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;
}
handleKeyPress = (event: SyntheticKeyboardEvent<HTMLInputElement>) => { handleKeyPress = (event: SyntheticKeyboardEvent<HTMLInputElement>) => {
const onReturnPressed = this.props.onReturnPressed; const onReturnPressed = this.props.onReturnPressed;
@@ -71,7 +84,8 @@ class InputField extends React.Component<Props> {
return ( return (
<div className="field"> <div className="field">
{this.renderLabel()} {this.renderLabel()}
<div className="control"> <div className="field is-grouped">
<div className="control is-expanded">
<input <input
ref={input => { ref={input => {
this.field = input; this.field = input;
@@ -85,6 +99,8 @@ class InputField extends React.Component<Props> {
disabled={disabled} disabled={disabled}
/> />
</div> </div>
{this.renderHelp()}
</div>
{helper} {helper}
</div> </div>
); );

View File

@@ -41,6 +41,7 @@ class GeneralSettings extends React.Component<Props> {
onChange={this.handleRealmDescriptionChange} onChange={this.handleRealmDescriptionChange}
value={realmDescription} value={realmDescription}
disabled={!hasUpdatePermission} disabled={!hasUpdatePermission}
helpText={"hallo"}
/> />
<InputField <InputField
label={t("general-settings.date-format")} label={t("general-settings.date-format")}

View File

@@ -39,7 +39,6 @@ class Config extends React.Component<Props> {
return ( return (
<Page> <Page>
<Help message={"Hallo"} />
<div className="columns"> <div className="columns">
<div className="column is-three-quarters"> <div className="column is-three-quarters">
<Route path={url} exact component={GlobalConfig} /> <Route path={url} exact component={GlobalConfig} />