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

[TextField] Add support for "secondary" color #17891

Merged
merged 2 commits into from
Oct 30, 2019

Conversation

ValentinH
Copy link
Contributor

@ValentinH ValentinH commented Oct 15, 2019

Closes #17006
Closes #17891

Open questions:

  • do we want to support "inherit"?

  • which CSS rule name should we use? I've used both secondaryColor and underlineSecondary...

  • I have followed (at least) the PR section of the contributing guide.

@mui-pr-bot
Copy link

mui-pr-bot commented Oct 15, 2019

@material-ui/core: parsed: +0.16% , gzip: +0.09%

Details of bundle changes.

Comparing: 258e847...29ba262

bundle Size Change Size Gzip Change Gzip
TextField ▲ +544 B (+0.45% ) 121 kB ▲ +128 B (+0.36% ) 35.4 kB
@material-ui/core ▲ +544 B (+0.16% ) 348 kB ▲ +88 B (+0.09% ) 95.3 kB
@material-ui/core[umd] ▲ +500 B (+0.16% ) 308 kB ▲ +108 B (+0.12% ) 88.6 kB
Select ▲ +324 B (+0.29% ) 112 kB ▲ +56 B (+0.17% ) 33.4 kB
TablePagination ▲ +324 B (+0.23% ) 139 kB ▲ +49 B (+0.12% ) 40.5 kB
FilledInput ▲ +294 B (+0.41% ) 72 kB ▲ +68 B (+0.31% ) 22.3 kB
Input ▲ +290 B (+0.41% ) 70.9 kB ▲ +72 B (+0.33% ) 22.1 kB
InputLabel ▲ +234 B (+0.37% ) 63.7 kB ▲ +47 B (+0.24% ) 19.8 kB
FormLabel ▲ +230 B (+0.37% ) 61.9 kB ▲ +50 B (+0.26% ) 19.1 kB
InputBase ▲ +225 B (+0.33% ) 69 kB ▲ +65 B (+0.30% ) 21.6 kB
OutlinedInput ▲ +190 B (+0.26% ) 72.4 kB ▲ +56 B (+0.25% ) 22.5 kB
NativeSelect ▲ +171 B (+0.23% ) 75.1 kB ▲ +56 B (+0.24% ) 23.7 kB
FormControl ▲ +51 B (+0.08% ) 62.8 kB ▲ +27 B (+0.14% ) 19.5 kB
Rating -- 68.3 kB ▲ +7 B (+0.03% ) 21.8 kB
AppBar -- 62.2 kB ▲ +5 B (+0.03% ) 19.5 kB
Badge -- 63.8 kB ▲ +5 B (+0.03% ) 19.7 kB
Paper -- 60.6 kB ▲ +5 B (+0.03% ) 18.8 kB
Tabs -- 83.7 kB ▲ +5 B (+0.02% ) 26.6 kB
Breadcrumbs -- 66.4 kB ▲ +4 B (+0.02% ) 20.8 kB
Button -- 77.7 kB ▲ +4 B (+0.02% ) 24 kB
Link -- 65 kB ▼ -4 B (-0.02% ) 20.6 kB
@material-ui/styles -- 50.8 kB ▲ +3 B (+0.02% ) 15.4 kB
Checkbox -- 80 kB ▲ +3 B (+0.01% ) 25.1 kB
Grow -- 22.6 kB ▲ +3 B (+0.04% ) 7.72 kB
Radio -- 80.9 kB ▲ +3 B (+0.01% ) 25.4 kB
StepButton -- 80.5 kB ▲ +3 B (+0.01% ) 25.3 kB
TableCell -- 62.5 kB ▼ -3 B (-0.02% ) 19.6 kB
@material-ui/system -- 14.8 kB ▲ +2 B (+0.05% ) 4.06 kB
Avatar -- 61.1 kB ▲ +2 B (+0.01% ) 19.2 kB
Backdrop -- 66.2 kB ▲ +2 B (+0.01% ) 20.4 kB
BottomNavigation -- 60.8 kB ▲ +2 B (+0.01% ) 19 kB
CardActions -- 60.5 kB ▼ -2 B (-0.01% ) 18.9 kB
CardContent -- 60.4 kB ▼ -2 B (-0.01% ) 18.9 kB
CardMedia -- 60.8 kB ▼ -2 B (-0.01% ) 19.1 kB
Chip -- 80.9 kB ▲ +2 B (+0.01% ) 24.7 kB
Dialog -- 80.9 kB ▲ +2 B (+0.01% ) 25.1 kB
DialogContentText -- 62.5 kB ▲ +2 B (+0.01% ) 19.6 kB
DialogTitle -- 62.7 kB ▲ +2 B (+0.01% ) 19.7 kB
ExpansionPanelSummary -- 76.3 kB ▲ +2 B (+0.01% ) 24 kB
Hidden -- 64.5 kB ▲ +2 B (+0.01% ) 20.2 kB
IconButton -- 74.4 kB ▼ -2 B (-0.01% ) 23.2 kB
InputAdornment -- 63.5 kB ▲ +2 B (+0.01% ) 20 kB
List -- 60.8 kB ▲ +2 B (+0.01% ) 18.9 kB
ListItemText -- 63.4 kB ▲ +2 B (+0.01% ) 19.9 kB
MobileStepper -- 66.1 kB ▼ -2 B (-0.01% ) 20.6 kB
Slider -- 73.7 kB ▲ +2 B (+0.01% ) 23.3 kB
SpeedDialIcon -- 63 kB ▲ +2 B (+0.01% ) 19.8 kB
styles/createMuiTheme -- 15.2 kB ▼ -2 B (-0.04% ) 5.36 kB
Table -- 61 kB ▲ +2 B (+0.01% ) 19.1 kB
TableSortLabel -- 75.6 kB ▲ +2 B (+0.01% ) 23.9 kB
@material-ui/lab -- 168 kB ▼ -1 B (-0.00% ) 50.6 kB
BottomNavigationAction -- 73.7 kB ▼ -1 B (-0.00% ) 23.3 kB
Box -- 69.2 kB ▲ +1 B (0.00% ) 20.9 kB
ButtonGroup -- 62.6 kB ▼ -1 B (-0.01% ) 19.5 kB
Card -- 61.1 kB ▼ -1 B (-0.01% ) 19.1 kB
CardHeader -- 63.5 kB ▲ +1 B (+0.01% ) 20 kB
CircularProgress -- 62.5 kB ▼ -1 B (-0.01% ) 19.7 kB
Container -- 61.6 kB ▼ -1 B (-0.01% ) 19.2 kB
CssBaseline -- 56 kB ▼ -1 B (-0.01% ) 17.5 kB
DialogContent -- 60.6 kB ▲ +1 B (+0.01% ) 19 kB
Divider -- 61 kB ▼ -1 B (-0.01% ) 19.1 kB
Drawer -- 82.7 kB ▲ +1 B (0.00% ) 25.6 kB
Fab -- 75.1 kB ▼ -1 B (-0.00% ) 23.3 kB
FormControlLabel -- 63.9 kB ▲ +1 B (0.00% ) 20.1 kB
FormGroup -- 60.4 kB ▲ +1 B (+0.01% ) 18.9 kB
FormHelperText -- 61.7 kB ▼ -1 B (-0.01% ) 19.3 kB
GridList -- 60.9 kB ▼ -1 B (-0.01% ) 19.1 kB
GridListTile -- 62.1 kB ▲ +1 B (+0.01% ) 19.5 kB
LinearProgress -- 63.7 kB ▼ -1 B (-0.01% ) 19.8 kB
MenuItem -- 76.4 kB ▲ +1 B (0.00% ) 23.8 kB
MenuList -- 64.4 kB ▲ +1 B (0.00% ) 20.1 kB
RadioGroup -- 61.7 kB ▲ +1 B (+0.01% ) 19.3 kB
Snackbar -- 75.5 kB ▲ +1 B (0.00% ) 23.5 kB
SnackbarContent -- 64 kB ▲ +1 B (0.00% ) 20.1 kB
SvgIcon -- 61.5 kB ▲ +1 B (+0.01% ) 19.1 kB
SwipeableDrawer -- 90 kB ▲ +1 B (0.00% ) 27.9 kB
Tab -- 74.6 kB ▲ +1 B (0.00% ) 23.6 kB
ToggleButton -- 74.4 kB ▲ +1 B (0.00% ) 23.5 kB
ToggleButtonGroup -- 61.6 kB ▲ +1 B (+0.01% ) 19.4 kB
Tooltip -- 97.6 kB ▼ -1 B (-0.00% ) 30.9 kB
TreeItem -- 71.8 kB ▲ +1 B (0.00% ) 22.6 kB
TreeView -- 64.4 kB ▼ -1 B (-0.00% ) 20.1 kB
Autocomplete -- 124 kB -- 39.5 kB
ButtonBase -- 72.2 kB -- 22.6 kB
CardActionArea -- 73.3 kB -- 23.1 kB
ClickAwayListener -- 3.85 kB -- 1.55 kB
Collapse -- 66.3 kB -- 20.5 kB
colorManipulator -- 3.83 kB -- 1.52 kB
DialogActions -- 60.5 kB -- 18.9 kB
docs.landing -- 56 kB -- 14.6 kB
docs.main -- 602 kB -- 192 kB
ExpansionPanel -- 69.4 kB -- 21.7 kB
ExpansionPanelActions -- 60.5 kB -- 18.9 kB
ExpansionPanelDetails -- 60.4 kB -- 18.9 kB
Fade -- 22 kB -- 7.6 kB
Grid -- 63.5 kB -- 19.9 kB
GridListTileBar -- 61.6 kB -- 19.3 kB
Icon -- 61.2 kB -- 19.1 kB
ListItem -- 75.4 kB -- 23.5 kB
ListItemAvatar -- 60.5 kB -- 18.9 kB
ListItemIcon -- 60.6 kB -- 19 kB
ListItemSecondaryAction -- 60.4 kB -- 18.9 kB
ListSubheader -- 61.2 kB -- 19.2 kB
Menu -- 86.6 kB -- 27.2 kB
Modal -- 14.2 kB -- 4.96 kB
NoSsr -- 2.19 kB -- 1.04 kB
Popover -- 81 kB -- 25 kB
Popper -- 28.5 kB -- 10.2 kB
Portal -- 2.87 kB -- 1.29 kB
RootRef -- 4.43 kB -- 1.67 kB
Skeleton -- 60.9 kB -- 19.1 kB
Slide -- 24.1 kB -- 8.21 kB
SpeedDial -- 84.3 kB -- 26.5 kB
SpeedDialAction -- 114 kB -- 36 kB
Step -- 61 kB -- 19.1 kB
StepConnector -- 61.1 kB -- 19.2 kB
StepContent -- 67.4 kB -- 21 kB
StepIcon -- 63.1 kB -- 19.6 kB
StepLabel -- 67 kB -- 21 kB
Stepper -- 63.2 kB -- 19.9 kB
Switch -- 79.3 kB -- 24.7 kB
TableBody -- 60.5 kB -- 18.9 kB
TableFooter -- 60.5 kB -- 18.9 kB
TableHead -- 60.5 kB -- 18.9 kB
TableRow -- 60.9 kB -- 19.1 kB
TextareaAutosize -- 5.06 kB -- 2.11 kB
Toolbar -- 60.7 kB -- 19 kB
Typography -- 62.1 kB -- 19.3 kB
useAutocomplete -- 11.1 kB -- 4.21 kB
useMediaQuery -- 2.49 kB -- 1.05 kB
Zoom -- 22.1 kB -- 7.6 kB

Generated by 🚫 dangerJS against 29ba262

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the color propagate through the form context?

do we want to support "inherit"?

I have explored it a bit in the past, I didn't find any good lead. Did you find a possible solution?

which CSS rule name should we use? I've used both secondaryColor and underlineSecondary...

colorSecondary?

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 15, 2019

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 48d6cab:

Sandbox Source
create-react-app Configuration
create-react-app-with-typescript Configuration

@ValentinH
Copy link
Contributor Author

I didn't pay attention to the context, I'll look into that.

Regarding inherit, I was just asking because I saw it on other components. Indeed, it's probably tricky to support it here.

I'm fine with colorSecondary.

I'll update this later today 🙂

@ValentinH
Copy link
Contributor Author

@oliviertassinari I've made the requested adjustments.

I didn't use the form context inside FilledInput, OutlinedInput and Input because it was yet used. Should I use it there as well so that we don't have to provide the color prop when we already use it on the FormControl?

@ValentinH ValentinH force-pushed the input-secondary-color branch 3 times, most recently from ed5f9b3 to 068beea Compare October 15, 2019 20:25
@oliviertassinari oliviertassinari added the component: text field This is the name of the generic UI component, not the React module! label Oct 18, 2019
@oliviertassinari oliviertassinari changed the title [Input] add support for "secondary" color [TextField] add support for "secondary" color Oct 18, 2019
@oliviertassinari oliviertassinari force-pushed the input-secondary-color branch 2 times, most recently from 2e44eb6 to 24721c0 Compare October 18, 2019 17:24
@oliviertassinari oliviertassinari changed the title [TextField] add support for "secondary" color [TextField] Add support for "secondary" color Oct 18, 2019
@oliviertassinari oliviertassinari force-pushed the input-secondary-color branch 2 times, most recently from b0bef5f to c8cd861 Compare October 18, 2019 17:40
@oliviertassinari oliviertassinari added the new feature New feature or request label Oct 18, 2019
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done, quite some changes 😁. This should enable us to support dynamic color in the future.

});

return (
<Component
className={clsx(
classes.root,
classes[`color${capitalize(fcs.color || 'primary')}`],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the colorPrimary class defined?

Copy link
Member

@oliviertassinari oliviertassinari Oct 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, it doesn't stop somebody to use .MuiFormLabel-colorPrimary (in the future)

@ValentinH
Copy link
Contributor Author

I've checked your changes and it looks good to me too. 🎉

@oliviertassinari
Copy link
Member

Great, let's wait till Monday to collect more feedback.

@oliviertassinari oliviertassinari added this to the v4.6.0 milestone Oct 20, 2019
@oliviertassinari oliviertassinari self-assigned this Oct 30, 2019
Valentin Hervieu and others added 2 commits October 30, 2019 21:42
As discussed in mui#17006

Open questions:
- do we want to support "inherit"?
- which CSS rule name should we use? I've used both `secondaryColor` and `underlineSecondary`...
@oliviertassinari oliviertassinari merged commit c28697d into mui:master Oct 30, 2019
@oliviertassinari
Copy link
Member

@ValentinH Thank you

@ValentinH
Copy link
Contributor Author

@oliviertassinari why did you remove the demos?

@ValentinH
Copy link
Contributor Author

ValentinH commented Oct 31, 2019

Also I just noticed that you changed the default color for the Input, FilledInput and Label from light/dark to main primary. Isn't this a breaking change? Or it's a bug fix?

@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 31, 2019

@ValentinH I have removed the demo because I think that few people will want to change the color from primary to secondary. I have changed the color to simplify the logic.

@ValentinH ValentinH deleted the input-secondary-color branch October 31, 2019 08:44
@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 31, 2019

Well, maybe there are more need for this color prop documentation demo than I thought: #11644
(x6 👍) 🤔.

@jadbox
Copy link

jadbox commented Nov 8, 2019

Getting lots of errors from libraries like material-table where they set the color to inherit. Should this be provided?

@oliviertassinari
Copy link
Member

It's not supported

@ValentinH
Copy link
Contributor Author

@jadbox are they typescript error or runtime ones?

@jadbox
Copy link

jadbox commented Nov 8, 2019

@ValentinH They are runtime errors.

Warning: Failed prop type: Invalid prop `color` of value `inherit` supplied to `ForwardRef(TextField)`, expected one of ["primary","secondary"].
    in ForwardRef(TextField) (created by WithStyles(ForwardRef(TextField)))
    in WithStyles(ForwardRef(TextField)) (created by MTableToolbar)

Here's the GH issue within material-table: mbrn/material-table#1293

@ValentinH
Copy link
Contributor Author

Yes these are warnings only. Indeed, it's a side effect of a prop that used to be passed but not used.

@amalv
Copy link

amalv commented Nov 14, 2019

I seem to have the same problem as @jadbox regarding the <Input> component.

When I use the input component:

<Input label="email" />

The following warnings are generated in the console:

Warning: Failed prop type: Invalid prop color of value rgba(0, 0, 0, 0.54) supplied to ForwardRef(TextField), expected one of ["primary","secondary"].

Warning: Failed prop type: Invalid prop color of value rgba(0, 0, 0, 0.54) supplied to ForwardRef(FormControl), expected one of ["primary","secondary"].

Is there any workaround to fix this?

I'm using Material UI 4.6.1

@htkcodes
Copy link

Having the same issue.

@robert-levy
Copy link

Really annoying. Can't get rid of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to set the color in inputs from the theme colors
7 participants