File tree 2 files changed +37
-13
lines changed
docs/src/pages/customization/breakpoints
2 files changed +37
-13
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import PropTypes from 'prop-types' ;
3
- import { withStyles } from '@material-ui/core/styles' ;
2
+ import { makeStyles } from '@material-ui/core/styles' ;
4
3
import Typography from '@material-ui/core/Typography' ;
5
4
import { green } from '@material-ui/core/colors' ;
6
5
7
- const styles = theme => ( {
6
+ const useStyles = makeStyles ( theme => ( {
8
7
root : {
9
8
padding : theme . spacing ( 1 ) ,
10
9
[ theme . breakpoints . down ( 'sm' ) ] : {
@@ -17,11 +16,10 @@ const styles = theme => ({
17
16
backgroundColor : green [ 500 ] ,
18
17
} ,
19
18
} ,
20
- } ) ;
21
-
22
- function MediaQuery ( props ) {
23
- const { classes } = props ;
19
+ } ) ) ;
24
20
21
+ export default function MediaQuery ( ) {
22
+ const classes = useStyles ( ) ;
25
23
return (
26
24
< div className = { classes . root } >
27
25
< Typography variant = "subtitle1" > { 'down(sm): red' } </ Typography >
@@ -30,9 +28,3 @@ function MediaQuery(props) {
30
28
</ div >
31
29
) ;
32
30
}
33
-
34
- MediaQuery . propTypes = {
35
- classes : PropTypes . object . isRequired ,
36
- } ;
37
-
38
- export default withStyles ( styles ) ( MediaQuery ) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { Theme , makeStyles , createStyles } from '@material-ui/core/styles' ;
3
+ import Typography from '@material-ui/core/Typography' ;
4
+ import { green } from '@material-ui/core/colors' ;
5
+
6
+ const useStyles = makeStyles ( ( theme : Theme ) =>
7
+ createStyles ( {
8
+ root : {
9
+ padding : theme . spacing ( 1 ) ,
10
+ [ theme . breakpoints . down ( 'sm' ) ] : {
11
+ backgroundColor : theme . palette . secondary . main ,
12
+ } ,
13
+ [ theme . breakpoints . up ( 'md' ) ] : {
14
+ backgroundColor : theme . palette . primary . main ,
15
+ } ,
16
+ [ theme . breakpoints . up ( 'lg' ) ] : {
17
+ backgroundColor : green [ 500 ] ,
18
+ } ,
19
+ } ,
20
+ } ) ,
21
+ ) ;
22
+
23
+ export default function MediaQuery ( ) {
24
+ const classes = useStyles ( ) ;
25
+ return (
26
+ < div className = { classes . root } >
27
+ < Typography variant = "subtitle1" > { 'down(sm): red' } </ Typography >
28
+ < Typography variant = "subtitle1" > { 'up(md): blue' } </ Typography >
29
+ < Typography variant = "subtitle1" > { 'up(lg): green' } </ Typography >
30
+ </ div >
31
+ ) ;
32
+ }
You can’t perform that action at this time.
0 commit comments