@@ -5,6 +5,8 @@ import MuiExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
55import MuiExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary' ;
66import { withStyles } from '@material-ui/core/styles' ;
77import Typography from '@material-ui/core/Typography' ;
8+ import ExpandLessIcon from '@material-ui/icons/ExpandLess' ;
9+ import ExpandMoreIcon from '@material-ui/icons/ExpandMore' ;
810import PlayCircleOutlineIcon from '@material-ui/icons/PlayCircleOutline' ;
911import React from 'react' ;
1012import Section from '../../types/items/Section' ;
@@ -18,7 +20,7 @@ const ExpansionPanel = withStyles({
1820 display : 'none' ,
1921 } ,
2022 '&:not(:last-child)' : {
21- borderBottom : 0 ,
23+ margin : '12px 0' ,
2224 } ,
2325 border : '1px solid rgba(0, 0, 0, .125)' ,
2426 expanded : { } ,
@@ -27,25 +29,24 @@ const ExpansionPanel = withStyles({
2729
2830const ExpansionPanelSummary = withStyles ( {
2931 content : {
30- '&$expanded' : {
31- margin : '12px 0' ,
32- } ,
32+ margin : '12px 0' ,
3333 } ,
3434 expanded : { } ,
3535 root : {
3636 '&$expanded' : {
3737 minHeight : 56 ,
3838 } ,
39+ alignItems : 'center' ,
3940 backgroundColor : 'rgba(0, 0, 0, .03)' ,
4041 borderBottom : '1px solid rgba(0, 0, 0, .125)' ,
41- marginBottom : - 1 ,
42+ display : 'flex' ,
4243 minHeight : 56 ,
4344 } ,
4445} ) ( MuiExpansionPanelSummary ) ;
4546
4647const ExpansionPanelDetails = withStyles ( theme => ( {
4748 root : {
48- padding : theme . spacing ( 2 ) ,
49+ padding : theme . spacing ( 1 ) ,
4950 } ,
5051} ) ) ( MuiExpansionPanelDetails ) ;
5152
@@ -62,40 +63,46 @@ interface Options {
6263 ) => void ;
6364}
6465
65- const CourseSection = ( { section, expandedIds, onChange } : Options ) => (
66- < ExpansionPanel
67- square
68- expanded = { expandedIds . includes ( section . id ) }
69- onChange = { onChange }
70- >
71- < ExpansionPanelSummary
72- aria-controls = { `panel- ${ section . id } -content` }
73- id = { `panel-header- ${ section . id } ` }
66+ const CourseSection = ( { section, expandedIds, onChange } : Options ) => {
67+ const expanded = expandedIds . includes ( section . id ) ;
68+
69+ return (
70+ < ExpansionPanel
71+ square
72+ elevation = { 0 }
73+ expanded = { expanded }
74+ onChange = { onChange }
7475 >
75- < Typography > { section . title } </ Typography >
76- </ ExpansionPanelSummary >
77- < ExpansionPanelDetails >
78- < List
79- component = "nav"
80- /** TODO: move to classes */
81- style = { {
82- backgroundColor : '#fff' ,
83- width : '100%' ,
84- } }
85- aria-label = "mailbox folders"
76+ < ExpansionPanelSummary
77+ aria-controls = { `panel-${ section . id } -content` }
78+ id = { `panel-header-${ section . id } ` }
8679 >
87- { section . units . map ( ( unit : Unit , index : number ) => (
88- < ListItem key = { index } divider = { section . units . length - 1 !== index } >
89- < >
90- < PlayCircleOutlineIcon style = { { marginRight : '1rem' } } />
91- < ListItemText primary = { unit . title } > </ ListItemText >
92- </ >
93- </ ListItem >
94- ) ) }
95- </ List >
96- </ ExpansionPanelDetails >
97- </ ExpansionPanel >
98- ) ;
80+ { expanded ? < ExpandLessIcon /> : < ExpandMoreIcon /> }
81+ < Typography style = { { marginLeft : '10px' } } > { section . title } </ Typography >
82+ </ ExpansionPanelSummary >
83+ < ExpansionPanelDetails >
84+ < List
85+ component = "nav"
86+ /** TODO: move to classes */
87+ style = { {
88+ backgroundColor : '#fff' ,
89+ width : '100%' ,
90+ } }
91+ aria-label = "course section"
92+ >
93+ { section . units . map ( ( unit : Unit , index : number ) => (
94+ < ListItem key = { index } divider = { section . units . length - 1 !== index } >
95+ < >
96+ < PlayCircleOutlineIcon style = { { marginRight : '1rem' } } />
97+ < ListItemText primary = { unit . title } > </ ListItemText >
98+ </ >
99+ </ ListItem >
100+ ) ) }
101+ </ List >
102+ </ ExpansionPanelDetails >
103+ </ ExpansionPanel >
104+ ) ;
105+ } ;
99106
100107// tslint:disable-next-line:max-file-line-count
101108export default CourseSection ;
0 commit comments