diff --git a/app/gabsocial/features/forms/index.js b/app/gabsocial/features/forms/index.js index a1f890eb7..13932efa7 100644 --- a/app/gabsocial/features/forms/index.js +++ b/app/gabsocial/features/forms/index.js @@ -4,6 +4,28 @@ import PropTypes from 'prop-types'; import classNames from 'classnames'; import { v4 as uuidv4 } from 'uuid'; +export const InputContainer = (props) => { + const containerClass = classNames('input', { + 'with_label': props.label, + 'required': props.required, + }, props.extraClass); + + return ( +
+ {props.children} + {props.hint && {props.hint}} +
+ ); +}; + +InputContainer.propTypes = { + label: PropTypes.string, + hint: PropTypes.string, + required: PropTypes.bool, + children: PropTypes.node, + extraClass: PropTypes.string, +}; + export const LabelInput = ({ label, ...props }) => { const id = uuidv4(); return ( @@ -68,19 +90,12 @@ export class Checkbox extends ImmutablePureComponent { } render() { - const { label, required } = this.props; - - const containerClassNames = classNames('input', 'boolean', { - 'with_label': label, - 'required': required, - }); - - const Input = label ? LabelInput : 'input'; + const Input = this.props.label ? LabelInput : 'input'; return ( -
+ -
+ ); } @@ -194,19 +209,12 @@ export class TextInput extends ImmutablePureComponent { } render() { - const { label, required } = this.props; - - const containerClassNames = classNames('input', { - 'with_label': label, - 'required': required, - }); - - const Input = label ? LabelInput : 'input'; + const Input = this.props.label ? LabelInput : 'input'; return ( -
+ -
+ ); } @@ -224,20 +232,13 @@ export class FileChooser extends ImmutablePureComponent { } render() { - const { label, hint, ...props } = this.props; - - const containerClassNames = classNames('input', { - 'with_label': label, - 'required': this.props.required, - }); - - const Input = label ? LabelInput : 'input'; + const { hint, ...props } = this.props; + const Input = this.props.label ? LabelInput : 'input'; return ( -
+ - {hint && {hint}} -
+ ); } diff --git a/app/gabsocial/features/preferences/components/settings_checkbox.js b/app/gabsocial/features/preferences/components/settings_checkbox.js index 55f52ca97..1cf2f9c0c 100644 --- a/app/gabsocial/features/preferences/components/settings_checkbox.js +++ b/app/gabsocial/features/preferences/components/settings_checkbox.js @@ -27,13 +27,14 @@ class SettingsCheckbox extends ImmutablePureComponent { } render() { - const { label, path, settings } = this.props; + const { label, path, settings, ...props } = this.props; return ( ); }