@@ -2,8 +2,6 @@ import React from 'react';
22import { withStyles } from '@material-ui/core/styles' ;
33import ListItem from '@material-ui/core/ListItem' ;
44import List from '@material-ui/core/List' ;
5- import ListItemText from '@material-ui/core/ListItemText' ;
6- import Link from '@material-ui/core/Link' ;
75import Collapse from '@material-ui/core/Collapse' ;
86import { color , UiLayout } from '@pie-lib/pie-toolbox/render-ui' ;
97import PropTypes from 'prop-types' ;
@@ -63,49 +61,55 @@ class Rubric extends React.Component {
6361 . reverse ( )
6462 . map ( ( desc , index ) => {
6563 index = points . length - index - 1 ;
66- const pointsLabel = value . excludeZero ? index + 1 : index ;
64+ const pointsLabel = value . excludeZero ? index + 1 : index ;
6765
6866 return (
69- < React . Fragment key = { index } >
70- < ListItem key = { `P${ index } ` } >
71- < ListItemText
72- className = { classes . rubricCol }
73- primary = { < div className = { classes . text } > { pointsLabel === 1 ? ` ${ pointsLabel } PT` : ` ${ pointsLabel } PTS` } </ div > }
74- />
75-
76- < ListItemText
77- primary = { < div className = { classes . text } dangerouslySetInnerHTML = { { __html : desc } } /> }
78- />
67+ < React . Fragment key = { index } >
68+ < ListItem key = { `P${ index } ` } className = { classes . listColumn } >
69+ < h3 className = { classes . text } style = { { margin : 0 , fontSize : '1em' , fontWeight : '700' } } > { pointsLabel === 1 ? ` ${ pointsLabel } PT` : ` ${ pointsLabel } PTS` } </ h3 >
70+ < div className = { classes . text } dangerouslySetInnerHTML = { { __html : desc } } />
71+ </ ListItem >
72+
73+ { sampleAnswers && sampleAnswers [ index ] && (
74+ < ListItem key = { `S ${ index } ` } className = { classes . listColumn } >
75+ < h4 style = { { margin : 0 , fontSize : '1em' } } className = { classes . text } > Sample Answer </ h4 >
76+ < div className = { classes . text } dangerouslySetInnerHTML = { { __html : sampleAnswers [ index ] } } />
7977 </ ListItem >
80-
81- { sampleAnswers && sampleAnswers [ index ] && (
82- < ListItem key = { `S${ index } ` } >
83- < ListItemText
84- className = { classes . rubricCol }
85- style = { { marginLeft : '20px' } }
86- primary = { < div className = { classes . text } > Sample Answer</ div > }
87- />
88-
89- < ListItemText
90- primary = {
91- < div className = { classes . text } dangerouslySetInnerHTML = { { __html : sampleAnswers [ index ] } } />
92- }
93- />
94- </ ListItem >
95- ) }
96- </ React . Fragment >
78+ ) }
79+ </ React . Fragment >
9780 ) ;
9881 } ) }
9982 </ List >
10083 ) ;
10184
10285 return (
10386 < UiLayout extraCSSRules = { extraCSSRules } className = { classes . root } >
87+ { /* screen reader only heading for navigation as per PD-5057 */ }
88+ < h2 className = { classes . hiddenScreenReader } > Rubric</ h2 >
10489 { ! animationsDisabled ? (
10590 < React . Fragment >
106- < Link href = { this . dudUrl } onClick = { this . toggleRubric } >
91+ < h2
92+ className = { classes . rubricToggle }
93+ tabIndex = { 0 }
94+ role = "button"
95+ aria-expanded = { this . state . rubricOpen }
96+ onClick = { this . toggleRubric }
97+ onKeyPress = { e => {
98+ if ( e . key === 'Enter' || e . key === ' ' ) this . toggleRubric ( ) ;
99+ } }
100+ >
107101 { this . state . linkPrefix } Rubric
108- </ Link >
102+ < span
103+ className = { classes . chevronStyle }
104+ aria-hidden = "true"
105+ >
106+ { this . state . rubricOpen ? (
107+ < svg width = "20" height = "20" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" > < polyline points = "18 15 12 9 6 15" > </ polyline > </ svg >
108+ ) : (
109+ < svg width = "20" height = "20" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" strokeWidth = "2" strokeLinecap = "round" strokeLinejoin = "round" > < polyline points = "6 9 12 15 18 9" > </ polyline > </ svg >
110+ ) }
111+ </ span >
112+ </ h2 >
109113 < Collapse in = { this . state . rubricOpen } timeout = "auto" >
110114 { rubricList }
111115 </ Collapse >
@@ -121,18 +125,47 @@ class Rubric extends React.Component {
121125 }
122126}
123127
124- const styles = ( ) => ( {
128+ const styles = ( theme ) => ( {
125129 root : {
126130 color : color . text ( ) ,
127131 backgroundColor : color . background ( ) ,
128132 } ,
129- rubricCol : {
130- flex : '0 1 auto' ,
131- minWidth : 'fit-content' ,
133+ listColumn : {
134+ display : 'flex' ,
135+ flexDirection : 'column' ,
136+ alignItems : 'flex-start' ,
137+ } ,
138+ listColumnItem : {
139+ padding : 0 ,
132140 } ,
133141 text : {
134142 color : color . text ( ) ,
135143 } ,
144+ rubricToggle : {
145+ display : 'flex' ,
146+ cursor : 'pointer' ,
147+ userSelect : 'none' ,
148+ fontSize : theme . typography . fontSize + 2 ,
149+ fontWeight : 600 ,
150+ color : color . tertiary ( ) ,
151+ } ,
152+ chevronStyle : {
153+ display : 'inline-flex' ,
154+ transition : 'transform 0.2s' ,
155+ marginLeft : 4 ,
156+ alignSelf : 'center' ,
157+ } ,
158+ hiddenScreenReader : {
159+ position : 'absolute' ,
160+ width : '1px' ,
161+ height : '1px' ,
162+ padding : 0 ,
163+ margin : '-1px' ,
164+ overflow : 'hidden' ,
165+ clip : 'rect(0,0,0,0)' ,
166+ border : 0 ,
167+ whiteSpace : 'nowrap' ,
168+ } ,
136169} ) ;
137170
138171export default withStyles ( styles ) ( Rubric ) ;
0 commit comments