fix bouncing help icons on mobiles devices

This commit is contained in:
Sebastian Sdorra
2018-11-13 07:39:19 +01:00
parent 24de639c1e
commit e7c9560073
11 changed files with 102 additions and 76 deletions

View File

@@ -10,7 +10,9 @@ type Props = {
disabled?: boolean,
helpText?: string
};
class Checkbox extends React.Component<Props> {
onCheckboxChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
if (this.props.onChange) {
this.props.onChange(event.target.checked, this.props.name);
@@ -20,12 +22,8 @@ class Checkbox extends React.Component<Props> {
renderHelp = () => {
const helpText = this.props.helpText;
if (helpText) {
return (
<div className="control columns is-vcentered">
<Help message={helpText} />
</div>
);
} else return null;
return <Help message={helpText} />;
}
};
render() {
@@ -39,10 +37,11 @@ class Checkbox extends React.Component<Props> {
onChange={this.onCheckboxChange}
disabled={this.props.disabled}
/>
{" "}
{this.props.label}
{this.renderHelp()}
</label>
</div>
{this.renderHelp()}
</div>
);
}

View File

@@ -1,7 +1,7 @@
//@flow
import React from "react";
import classNames from "classnames";
import { LabelWithHelpIcon } from "../index";
import LabelWithHelpIcon from "./LabelWithHelpIcon";
type Props = {
label?: string,

View File

@@ -0,0 +1,37 @@
//@flow
import React from "react";
import Help from '../Help';
type Props = {
label?: string,
helpText?: string
};
class LabelWithHelpIcon extends React.Component<Props> {
renderHelp() {
const { helpText } = this.props;
if (helpText) {
return (
<Help message={helpText} />
);
}
}
render() {
const {label } = this.props;
if (label) {
const help = this.renderHelp();
return (
<label className="label">
{label} { help }
</label>
);
}
return "";
}
}
export default LabelWithHelpIcon;

View File

@@ -1,7 +1,7 @@
//@flow
import React from "react";
import classNames from "classnames";
import { LabelWithHelpIcon } from "../index";
import LabelWithHelpIcon from "./LabelWithHelpIcon";
export type SelectItem = {
value: string,

View File

@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { LabelWithHelpIcon } from "../index";
import LabelWithHelpIcon from "./LabelWithHelpIcon";
export type SelectItem = {
value: string,

View File

@@ -5,4 +5,5 @@ export { default as Checkbox } from "./Checkbox.js";
export { default as InputField } from "./InputField.js";
export { default as Select } from "./Select.js";
export { default as Textarea } from "./Textarea.js";
export { default as LabelWithHelpIcon } from "./LabelWithHelpIcon";