-
-
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.
[Rating] Fix readOnly + precision combination (#19414)
- Loading branch information
1 parent
95d9c78
commit 7e97de3
Showing
7 changed files
with
83 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
import React from 'react'; | ||
import Rating from '@material-ui/lab/Rating'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
root: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
'& > * + *': { | ||
marginTop: theme.spacing(1), | ||
}, | ||
}, | ||
})); | ||
|
||
export default function HalfRating() { | ||
return <Rating name="half-rating" defaultValue={2.5} precision={0.5} />; | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Rating name="half-rating" defaultValue={2.5} precision={0.5} /> | ||
<Rating name="half-rating-read" defaultValue={2.5} precision={0.5} readOnly /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
import React from 'react'; | ||
import Rating from '@material-ui/lab/Rating'; | ||
import { makeStyles, Theme, createStyles } from '@material-ui/core/styles'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
root: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
'& > * + *': { | ||
marginTop: theme.spacing(1), | ||
}, | ||
}, | ||
}), | ||
); | ||
|
||
export default function HalfRating() { | ||
return <Rating name="half-rating" defaultValue={2.5} precision={0.5} />; | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Rating name="half-rating" defaultValue={2.5} precision={0.5} /> | ||
<Rating name="half-rating-read" defaultValue={2.5} precision={0.5} readOnly /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import React from 'react'; | ||
import Box from '@material-ui/core/Box'; | ||
import Rating from '@material-ui/lab/Rating'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
root: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
'& > * + *': { | ||
marginTop: theme.spacing(1), | ||
}, | ||
}, | ||
})); | ||
|
||
export default function HalfRating() { | ||
const classes = useStyles(); | ||
|
||
export default function RatingSize() { | ||
return ( | ||
<Box display="flex" flexDirection="column"> | ||
<div className={classes.root}> | ||
<Rating name="size-small" defaultValue={2} size="small" /> | ||
<Rating name="size-medium" defaultValue={2} /> | ||
<Rating name="size-large" defaultValue={2} size="large" /> | ||
</Box> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import React from 'react'; | ||
import Box from '@material-ui/core/Box'; | ||
import Rating from '@material-ui/lab/Rating'; | ||
import { makeStyles, Theme, createStyles } from '@material-ui/core/styles'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
root: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
'& > * + *': { | ||
marginTop: theme.spacing(1), | ||
}, | ||
}, | ||
}), | ||
); | ||
|
||
export default function HalfRating() { | ||
const classes = useStyles(); | ||
|
||
export default function RatingSize() { | ||
return ( | ||
<Box display="flex" flexDirection="column"> | ||
<div className={classes.root}> | ||
<Rating name="size-small" defaultValue={2} size="small" /> | ||
<Rating name="size-medium" defaultValue={2} /> | ||
<Rating name="size-large" defaultValue={2} size="large" /> | ||
</Box> | ||
</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