-
-
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.
[docs] Improve Style Library Interoperability
- Loading branch information
1 parent
5c84559
commit 30d41f0
Showing
9 changed files
with
382 additions
and
223 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
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
61 changes: 25 additions & 36 deletions
61
docs/src/pages/guides/interoperability/StyledComponentsTheme.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,57 +1,46 @@ | ||
import React from 'react'; | ||
import styled, { ThemeProvider } from 'styled-components'; | ||
import NoSsr from '@material-ui/core/NoSsr'; | ||
import { createMuiTheme, darken, fade } from '@material-ui/core/styles'; | ||
import { | ||
createMuiTheme, | ||
ThemeProvider as MuiThemeProvider, | ||
darken, | ||
} from '@material-ui/core/styles'; | ||
import Button from '@material-ui/core/Button'; | ||
|
||
const defaultTheme = createMuiTheme(); | ||
const theme = createMuiTheme({ | ||
palette: { | ||
primary: { | ||
main: '#6772e5', | ||
}, | ||
}, | ||
}); | ||
|
||
const StyledButton = styled.button` | ||
const StyledButton = styled(Button)` | ||
${({ theme }) => ` | ||
padding: 8px 12px; | ||
border: 1px solid; | ||
cursor: pointer; | ||
outline: 0; | ||
border-radius: ${theme.shape.borderRadius}px; | ||
color: ${theme.palette.primary.contrastText}; | ||
background-color: ${theme.palette.primary.main}; | ||
border-color: ${theme.palette.primary.main}; | ||
transition: ${theme.transitions.create(['background-color', 'box-shadow'])}; | ||
font-family: ${[ | ||
'-apple-system', | ||
'BlinkMacSystemFont', | ||
'"Segoe UI"', | ||
'Roboto', | ||
'"Helvetica Neue"', | ||
'Arial', | ||
'sans-serif', | ||
'"Apple Color Emoji"', | ||
'"Segoe UI Emoji"', | ||
'"Segoe UI Symbol"', | ||
].join(',')}; | ||
color: #fff; | ||
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08); | ||
padding: 4px 10px; | ||
font-size: 13px; | ||
&:hover { | ||
background-color: ${darken(theme.palette.primary.main, 0.1)}; | ||
border-color: ${darken(theme.palette.primary.main, 0.2)}; | ||
} | ||
&:active { | ||
background-color: ${darken(theme.palette.primary.main, 0.2)}; | ||
border-color: ${darken(theme.palette.primary.main, 0.3)}; | ||
} | ||
&:focus { | ||
box-shadow: 0 0 0 0.2rem ${fade(theme.palette.primary.main, 0.5)}; | ||
} | ||
font-size: 18px; | ||
${theme.breakpoints.up('md')} { | ||
font-size: 16px; | ||
font-size: 14px; | ||
padding: 7px 14px; | ||
} | ||
`} | ||
`; | ||
|
||
export default function StyledComponentsTheme() { | ||
return ( | ||
<NoSsr> | ||
<ThemeProvider theme={defaultTheme}> | ||
<StyledButton>Styled Components</StyledButton> | ||
</ThemeProvider> | ||
<MuiThemeProvider theme={theme}> | ||
<ThemeProvider theme={theme}> | ||
<StyledButton>Styled Components</StyledButton> | ||
</ThemeProvider> | ||
</MuiThemeProvider> | ||
</NoSsr> | ||
); | ||
} |
61 changes: 25 additions & 36 deletions
61
docs/src/pages/guides/interoperability/StyledComponentsTheme.tsx
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,57 +1,46 @@ | ||
import React from 'react'; | ||
import styled, { ThemeProvider } from 'styled-components'; | ||
import NoSsr from '@material-ui/core/NoSsr'; | ||
import { createMuiTheme, darken, fade } from '@material-ui/core/styles'; | ||
import { | ||
createMuiTheme, | ||
ThemeProvider as MuiThemeProvider, | ||
darken, | ||
} from '@material-ui/core/styles'; | ||
import Button from '@material-ui/core/Button'; | ||
|
||
const defaultTheme = createMuiTheme(); | ||
const theme = createMuiTheme({ | ||
palette: { | ||
primary: { | ||
main: '#6772e5', | ||
}, | ||
}, | ||
}); | ||
|
||
const StyledButton = styled.button` | ||
const StyledButton = styled(Button)` | ||
${({ theme }) => ` | ||
padding: 8px 12px; | ||
border: 1px solid; | ||
cursor: pointer; | ||
outline: 0; | ||
border-radius: ${theme.shape.borderRadius}px; | ||
color: ${theme.palette.primary.contrastText}; | ||
background-color: ${theme.palette.primary.main}; | ||
border-color: ${theme.palette.primary.main}; | ||
transition: ${theme.transitions.create(['background-color', 'box-shadow'])}; | ||
font-family: ${[ | ||
'-apple-system', | ||
'BlinkMacSystemFont', | ||
'"Segoe UI"', | ||
'Roboto', | ||
'"Helvetica Neue"', | ||
'Arial', | ||
'sans-serif', | ||
'"Apple Color Emoji"', | ||
'"Segoe UI Emoji"', | ||
'"Segoe UI Symbol"', | ||
].join(',')}; | ||
color: #fff; | ||
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08); | ||
padding: 4px 10px; | ||
font-size: 13px; | ||
&:hover { | ||
background-color: ${darken(theme.palette.primary.main, 0.1)}; | ||
border-color: ${darken(theme.palette.primary.main, 0.2)}; | ||
} | ||
&:active { | ||
background-color: ${darken(theme.palette.primary.main, 0.2)}; | ||
border-color: ${darken(theme.palette.primary.main, 0.3)}; | ||
} | ||
&:focus { | ||
box-shadow: 0 0 0 0.2rem ${fade(theme.palette.primary.main, 0.5)}; | ||
} | ||
font-size: 18px; | ||
${theme.breakpoints.up('md')} { | ||
font-size: 16px; | ||
font-size: 14px; | ||
padding: 7px 14px; | ||
} | ||
`} | ||
`; | ||
|
||
export default function StyledComponentsTheme() { | ||
return ( | ||
<NoSsr> | ||
<ThemeProvider theme={defaultTheme}> | ||
<StyledButton>Styled Components</StyledButton> | ||
</ThemeProvider> | ||
<MuiThemeProvider theme={theme}> | ||
<ThemeProvider theme={theme}> | ||
<StyledButton>Styled Components</StyledButton> | ||
</ThemeProvider> | ||
</MuiThemeProvider> | ||
</NoSsr> | ||
); | ||
} |
Oops, something went wrong.