Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FormLabel] [FormHelperText] classes keys #12373

Merged
merged 6 commits into from
Aug 2, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
let's merge
oliviertassinari committed Aug 2, 2018

Verified

This commit was signed with the committer’s verified signature.
natlibfi-psams Pekko Sams
commit 8f28bc98c1098dff144983800c59d92b8b9363be
14 changes: 7 additions & 7 deletions packages/material-ui/src/FormHelperText/FormHelperText.js
Original file line number Diff line number Diff line change
@@ -41,23 +41,23 @@ function FormHelperText(props, context) {
const {
classes,
className: classNameProp,
component: Component,
disabled: disabledProp,
error: errorProp,
margin: marginProp,
component: Component,
filled: filledProp,
focused: focusedProp,
margin: marginProp,
required: requiredProp,
filled: filledProp,
...other
} = props;
const { muiFormControl } = context;

let disabled = disabledProp;
let error = errorProp;
let filled = filledProp;
let focused = focusedProp;
let margin = marginProp;
let required = requiredProp;
let focused = focusedProp;
let filled = filledProp;

if (muiFormControl) {
if (typeof disabled === 'undefined') {
@@ -85,9 +85,9 @@ function FormHelperText(props, context) {
{
[classes.disabled]: disabled,
[classes.error]: error,
[classes.marginDense]: margin === 'dense',
[classes.focused]: focused,
[classes.filled]: filled,
[classes.focused]: focused,
[classes.marginDense]: margin === 'dense',
[classes.required]: required,
},
classNameProp,
8 changes: 4 additions & 4 deletions packages/material-ui/src/FormLabel/FormLabel.js
Original file line number Diff line number Diff line change
@@ -46,19 +46,19 @@ function FormLabel(props, context) {
component: Component,
disabled: disabledProp,
error: errorProp,
filled: filledProp,
focused: focusedProp,
required: requiredProp,
filled: filledProp,
...other
} = props;

const { muiFormControl } = context;

let required = requiredProp;
let focused = focusedProp;
let disabled = disabledProp;
let error = errorProp;
let filled = filledProp;
let focused = focusedProp;
let required = requiredProp;

if (muiFormControl) {
if (typeof required === 'undefined') {
@@ -81,10 +81,10 @@ function FormLabel(props, context) {
const className = classNames(
classes.root,
{
[classes.focused]: focused,
[classes.disabled]: disabled,
[classes.error]: error,
[classes.filled]: filled,
[classes.focused]: focused,
[classes.required]: required,
},
classNameProp,
6 changes: 6 additions & 0 deletions pages/api/form-helper-text.md
Original file line number Diff line number Diff line change
@@ -20,7 +20,10 @@ title: FormHelperText API
| <span class="prop-name">component</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;func&nbsp;&#124;<br>&nbsp;object<br> | <span class="prop-default">'p'</span> | The component used for the root node. Either a string to use a DOM element or a component. |
| <span class="prop-name">disabled</span> | <span class="prop-type">bool |   | If `true`, the helper text should be displayed in a disabled state. |
| <span class="prop-name">error</span> | <span class="prop-type">bool |   | If `true`, helper text should be displayed in an error state. |
| <span class="prop-name">filled</span> | <span class="prop-type">bool |   | If `true`, the helper text should use filled classes key. |
| <span class="prop-name">focused</span> | <span class="prop-type">bool |   | If `true`, the helper text should use focused classes key. |
| <span class="prop-name">margin</span> | <span class="prop-type">enum:&nbsp;'dense'<br> |   | If `dense`, will adjust vertical spacing. This is normally obtained via context from FormControl. |
| <span class="prop-name">required</span> | <span class="prop-type">bool |   | If `true`, the helper text should use required classes key. |

Any other properties supplied will be spread to the root element (native element).

@@ -36,6 +39,9 @@ This property accepts the following keys:
| <span class="prop-name">error</span> | Styles applied to the root element if `error={true}`.
| <span class="prop-name">disabled</span> | Styles applied to the root element if `disabled={true}`.
| <span class="prop-name">marginDense</span> | Styles applied to the root element if `margin="dense"`.
| <span class="prop-name">focused</span> | Styles applied to the root element if `focused={true}`.
| <span class="prop-name">filled</span> | Styles applied to the root element if `filled={true}`.
| <span class="prop-name">required</span> | Styles applied to the root element if `required={true}`.

Have a look at [overriding with classes](/customization/overrides#overriding-with-classes) section
and the [implementation of the component](https://github.com/mui-org/material-ui/tree/master/packages/material-ui/src/FormHelperText/FormHelperText.js)
3 changes: 3 additions & 0 deletions pages/api/form-label.md
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ title: FormLabel API
| <span class="prop-name">component</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;func&nbsp;&#124;<br>&nbsp;object<br> | <span class="prop-default">'label'</span> | The component used for the root node. Either a string to use a DOM element or a component. |
| <span class="prop-name">disabled</span> | <span class="prop-type">bool |   | If `true`, the label should be displayed in a disabled state. |
| <span class="prop-name">error</span> | <span class="prop-type">bool |   | If `true`, the label should be displayed in an error state. |
| <span class="prop-name">filled</span> | <span class="prop-type">bool |   | If `true`, the label should use filled classes key. |
| <span class="prop-name">focused</span> | <span class="prop-type">bool |   | If `true`, the input of this label is focused (used by `FormGroup` components). |
| <span class="prop-name">required</span> | <span class="prop-type">bool |   | If `true`, the label will indicate that the input is required. |

@@ -37,6 +38,8 @@ This property accepts the following keys:
| <span class="prop-name">focused</span> | Styles applied to the root element if `focused={true}`.
| <span class="prop-name">disabled</span> | Styles applied to the root element if `disabled={true}`.
| <span class="prop-name">error</span> | Styles applied to the root element if `error={true}`.
| <span class="prop-name">filled</span> | Styles applied to the root element if `filled={true}`.
| <span class="prop-name">required</span> | Styles applied to the root element if `required={true}`.
| <span class="prop-name">asterisk</span> |

Have a look at [overriding with classes](/customization/overrides#overriding-with-classes) section