-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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 695cb3f
Showing
12 changed files
with
513 additions
and
238 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** @jsx jsx */ | ||
import { jsx, css } from '@emotion/core'; | ||
import Button from '@material-ui/core/Button'; | ||
import { ThemeProvider } from 'emotion-theming'; | ||
import { | ||
createMuiTheme, | ||
ThemeProvider as MuiThemeProvider, | ||
darken, | ||
} from '@material-ui/core/styles'; | ||
|
||
const customTheme = createMuiTheme({ | ||
palette: { | ||
primary: { | ||
main: '#6772e5', | ||
}, | ||
}, | ||
}); | ||
|
||
export default function EmotionTheme() { | ||
return ( | ||
<MuiThemeProvider theme={customTheme}> | ||
<ThemeProvider theme={customTheme}> | ||
<Button>Default</Button> | ||
<Button | ||
css={theme => css` | ||
background-color: ${theme.palette.primary.main}; | ||
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.2)}; | ||
} | ||
${theme.breakpoints.up('sm')} { | ||
font-size: 14px; | ||
padding: 7px 14px; | ||
} | ||
`} | ||
> | ||
Customized | ||
</Button> | ||
</ThemeProvider> | ||
</MuiThemeProvider> | ||
); | ||
} |
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,45 @@ | ||
/** @jsx jsx */ | ||
import { jsx, css } from '@emotion/core'; | ||
import Button from '@material-ui/core/Button'; | ||
import { ThemeProvider } from 'emotion-theming'; | ||
import { | ||
createMuiTheme, | ||
ThemeProvider as MuiThemeProvider, | ||
darken, | ||
} from '@material-ui/core/styles'; | ||
|
||
const customTheme = createMuiTheme({ | ||
palette: { | ||
primary: { | ||
main: '#6772e5', | ||
}, | ||
}, | ||
}); | ||
|
||
export default function EmotionTheme() { | ||
return ( | ||
<MuiThemeProvider theme={customTheme}> | ||
<ThemeProvider theme={customTheme}> | ||
<Button>Default</Button> | ||
<Button | ||
css={theme => css` | ||
background-color: ${theme.palette.primary.main}; | ||
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.2)}; | ||
} | ||
${theme.breakpoints.up('sm')} { | ||
font-size: 14px; | ||
padding: 7px 14px; | ||
} | ||
`} | ||
> | ||
Customized | ||
</Button> | ||
</ThemeProvider> | ||
</MuiThemeProvider> | ||
); | ||
} |
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
64 changes: 27 additions & 37 deletions
64
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,47 @@ | ||
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 customTheme = 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; | ||
${theme.breakpoints.up('sm')} { | ||
font-size: 14px; | ||
padding: 7px 14px; | ||
} | ||
`} | ||
`; | ||
|
||
export default function StyledComponentsTheme() { | ||
return ( | ||
<NoSsr> | ||
<ThemeProvider theme={defaultTheme}> | ||
<StyledButton>Styled Components</StyledButton> | ||
</ThemeProvider> | ||
<MuiThemeProvider theme={customTheme}> | ||
<ThemeProvider theme={customTheme}> | ||
<Button>Default</Button> | ||
<StyledButton>Customized</StyledButton> | ||
</ThemeProvider> | ||
</MuiThemeProvider> | ||
</NoSsr> | ||
); | ||
} |
Oops, something went wrong.