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

[theme] Add base color palette type to components #26697

Merged
merged 41 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4d4936d
fix AppBar color type
siriwatknp Jun 11, 2021
f3ccd6a
add color button classes
siriwatknp Jun 11, 2021
1fa7e0e
fix Checkbox color type
siriwatknp Jun 11, 2021
8b62042
fix Chip color type
siriwatknp Jun 11, 2021
2ca359c
add color type test
siriwatknp Jun 11, 2021
0c02a2f
run proptypes and docs:api
siriwatknp Jun 11, 2021
0cea9dd
fix CircularProgress color type
siriwatknp Jun 11, 2021
5cf0582
Merge branch 'next' of https://github.com/mui-org/material-ui into fi…
siriwatknp Jun 17, 2021
6e8cb80
Revert "fix AppBar color type"
siriwatknp Jun 17, 2021
d9a6611
Revert "fix CircularProgress color type"
siriwatknp Jun 17, 2021
ee6c307
run proptypes and docs:api
siriwatknp Jun 17, 2021
f00aba1
finish Badge color palette
siriwatknp Jun 17, 2021
ecf4bf6
finish TimelineDot color palette
siriwatknp Jun 17, 2021
667f32a
finish ButtonGroup color palette
siriwatknp Jun 17, 2021
64f2ab2
finish SvgIcon color palette
siriwatknp Jun 17, 2021
1f0afe0
finish IconButton color palette
siriwatknp Jun 17, 2021
7d027ba
finish LinearProgress color palette
siriwatknp Jun 17, 2021
f603edd
finish CircularProgress color palette
siriwatknp Jun 18, 2021
4368b8a
fix FormControl color palette
siriwatknp Jun 18, 2021
6dd4341
fix InputBase color palette
siriwatknp Jun 18, 2021
ad5a12b
fix Radio color palette
siriwatknp Jun 18, 2021
6505767
update Checkbox color demo
siriwatknp Jun 18, 2021
e0ee83c
fix Switch color palette
siriwatknp Jun 18, 2021
028106b
revert classes
siriwatknp Jun 18, 2021
da2ed6a
fix Icon color palette
siriwatknp Jun 18, 2021
be18f66
run docs:api and docs:formatted
siriwatknp Jun 18, 2021
c8e263b
cleanup
siriwatknp Jun 18, 2021
3c382a5
Revert "finish ButtonGroup color palette"
siriwatknp Jun 18, 2021
e65029e
run docs:api
siriwatknp Jun 18, 2021
bd62977
fix TextField color palette
siriwatknp Jun 18, 2021
f7d1504
remove ColorsButtonGroup
siriwatknp Jun 18, 2021
ada5bea
update Chip color demo
siriwatknp Jun 18, 2021
d704fca
run docs:api
siriwatknp Jun 18, 2021
fec817d
update Button color demo
siriwatknp Jun 18, 2021
8b2b4e8
fix color chip demo
siriwatknp Jun 18, 2021
5953c18
Update docs/src/pages/components/badges/badges.md
siriwatknp Jun 21, 2021
f665789
add only 'success' color to demos
siriwatknp Jun 21, 2021
acbd376
fix demos
siriwatknp Jun 21, 2021
fe1e639
reduce lines for inline preview
siriwatknp Jun 21, 2021
ca5acfd
reduce lines for inline preview
siriwatknp Jun 21, 2021
697bfec
fix naming typo
siriwatknp Jun 22, 2021
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
7 changes: 5 additions & 2 deletions docs/pages/api-docs/badge.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"color": {
"type": {
"name": "union",
"description": "'default'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'default'"
},
Expand Down Expand Up @@ -57,7 +57,10 @@
"invisible",
"colorPrimary",
"colorSecondary",
"colorError"
"colorError",
"colorInfo",
"colorSuccess",
"colorWarning"
],
"globalClasses": {},
"name": "MuiBadge"
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/checkbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"color": {
"type": {
"name": "union",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'succes'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'primary'"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/chip.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"color": {
"type": {
"name": "union",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'default'"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/circular-progress.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"color": {
"type": {
"name": "union",
"description": "'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'primary'"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/form-control.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"color": {
"type": {
"name": "union",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'primary'"
},
Expand Down
7 changes: 6 additions & 1 deletion docs/pages/api-docs/form-label.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"props": {
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" } },
"color": { "type": { "name": "enum", "description": "'primary'<br>&#124;&nbsp;'secondary'" } },
"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'"
}
},
"component": { "type": { "name": "elementType" } },
"disabled": { "type": { "name": "bool" } },
"error": { "type": { "name": "bool" } },
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/icon-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"color": {
"type": {
"name": "union",
"description": "'inherit'<br>&#124;&nbsp;'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'inherit'<br>&#124;&nbsp;'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'default'"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/icon.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"color": {
"type": {
"name": "union",
"description": "'action'<br>&#124;&nbsp;'disabled'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'inherit'<br>&#124;&nbsp;'action'<br>&#124;&nbsp;'disabled'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'inherit'"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/input-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"color": {
"type": {
"name": "union",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
}
},
"components": {
Expand Down
7 changes: 6 additions & 1 deletion docs/pages/api-docs/input-label.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"props": {
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" } },
"color": { "type": { "name": "enum", "description": "'primary'<br>&#124;&nbsp;'secondary'" } },
"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'"
}
},
"disableAnimation": { "type": { "name": "bool" } },
"disabled": { "type": { "name": "bool" } },
"error": { "type": { "name": "bool" } },
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/radio.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"color": {
"type": {
"name": "union",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'primary'"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/svg-icon.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"color": {
"type": {
"name": "union",
"description": "'action'<br>&#124;&nbsp;'disabled'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'inherit'<br>&#124;&nbsp;'action'<br>&#124;&nbsp;'disabled'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'inherit'"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/switch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"color": {
"type": {
"name": "union",
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'default'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'primary'"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/text-field.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"color": {
"type": {
"name": "union",
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;string"
"description": "'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'<br>&#124;&nbsp;string"
},
"default": "'primary'"
},
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/api-docs/timeline-dot.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"color": {
"type": {
"name": "enum",
"description": "'grey'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'"
"description": "'error'<br>&#124;&nbsp;'grey'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'"
},
"default": "'grey'"
},
Expand Down
18 changes: 18 additions & 0 deletions docs/src/pages/components/badges/ColorBadge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import Badge from '@material-ui/core/Badge';
import Stack from '@material-ui/core/Stack';
import MailIcon from '@material-ui/icons/Mail';

export default function ColorBadge() {
return (
<Stack spacing={2} direction="row">
{['primary', 'secondary', 'error', 'info', 'success', 'warning'].map(
(color) => (
<Badge badgeContent={4} color={color}>
<MailIcon color="action" />
</Badge>
),
)}
</Stack>
);
}
18 changes: 18 additions & 0 deletions docs/src/pages/components/badges/ColorBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as React from 'react';
import Badge from '@material-ui/core/Badge';
import Stack from '@material-ui/core/Stack';
import MailIcon from '@material-ui/icons/Mail';

export default function ColorBadge() {
return (
<Stack spacing={2} direction="row">
{(
['primary', 'secondary', 'error', 'info', 'success', 'warning'] as const
).map((color) => (
<Badge badgeContent={4} color={color}>
<MailIcon color="action" />
</Badge>
))}
</Stack>
);
}
12 changes: 3 additions & 9 deletions docs/src/pages/components/badges/SimpleBadge.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import * as React from 'react';
import Stack from '@material-ui/core/Stack';
import Badge from '@material-ui/core/Badge';
import MailIcon from '@material-ui/icons/Mail';

export default function SimpleBadge() {
return (
<Stack spacing={4} direction="row" sx={{ color: 'action.active' }}>
<Badge badgeContent={4} color="secondary">
<MailIcon />
</Badge>
<Badge badgeContent={4} color="error">
<MailIcon />
</Badge>
</Stack>
<Badge badgeContent={4} color="primary">
<MailIcon color="action" />
</Badge>
);
}
12 changes: 3 additions & 9 deletions docs/src/pages/components/badges/SimpleBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import * as React from 'react';
import Stack from '@material-ui/core/Stack';
import Badge from '@material-ui/core/Badge';
import MailIcon from '@material-ui/icons/Mail';

export default function SimpleBadge() {
return (
<Stack spacing={4} direction="row" sx={{ color: 'action.active' }}>
<Badge badgeContent={4} color="secondary">
<MailIcon />
</Badge>
<Badge badgeContent={4} color="error">
<MailIcon />
</Badge>
</Stack>
<Badge badgeContent={4} color="primary">
<MailIcon color="action" />
</Badge>
);
}
6 changes: 6 additions & 0 deletions docs/src/pages/components/badges/badges.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Examples of badges containing text, using primary and secondary colors. The badg

{{"demo": "pages/components/badges/SimpleBadge.js"}}

## Color Badge
siriwatknp marked this conversation as resolved.
Show resolved Hide resolved

Use `color` prop to apply theme color palette to component.

{{"demo": "pages/components/badges/ColorBadge.js"}}

## Customized badges

Here is an example of customizing the component. You can learn more about this in the [overrides documentation page](/customization/how-to-customize/).
Expand Down
76 changes: 71 additions & 5 deletions docs/src/pages/components/buttons/ColorButtons.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,83 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import Box from '@material-ui/core/Box';
import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import Tooltip from '@material-ui/core/Tooltip';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';

const ColorSelector = ({ color, setColor }) => {
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
return (
<span>
<Tooltip title="Change color">
<IconButton
onClick={(event) => setAnchorEl(event.currentTarget)}
id="color-button"
aria-controls="color-menu"
aria-haspopup="true"
aria-expanded={open ? 'true' : undefined}
sx={{ lineHeight: 1 }}
color="inherit"
>
🎨
</IconButton>
</Tooltip>
<Menu
id="color-menu"
variant="selectedMenu"
anchorEl={anchorEl}
open={open}
onClose={() => setAnchorEl(null)}
MenuListProps={{
'aria-labelledby': 'color-button',
}}
>
{['primary', 'secondary', 'error', 'info', 'success', 'warning'].map(
(item) => (
<MenuItem
key={item}
selected={item === color}
onClick={() => {
setColor(item);
setAnchorEl(null);
}}
>
{item}
</MenuItem>
),
)}
</Menu>
</span>
);
};

ColorSelector.propTypes = {
color: PropTypes.oneOf([
'error',
'info',
'primary',
'secondary',
'success',
'warning',
]).isRequired,
setColor: PropTypes.func.isRequired,
};

export default function ColorButtons() {
const [color, setColor] = React.useState('secondary');
return (
<Box sx={{ '& > :not(style)': { m: 1 } }}>
<Button color="secondary">Secondary</Button>
<Button variant="contained" color="secondary">
Secondary
<Button color={color}>{color}</Button>
<Button variant="contained" color={color}>
{color}
</Button>
<Button variant="outlined" color="secondary">
Secondary
<Button variant="outlined" color={color}>
{color}
</Button>
<ColorSelector color={color} setColor={setColor} />
</Box>
);
}
Loading