-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[docs] Remove last dependencies on makeStyles
from @material-ui/core/styles
#26246
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import * as React from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import { experimentalStyled as styled } from '@material-ui/core/styles'; | ||
import Box from '@material-ui/core/Box'; | ||
import Typography, { TypographyProps } from '@material-ui/core/Typography'; | ||
import Button from '@material-ui/core/Button'; | ||
import Container from '@material-ui/core/Container'; | ||
import Steps from 'docs/src/pages/landing/Steps'; | ||
|
@@ -32,82 +33,59 @@ function loadDependencies() { | |
loadScript('https://platform.twitter.com/widgets.js', document.querySelector('head')); | ||
} | ||
|
||
const useStyles = makeStyles( | ||
(theme) => ({ | ||
root: { | ||
flex: '1 0 100%', | ||
}, | ||
hero: { | ||
paddingTop: theme.spacing(8), | ||
color: theme.palette.primary.main, | ||
}, | ||
content: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
textAlign: 'center', | ||
paddingTop: theme.spacing(4), | ||
paddingBottom: theme.spacing(8), | ||
[theme.breakpoints.up('md')]: { | ||
paddingTop: theme.spacing(16), | ||
paddingBottom: theme.spacing(16), | ||
flexDirection: 'row', | ||
alignItems: 'flex-start', | ||
textAlign: 'left', | ||
}, | ||
}, | ||
title: { | ||
marginLeft: -12, | ||
whiteSpace: 'nowrap', | ||
letterSpacing: '.7rem', | ||
textIndent: '.7rem', | ||
fontWeight: theme.typography.fontWeightLight, | ||
[theme.breakpoints.only('xs')]: { | ||
fontSize: 28, | ||
}, | ||
}, | ||
logo: { | ||
flexShrink: 0, | ||
width: 120, | ||
height: 120, | ||
marginBottom: theme.spacing(2), | ||
[theme.breakpoints.up('md')]: { | ||
marginRight: theme.spacing(8), | ||
width: 195, | ||
height: 175, | ||
}, | ||
}, | ||
button: { | ||
marginTop: theme.spacing(4), | ||
}, | ||
social: { | ||
padding: theme.spacing(2, 0), | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
minHeight: 21, | ||
boxSizing: 'content-box', | ||
'& a': { | ||
color: theme.palette.background.paper, | ||
}, | ||
}, | ||
github: { | ||
width: 105, | ||
display: 'flex', | ||
justifyContent: 'flex-end', | ||
marginRight: theme.spacing(1), | ||
'& span': { | ||
display: 'flex', | ||
}, | ||
}, | ||
twitter: { | ||
width: 160, | ||
display: 'flex', | ||
const Content = styled(Container)(({ theme }) => ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This page is going away, it would have been simpler to change the import only (it seems). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh well.. |
||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
textAlign: 'center', | ||
paddingTop: theme.spacing(4), | ||
paddingBottom: theme.spacing(8), | ||
[theme.breakpoints.up('md')]: { | ||
paddingTop: theme.spacing(16), | ||
paddingBottom: theme.spacing(16), | ||
flexDirection: 'row', | ||
alignItems: 'flex-start', | ||
textAlign: 'left', | ||
}, | ||
})); | ||
|
||
const Title = styled(Typography)<TypographyProps & { component?: React.ElementType }>( | ||
({ theme }) => ({ | ||
marginLeft: -12, | ||
whiteSpace: 'nowrap', | ||
letterSpacing: '.7rem', | ||
textIndent: '.7rem', | ||
fontWeight: theme.typography.fontWeightLight, | ||
[theme.breakpoints.only('xs')]: { | ||
fontSize: 28, | ||
}, | ||
}), | ||
{ name: 'LandingPage' }, | ||
); | ||
|
||
const Logo = styled('img')(({ theme }) => ({ | ||
flexShrink: 0, | ||
width: 120, | ||
height: 120, | ||
marginBottom: theme.spacing(2), | ||
[theme.breakpoints.up('md')]: { | ||
marginRight: theme.spacing(8), | ||
width: 195, | ||
height: 175, | ||
}, | ||
})); | ||
|
||
const Social = styled('div')(({ theme }) => ({ | ||
padding: theme.spacing(2, 0), | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
minHeight: 21, | ||
boxSizing: 'content-box', | ||
'& a': { | ||
color: theme.palette.background.paper, | ||
}, | ||
})); | ||
|
||
interface LandingPageProps { | ||
sponsorsProps: { | ||
docs: object; | ||
|
@@ -121,43 +99,44 @@ export default function LandingPage(props: LandingPageProps) { | |
loadDependencies(); | ||
}, []); | ||
const t = useTranslate(); | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<AppFrame> | ||
<div className={classes.root}> | ||
<Box sx={{ flex: '1 0 100%' }}> | ||
<Head /> | ||
<main id="main-content" tabIndex={-1}> | ||
<div className={classes.hero}> | ||
<Container maxWidth="md" className={classes.content}> | ||
<img src="/static/logo_raw.svg" alt="" className={classes.logo} /> | ||
<Box sx={{ pt: 8, color: 'primary.main' }}> | ||
<Content maxWidth="md"> | ||
<Logo src="/static/logo_raw.svg" alt="" /> | ||
<div> | ||
<Typography | ||
variant="h3" | ||
component="h1" | ||
color="inherit" | ||
gutterBottom | ||
className={classes.title} | ||
> | ||
<Title variant="h3" component="h1" color="inherit" gutterBottom> | ||
{'MATERIAL-UI'} | ||
</Typography> | ||
</Title> | ||
<Typography variant="h5" component="p" color="inherit"> | ||
{t('strapline')} | ||
</Typography> | ||
<Button | ||
component={Link} | ||
noLinkStyle | ||
href="/getting-started/installation" | ||
className={classes.button} | ||
sx={{ mt: 4 }} | ||
variant="outlined" | ||
> | ||
{t('getStarted')} | ||
</Button> | ||
</div> | ||
</Container> | ||
</div> | ||
<div className={classes.social}> | ||
<div className={classes.github}> | ||
</Content> | ||
</Box> | ||
<Social> | ||
<Box | ||
sx={{ | ||
width: 105, | ||
display: 'flex', | ||
justifyContent: 'flex-end', | ||
mr: 1, | ||
'& span': { display: 'flex' }, | ||
}} | ||
> | ||
<a | ||
className="github-button" | ||
href="https://github.com/mui-org/material-ui" | ||
|
@@ -166,17 +145,17 @@ export default function LandingPage(props: LandingPageProps) { | |
> | ||
Star | ||
</a> | ||
</div> | ||
<div className={classes.twitter}> | ||
</Box> | ||
<Box sx={{ width: 160, display: 'flex' }}> | ||
<a | ||
className="twitter-follow-button" | ||
href="https://twitter.com/@materialui" | ||
data-show-screen-name="false" | ||
> | ||
Follow | ||
</a> | ||
</div> | ||
</div> | ||
</Box> | ||
</Social> | ||
<Pro /> | ||
<QuickWord /> | ||
<Steps /> | ||
|
@@ -186,7 +165,7 @@ export default function LandingPage(props: LandingPageProps) { | |
<Users /> | ||
</main> | ||
<AppFooter /> | ||
</div> | ||
</Box> | ||
<script | ||
type="application/ld+json" | ||
// eslint-disable-next-line react/no-danger | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import * as React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import clsx from 'clsx'; | ||
// TODO: fix import, test:regressions is failing as there is no theme in the context | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import { makeStyles } from '@material-ui/styles'; | ||
import { createTheme } from '@material-ui/core/styles'; | ||
|
||
const styles = (theme) => ({ | ||
root: { | ||
|
@@ -207,7 +207,8 @@ const styles = (theme) => ({ | |
}, | ||
}, | ||
}); | ||
const useStyles = makeStyles(styles, { name: 'MarkdownElement', flip: false }); | ||
const defaultTheme = createTheme(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the dark mode and RTL toggle? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am setting only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK my bad |
||
const useStyles = makeStyles(styles, { name: 'MarkdownElement', flip: false, defaultTheme }); | ||
|
||
const MarkdownElement = React.forwardRef(function MarkdownElement(props, ref) { | ||
const { className, renderedMarkdown, ...other } = props; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where the code is not publicly visible on docs, or styles are too complicated, I used the
defaultTheme
prop.