Skip to content

Commit

Permalink
[docs] Fix Theme nesting demo in codesandbox (#12097)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Jul 9, 2018
1 parent d205e2d commit ed6f165
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
12 changes: 6 additions & 6 deletions docs/src/pages/customization/css-in-js/JssRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ class JssRegistry extends React.Component {

render() {
return (
<JssProvider registry={sheetsRegistry}>
<MuiThemeProvider theme={theme}>
<div>
<div>
<JssProvider registry={sheetsRegistry}>
<MuiThemeProvider theme={theme}>
<CssInJs />
<br />
{'We are collecting all the sheets injected in the DOM.'}
<br />
{`The size of the registry is ${this.state.length}.`}
</div>
</MuiThemeProvider>
</JssProvider>
</MuiThemeProvider>
</JssProvider>
</div>
);
}
}
Expand Down
14 changes: 7 additions & 7 deletions docs/src/pages/customization/overrides/DynamicThemeNesting.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import Button from '@material-ui/core/Button';
import { MuiThemeProvider } from '@material-ui/core/styles';
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import blue from '@material-ui/core/colors/blue';
import Switch from '@material-ui/core/Switch';

const defaultTheme = createMuiTheme();

class DynamicThemeNesting extends React.Component {
state = {
color: 'default',
Expand All @@ -29,21 +31,19 @@ class DynamicThemeNesting extends React.Component {
label="Blue"
/>
<MuiThemeProvider
theme={theme =>
theme={
this.state.color === 'blue'
? {
...theme,
...defaultTheme,
palette: {
...theme.palette,
...defaultTheme.palette,
secondary: {
light: blue[300],
main: blue[500],
dark: blue[700],
contrastText: '#fff',
},
},
}
: theme
: defaultTheme
}
>
<Button variant="raised" color="secondary">
Expand Down
14 changes: 6 additions & 8 deletions docs/src/pages/customization/themes/Nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@ const theme3 = outerTheme => ({
function Nested() {
return (
<MuiThemeProvider theme={theme1}>
<div>
<NestedCheckbox />
<MuiThemeProvider theme={theme2}>
<NestedCheckbox />
<MuiThemeProvider theme={theme2}>
<NestedCheckbox />
</MuiThemeProvider>
<MuiThemeProvider theme={theme3}>
<NestedCheckbox />
</MuiThemeProvider>
</div>
</MuiThemeProvider>
<MuiThemeProvider theme={theme3}>
<NestedCheckbox />
</MuiThemeProvider>
</MuiThemeProvider>
);
}
Expand Down
6 changes: 2 additions & 4 deletions docs/src/pages/customization/themes/Palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ const theme = createMuiTheme({
function Palette() {
return (
<MuiThemeProvider theme={theme}>
<div>
<Button color="primary">Primary</Button>
<Button color="secondary">Secondary</Button>
</div>
<Button color="primary">Primary</Button>
<Button color="secondary">Secondary</Button>
</MuiThemeProvider>
);
}
Expand Down
1 change: 0 additions & 1 deletion packages/material-ui/src/styles/MuiThemeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class MuiThemeProvider extends React.Component {
'Material-UI: you are providing a theme function property ' +
'to the MuiThemeProvider component:',
'<MuiThemeProvider theme={outerTheme => outerTheme} />',
'',
'However, no outer theme is present.',
'Make sure a theme is already injected higher in the React tree ' +
'or provide a theme object.',
Expand Down

0 comments on commit ed6f165

Please sign in to comment.