1- import React from 'react' ;
21import {
3- Grid ,
4- Typography ,
5- Hidden ,
62 Box ,
73 Collapse ,
8- IconButton
4+ Grid ,
5+ Hidden ,
6+ IconButton ,
7+ makeStyles ,
8+ Typography
99} from '@material-ui/core' ;
10- import ExpandLessIcon from '@material-ui/icons/ExpandLess' ;
1110import ExpandMoreIcon from '@material-ui/icons/ExpandMore' ;
11+ import clsx from 'clsx' ;
12+ import React from 'react' ;
13+
14+ const useStyles = makeStyles ( theme => ( {
15+ expand : {
16+ transform : 'rotate(0deg)' ,
17+ marginLeft : 'auto' ,
18+ transition : theme . transitions . create ( 'transform' , {
19+ duration : theme . transitions . duration . short
20+ } )
21+ } ,
22+ expandOpen : {
23+ transform : 'rotate(180deg)'
24+ }
25+ } ) ) ;
1226
1327export default function Topics ( { course } ) {
1428 return (
@@ -47,6 +61,7 @@ export default function Topics({ course }) {
4761
4862function TopicDropBox ( { topic, topicIndex } ) {
4963 const [ expanded , setExpanded ] = React . useState ( false ) ;
64+ const classes = useStyles ( ) ;
5065
5166 return (
5267 < Box
@@ -58,9 +73,6 @@ function TopicDropBox({ topic, topicIndex }) {
5873 margin : '8px 0px' ,
5974 flexDirection : 'column'
6075 } }
61- onClick = { ( ) => {
62- setExpanded ( ! expanded ) ;
63- } }
6476 >
6577 < Box
6678 display = "flex"
@@ -77,31 +89,45 @@ function TopicDropBox({ topic, topicIndex }) {
7789 width : '100%'
7890 } }
7991 >
80- < Box fontWeight = { 500 } > { `Topic ${ topicIndex + 1 } : ${
92+ < Box fontWeight = { 500 } > { `Topic ${ topicIndex + 1 } : ${
8193 topic . title
8294 } `} </ Box >
8395 </ Typography >
8496 < Hidden xsDown >
8597 < Box
8698 display = "flex"
8799 alignItems = "center"
100+ justifyContent = "flex-end"
88101 style = { {
89- width : '200px' ,
102+ width : '180px' ,
103+ whiteSpace : 'nowrap' ,
90104 color : '#A60000'
91105 } }
92106 >
93- < Typography variant = "body1" >
107+ < Typography align = "left" variant = "body1" style = { { width : '100%' } } >
94108 < Box > { topic . classes } </ Box >
95109 </ Typography >
96- < IconButton >
97- { expanded ? < ExpandLessIcon /> : < ExpandMoreIcon /> }
110+ < IconButton
111+ onClick = { ( ) => {
112+ setExpanded ( ! expanded ) ;
113+ } }
114+ >
115+ < ExpandMoreIcon
116+ className = { clsx ( classes . expand , {
117+ [ classes . expandOpen ] : expanded
118+ } ) }
119+ />
98120 </ IconButton >
99121 </ Box >
100122 </ Hidden >
101123
102124 < Hidden smUp >
103- < IconButton >
104- { expanded ? < ExpandLessIcon /> : < ExpandMoreIcon /> }
125+ < IconButton
126+ onClick = { ( ) => {
127+ setExpanded ( ! expanded ) ;
128+ } }
129+ >
130+ < ExpandMoreIcon />
105131 </ IconButton >
106132 </ Hidden >
107133 </ Box >
0 commit comments