-
-
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.
[core] Fix TypographyStyle not allowing media queries and allowing un…
…safe undefined access (#19269)
- Loading branch information
Showing
7 changed files
with
91 additions
and
26 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
docs/src/pages/customization/typography/CustomResponsiveFontSizes.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,25 @@ | ||
import React from 'react'; | ||
import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles'; | ||
import Typography from '@material-ui/core/Typography'; | ||
|
||
const theme = createMuiTheme(); | ||
|
||
theme.typography.h3 = { | ||
fontSize: '1.2rem', | ||
'@media (min-width:600px)': { | ||
fontSize: '1.5rem', | ||
}, | ||
[theme.breakpoints.up('md')]: { | ||
fontSize: '2rem', | ||
}, | ||
}; | ||
|
||
export default function ResponsiveFontSizes() { | ||
return ( | ||
<div> | ||
<ThemeProvider theme={theme}> | ||
<Typography variant="h3">Responsive h3</Typography> | ||
</ThemeProvider> | ||
</div> | ||
); | ||
} |
25 changes: 25 additions & 0 deletions
25
docs/src/pages/customization/typography/CustomResponsiveFontSizes.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles'; | ||
import Typography from '@material-ui/core/Typography'; | ||
|
||
const theme = createMuiTheme(); | ||
|
||
theme.typography.h3 = { | ||
fontSize: '1.2rem', | ||
'@media (min-width:600px)': { | ||
fontSize: '1.5rem', | ||
}, | ||
[theme.breakpoints.up('md')]: { | ||
fontSize: '2rem', | ||
}, | ||
}; | ||
|
||
export default function ResponsiveFontSizes() { | ||
return ( | ||
<div> | ||
<ThemeProvider theme={theme}> | ||
<Typography variant="h3">Responsive h3</Typography> | ||
</ThemeProvider> | ||
</div> | ||
); | ||
} |
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,15 @@ | ||
import { createMuiTheme } from '@material-ui/core/styles'; | ||
|
||
{ | ||
// properties of the variants can be "unset" | ||
const theme = createMuiTheme({ | ||
typography: { | ||
allVariants: { | ||
fontStyle: undefined, | ||
}, | ||
}, | ||
}); | ||
|
||
// $ExpectType string | undefined | ||
const maybeFontStyle = theme.typography.body1.fontStyle; | ||
} |
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