Skip to content

Commit

Permalink
fix(Form components style modifiers): Style modifiers (patternfly#797)
Browse files Browse the repository at this point in the history
fix 791
  • Loading branch information
Hyperkid123 authored and jschuler committed Oct 17, 2018
1 parent e66fc24 commit b5bc87e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 35 deletions.
4 changes: 2 additions & 2 deletions packages/patternfly-4/react-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"react-dom": "^15.6.2 || ^16.4.0"
},
"scripts": {
"build": "yarn build:babel; yarn build:ts",
"build": "yarn build:babel && yarn build:ts",
"build:babel": "concurrently \"yarn build:babel:cjs\" \"yarn build:babel:esm\"",
"build:babel:cjs": "cross-env BABEL_ENV=production:cjs babel src --out-dir dist/js",
"build:babel:esm": "cross-env BABEL_ENV=production:esm babel src --out-dir dist/esm",
Expand All @@ -52,4 +52,4 @@
"glob": "^7.1.2",
"npmlog": "^4.1.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const defaultProps = {
};

const ActionGroup = ({ className, children, ...props }) => {
const customClassName = css(styles.formGroup, getModifier(styles, 'action', styles.modifiers.info), className);
const customClassName = css(styles.formGroup, getModifier(styles, 'action'), className);
const classesHorizontal = css(styles.formHorizontalGroup);

return (
Expand Down
5 changes: 1 addition & 4 deletions packages/patternfly-4/react-core/src/components/Form/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ const defaultProps = {
};

const Form = ({ className, children, isHorizontal, ...props }) => (
<form
{...props}
className={css(styles.form, isHorizontal ? styles.modifiers.horizontal : styles.modifiers.info, className)}
>
<form {...props} className={css(styles.form, isHorizontal && styles.modifiers.horizontal, className)}>
<FormContext.Provider value={{ isHorizontal }}>{children}</FormContext.Provider>
</form>
);
Expand Down
54 changes: 27 additions & 27 deletions packages/patternfly-4/react-core/src/components/Form/FormGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,33 +80,33 @@ const FormGroup = ({
fieldId,
...props
}) => (
<FormContext.Consumer>
{({ isHorizontal }) => (
<div {...props} className={css(styles.formGroup, getModifier(styles, isInline && 'inline'), className)}>
{label && (
<label className={css(styles.formLabel)} htmlFor={fieldId}>
{label}
{isRequired && (
<span className={css(styles.formLabelRequired)} aria-hidden="true">
{ASTERISK}
</span>
)}
</label>
)}
{isHorizontal ? <div className={css(styles.formHorizontalGroup)}>{children}</div> : children}
{((isValid && helperText) || (!isValid && helperTextInvalid)) && (
<div
className={css(styles.formHelperText, getModifier(styles, !isValid && 'error', styles.modifiers.info))}
id={`${fieldId}-helper`}
aria-live="polite"
>
{isValid ? helperText : helperTextInvalid}
</div>
)}
</div>
)}
</FormContext.Consumer>
);
<FormContext.Consumer>
{({ isHorizontal }) => (
<div {...props} className={css(styles.formGroup, getModifier(styles, isInline && 'inline'), className)}>
{label && (
<label className={css(styles.formLabel)} htmlFor={fieldId}>
{label}
{isRequired && (
<span className={css(styles.formLabelRequired)} aria-hidden="true">
{ASTERISK}
</span>
)}
</label>
)}
{isHorizontal ? <div className={css(styles.formHorizontalGroup)}>{children}</div> : children}
{((isValid && helperText) || (!isValid && helperTextInvalid)) && (
<div
className={css(styles.formHelperText, getModifier(styles, !isValid && 'error'))}
id={`${fieldId}-helper`}
aria-live="polite"
>
{isValid ? helperText : helperTextInvalid}
</div>
)}
</div>
)}
</FormContext.Consumer>
);

FormGroup.propTypes = propTypes;
FormGroup.defaultProps = defaultProps;
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4586,7 +4586,7 @@ csso@~2.3.1:
clap "^1.0.9"
source-map "^0.5.3"

cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0", cssom@^0.3.4:
cssom@0.3.4, cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0", cssom@^0.3.4:
version "0.3.4"
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.4.tgz#8cd52e8a3acfd68d3aed38ee0a640177d2f9d797"

Expand Down

0 comments on commit b5bc87e

Please sign in to comment.