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] Rename theme keys to defaultProps and styleOverrides #22347

Merged
merged 21 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
28 changes: 14 additions & 14 deletions docs/src/modules/components/ThemeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,30 @@ const themeInitialOptions = {
const highDensity = {
components: {
MuiButton: {
props: {
defaultProps: {
size: 'small',
},
},
MuiFilledInput: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiFormControl: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiFormHelperText: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiIconButton: {
props: {
defaultProps: {
size: 'small',
},
overrides: {
cssOverrides: {
sizeSmall: {
// minimal touch target hit spacing
marginLeft: 4,
Expand All @@ -71,42 +71,42 @@ const highDensity = {
},
},
MuiInputBase: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiInputLabel: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiListItem: {
props: {
defaultProps: {
dense: true,
},
},
MuiOutlinedInput: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiFab: {
props: {
prdefaultPropsops: {
size: 'small',
},
},
MuiTable: {
props: {
defaultProps: {
size: 'small',
},
},
MuiTextField: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiToolbar: {
props: {
defaultProps: {
variant: 'dense',
},
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/about-the-lab/about-the-lab.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import '@material-ui/lab/themeAugmentation';
const theme = createMuiTheme({
components: {
MuiTimeline: {
overrides: {
cssOverrides: {
root: {
backgroundColor: 'red',
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/typography/typography.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ It’s important to realize that the style of a typography component is independ
const theme = createMuiTheme({
components: {
MuiTypography: {
props: {
defaultProps: {
variantMapping: {
h1: 'h2',
h2: 'h2',
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/use-media-query/ServerSide.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ServerSide() {
components: {
MuiUseMediaQuery: {
// Change the default options of useMediaQuery
props: { ssrMatchMedia },
defaultProps: { ssrMatchMedia },
},
},
}}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/use-media-query/ServerSide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ServerSide() {
components: {
MuiUseMediaQuery: {
// Change the default options of useMediaQuery
props: { ssrMatchMedia },
defaultProps: { ssrMatchMedia },
},
},
}}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/breakpoints/breakpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const theme = createMuiTheme({
components: {
// withWidth component ⚛️
MuiWithWidth: {
props: {
defaultProps: {
// Initial width prop
initialWidth: 'lg', // Breakpoint being globally set 🌎!
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Button from '@material-ui/core/Button';
const theme = createMuiTheme({
components: {
MuiButton: {
overrides: {
cssOverrides: {
root: {
fontSize: '1rem',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Button from '@material-ui/core/Button';
const theme = createMuiTheme({
components: {
MuiButton: {
overrides: {
cssOverrides: {
root: {
fontSize: '1rem',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,28 @@ const theme = createMuiTheme({
variants: [
{
props: { variant: 'dashed' },
styles: {
css: {
textTransform: 'none',
border: `2px dashed ${defaultTheme.palette.primary.main}`,
color: defaultTheme.palette.primary.main,
},
},
{
props: { variant: 'dashed', color: 'secondary' },
styles: {
css: {
border: `2px dashed ${defaultTheme.palette.secondary.main}`,
color: defaultTheme.palette.secondary.main,
},
},
{
props: { variant: 'dashed', size: 'large' },
styles: {
css: {
borderWidth: 4,
},
},
{
props: { variant: 'dashed', color: 'secondary', size: 'large' },
styles: {
css: {
fontSize: 18,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ const theme = createMuiTheme({
variants: [
{
props: { variant: 'dashed' },
styles: {
css: {
textTransform: 'none',
border: `2px dashed ${defaultTheme.palette.primary.main}`,
color: defaultTheme.palette.primary.main,
},
},
{
props: { variant: 'dashed', color: 'secondary' },
styles: {
css: {
border: `2px dashed ${defaultTheme.palette.secondary.main}`,
color: defaultTheme.palette.secondary.main,
},
},
{
props: { variant: 'dashed', size: 'large' },
styles: {
css: {
borderWidth: 4,
},
},
{
props: { variant: 'dashed', color: 'secondary', size: 'large' },
styles: {
css: {
fontSize: 18,
},
},
Expand Down
8 changes: 4 additions & 4 deletions docs/src/pages/customization/components/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ Learn more about it in the [themes section](/customization/globals/#css) of the
const theme = createMuiTheme({
components: {
MuiButton: {
overrides: {
cssOverrides: {
root: {
fontSize: '1rem',
},
Expand All @@ -323,7 +323,7 @@ const theme = createMuiTheme({

### Adding new component variants

You can take advantage of the `variants` key in the `theme` to add new variants to Material-UI components. These new variants, can specify which styles the component should have, if specific props are defined together.
You can take advantage of the `variants` key in the `theme`'s components section to add new variants to Material-UI components. These new variants, can specify which styles the component should have, if specific props are defined together.

The definitions are specified in an array, under the component's name. For every one of them a class is added in the head. The order is **important**, so make sure that the styles that should win will be specified lastly.

Expand All @@ -334,14 +334,14 @@ const theme = createMuiTheme({
variants: [
{
props: { variant: 'dashed' },
styles: {
css: {
textTransform: 'none',
border: `2px dashed grey${blue[500]}`,
},
},
{
props: { variant: 'dashed', color: 'secondary' },
styles: {
css: {
border: `4px dashed ${red[500]}`,
},
},
Expand Down
28 changes: 14 additions & 14 deletions docs/src/pages/customization/density/density.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,30 @@ The theme is configured with the following options:
const theme = createMuiTheme({
components: {
MuiButton: {
props: {
defaultProps: {
size: 'small',
},
},
MuiFilledInput: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiFormControl: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiFormHelperText: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiIconButton: {
props: {
defaultProps: {
size: 'small',
},
overrides: {
cssOverrides: {
sizeSmall: {
// Adjust spacing to reach minimal touch target hitbox
marginLeft: 4,
Expand All @@ -81,42 +81,42 @@ const theme = createMuiTheme({
},
},
MuiInputBase: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiInputLabel: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiListItem: {
props: {
defaultProps: {
dense: true,
},
},
MuiOutlinedInput: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiFab: {
props: {
defaultProps: {
size: 'small',
},
},
MuiTable: {
props: {
defaultProps: {
size: 'small',
},
},
MuiTextField: {
props: {
defaultProps: {
margin: 'dense',
},
},
MuiToolbar: {
props: {
defaultProps: {
variant: 'dense',
},
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/globals/DefaultProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const theme = createMuiTheme({
components: {
// Name of the component ⚛️
MuiButtonBase: {
props: {
defaultProps: {
// The default props to change
disableRipple: true, // No more ripple, on the whole application 💣!
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/globals/DefaultProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const theme = createMuiTheme({
components: {
// Name of the component ⚛️
MuiButtonBase: {
props: {
defaultProps: {
// The default props to change
disableRipple: true, // No more ripple, on the whole application 💣!
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/globals/GlobalCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const theme = createMuiTheme({
components: {
MuiButton: {
// Style sheet name ⚛️
overrides: {
cssOverrides: {
// Name of the rule
textPrimary: {
// Some CSS
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/customization/globals/GlobalCss.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const theme = createMuiTheme({
components: {
MuiButton: {
// Style sheet name ⚛️
overrides: {
cssOverrides: {
// Name of the rule
textPrimary: {
// Some CSS
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/customization/globals/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ return (
## Default props

You can change the default props of all the Material-UI components.
A `props` key is exposed in the `theme` for this use case.
A `deafaultProps` key is exposed in the `theme`'s components key for this use case.

To override lab components styles with TypeScript, check [this documentation](/components/about-the-lab/#typescript).

Expand All @@ -73,7 +73,7 @@ const theme = createMuiTheme({
components: {
// Name of the component ⚛️
MuiButtonBase: {
props: {
defaultProps: {
// The default props to change
disableRipple: true, // No more ripple, on the whole application 💣!
},
Expand Down
Loading