-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[examples] Update examples to use StyledEngineProvider (#24489)
- Loading branch information
Showing
23 changed files
with
176 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 25 additions & 8 deletions
33
examples/create-react-app-with-styled-components/src/App.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
import * as React from 'react'; | ||
import Slider from '@material-ui/core/Slider'; | ||
import Container from '@material-ui/core/Container'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Box from '@material-ui/core/Box'; | ||
import Link from '@material-ui/core/Link'; | ||
import ProTip from './ProTip'; | ||
|
||
function Copyright() { | ||
return ( | ||
<Typography variant="body2" color="textSecondary" align="center"> | ||
{'Copyright © '} | ||
<Link color="inherit" href="https://material-ui.com/"> | ||
Your Website | ||
</Link>{' '} | ||
{new Date().getFullYear()}. | ||
</Typography> | ||
); | ||
} | ||
|
||
export default function App() { | ||
return ( | ||
<div> | ||
<Typography>Styled slider powered by styled-components</Typography> | ||
<Slider defaultValue={30} color="primary" /> | ||
<Slider defaultValue={30} color="secondary" /> | ||
<Slider defaultValue={30} disabled /> | ||
<Slider defaultValue={30} valueLabelDisplay="auto" step={10} marks min={10} max={110} /> | ||
</div> | ||
<Container maxWidth="sm"> | ||
<Box sx={{ my: 4 }}> | ||
<Typography variant="h4" component="h1" gutterBottom> | ||
Create React App v5-alpha example with TypeScript | ||
</Typography> | ||
<ProTip /> | ||
<Copyright /> | ||
</Box> | ||
</Container> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
examples/create-react-app-with-styled-components/src/ProTip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as React from 'react'; | ||
import Link from '@material-ui/core/Link'; | ||
import SvgIcon from '@material-ui/core/SvgIcon'; | ||
import Typography from '@material-ui/core/Typography'; | ||
|
||
function LightBulbIcon(props) { | ||
return ( | ||
<SvgIcon {...props}> | ||
<path d="M9 21c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-1H9v1zm3-19C8.14 2 5 5.14 5 9c0 2.38 1.19 4.47 3 5.74V17c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2.26c1.81-1.27 3-3.36 3-5.74 0-3.86-3.14-7-7-7zm2.85 11.1l-.85.6V16h-4v-2.3l-.85-.6C7.8 12.16 7 10.63 7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 1.63-.8 3.16-2.15 4.1z" /> | ||
</SvgIcon> | ||
); | ||
} | ||
|
||
export default function ProTip() { | ||
return ( | ||
<Typography sx={{ mt: 6, mb: 3 }} color="textSecondary"> | ||
<LightBulbIcon sx={{ mr: 1, verticalAlign: 'middle' }} /> | ||
Pro tip: See more{' '} | ||
<Link href="https://material-ui.com/getting-started/templates/">templates</Link> on the | ||
Material-UI documentation. | ||
</Typography> | ||
); | ||
} |
9 changes: 7 additions & 2 deletions
9
examples/create-react-app-with-styled-components/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
import * as React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import CssBaseline from '@material-ui/core/CssBaseline'; | ||
import StyledEngineProvider from '@material-ui/core/StyledEngineProvider'; | ||
import { ThemeProvider } from '@material-ui/core/styles'; | ||
import App from './App'; | ||
import theme from './theme'; | ||
|
||
ReactDOM.render( | ||
<ThemeProvider theme={theme}> | ||
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */} | ||
<CssBaseline /> | ||
<App /> | ||
</ThemeProvider>, | ||
// TODO v5: remove once migration to emotion is completed | ||
<StyledEngineProvider injectFirst> | ||
<ThemeProvider theme={theme}> | ||
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */} | ||
<CssBaseline /> | ||
<App /> | ||
</ThemeProvider> | ||
</StyledEngineProvider>, | ||
document.querySelector('#root'), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
import * as React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import StyledEngineProvider from '@material-ui/core/StyledEngineProvider'; | ||
import CssBaseline from '@material-ui/core/CssBaseline'; | ||
import { ThemeProvider } from '@material-ui/core/styles'; | ||
import App from './App'; | ||
import theme from './theme'; | ||
|
||
ReactDOM.render( | ||
<ThemeProvider theme={theme}> | ||
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */} | ||
<CssBaseline /> | ||
<App /> | ||
</ThemeProvider>, | ||
// TODO v5: remove once migration to emotion is completed | ||
<StyledEngineProvider injectFirst> | ||
<ThemeProvider theme={theme}> | ||
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */} | ||
<CssBaseline /> | ||
<App /> | ||
</ThemeProvider> | ||
</StyledEngineProvider>, | ||
document.querySelector('#root'), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.