Skip to content

Commit

Permalink
[TextField] Allow custom colors in FormLabel (#27337)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Jul 21, 2021
1 parent 9134611 commit dd1d07b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/pages/api-docs/form-label.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "enum",
"description": "'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'"
"name": "union",
"description": "'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
}
},
"component": { "type": { "name": "elementType" } },
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/api-docs/input-label.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"classes": { "type": { "name": "object" } },
"color": {
"type": {
"name": "enum",
"description": "'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'"
"name": "union",
"description": "'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
}
},
"disableAnimation": { "type": { "name": "bool" } },
Expand Down
8 changes: 7 additions & 1 deletion packages/material-ui/src/FormLabel/FormLabel.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import * as React from 'react';
import { SxProps } from '@material-ui/system';
import { OverridableStringUnion } from '@material-ui/types';
import { Theme } from '../styles';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
import { FormLabelClasses } from './formLabelClasses';

export interface FormLabelPropsColorOverrides {}

export interface FormLabelTypeMap<P = {}, D extends React.ElementType = 'label'> {
props: P &
FormLabelBaseProps & {
Expand All @@ -18,7 +21,10 @@ export interface FormLabelTypeMap<P = {}, D extends React.ElementType = 'label'>
/**
* The color of the component. It supports those theme colors that make sense for this component.
*/
color?: 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';
color?: OverridableStringUnion<
'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning',
FormLabelPropsColorOverrides
>;
/**
* If `true`, the label should be displayed in a disabled state.
*/
Expand Down
5 changes: 4 additions & 1 deletion packages/material-ui/src/FormLabel/FormLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ FormLabel.propTypes /* remove-proptypes */ = {
/**
* The color of the component. It supports those theme colors that make sense for this component.
*/
color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
PropTypes.string,
]),
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
Expand Down
5 changes: 4 additions & 1 deletion packages/material-ui/src/InputLabel/InputLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ InputLabel.propTypes /* remove-proptypes */ = {
/**
* The color of the component. It supports those theme colors that make sense for this component.
*/
color: PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['error', 'info', 'primary', 'secondary', 'success', 'warning']),
PropTypes.string,
]),
/**
* If `true`, the transition animation is disabled.
* @default false
Expand Down

0 comments on commit dd1d07b

Please sign in to comment.