-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new worksheet: numbers to words
- Loading branch information
Showing
24 changed files
with
666 additions
and
179 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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
it('can create numbers to words worksheet', () => { | ||
cy.visitWorksheetNumbersToWords(); | ||
|
||
cy.findByLabelText(/number of problems/i).clearType('7'); | ||
cy.setNumberRange('number-range-slider', 10, 99); | ||
cy.withinPreview(() => { | ||
cy.findByRole('list', { name: 'Problems' }).within((subject) => { | ||
cy.wrap(subject).findAllByRole('listitem') | ||
.should('have.length', 7) | ||
.each(($li) => { | ||
cy.wrap($li).contains(/[a-z\-\s]+:\s+_+/); | ||
}); | ||
}); | ||
}); | ||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import makeStyles from '@material-ui/core/styles/makeStyles'; | ||
import React, { CSSProperties, ReactNode } from 'react'; | ||
import { Props, PropsCallback } from './MultiPaperPage'; | ||
|
||
interface ProblemListProps { | ||
children: ReactNode; | ||
className?: string; | ||
columns?: number; | ||
style?: CSSProperties; | ||
label?: string; | ||
} | ||
|
||
const styles = makeStyles(() => ({ | ||
// All em units equivalent are based on a 20px font size base | ||
list: { | ||
margin: '5mm 0 0 0', | ||
padding: 0, | ||
columnCount: 2, | ||
columnWidth: 'auto', | ||
counterReset: 'problem', | ||
|
||
'& > li': { | ||
counterIncrement: 'problem', | ||
}, | ||
|
||
'& > li::marker': { | ||
content: 'counter(problem) "."', | ||
}, | ||
}, | ||
})); | ||
|
||
function ProblemList({ | ||
children, className, columns, style, label, | ||
}: ProblemListProps): JSX.Element { | ||
const classes = styles(); | ||
const cols = columns ?? 1; | ||
const paddedClassName = className ? ` ${className}` : ''; | ||
const styleUsed = { ...style, columns: cols }; | ||
|
||
return ( | ||
<ol | ||
className={`problems ${classes.list}${paddedClassName}`} | ||
style={styleUsed} | ||
aria-label={label ?? 'Problems'} | ||
> | ||
{children} | ||
</ol> | ||
); | ||
} | ||
|
||
const propsCallback: PropsCallback = (inputProps: Props, { memberIndex }) => ({ | ||
...inputProps, | ||
style: { | ||
counterReset: `problem ${memberIndex}`, | ||
}, | ||
}); | ||
|
||
ProblemList.propsCallback = propsCallback; | ||
|
||
ProblemList.defaultProps = { | ||
className: null, | ||
columns: 1, | ||
style: null, | ||
label: null, | ||
}; | ||
|
||
export default ProblemList; |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { makeStyles } from '@material-ui/core'; | ||
import React, { ReactNode } from 'react'; | ||
|
||
interface ProblemListItemProps { | ||
children: ReactNode; | ||
label?: string; | ||
fontSize?: number; | ||
className?: string; | ||
} | ||
|
||
const defaultFontSize = 20; | ||
const defaultLabel = 'Problem'; | ||
|
||
const styles = makeStyles(() => ({ | ||
// All em units equivalent are based on a 20px font size base | ||
li: { | ||
padding: '1.15em 0 1.15em 1.15em', // '6mm 0 6mm 6mm', // 23px | ||
marginLeft: '1.9em', // '10mm', // 38px | ||
'-webkit-column-break-inside': 'avoid', | ||
pabeBreakInside: 'avoid', | ||
breakInside: 'avoid', | ||
|
||
'&::marker': { | ||
fontSize: '0.8em', // 16px | ||
}, | ||
}, | ||
})); | ||
|
||
function ProblemListItem({ | ||
children, label, fontSize, className, | ||
}: ProblemListItemProps): JSX.Element { | ||
const classes = styles(); | ||
const paddedClassName = className ? ` ${className}` : ''; | ||
return ( | ||
<li | ||
className={`${classes.li}${paddedClassName}`} | ||
aria-label={label ?? defaultLabel} | ||
style={{ fontSize: `${fontSize ?? defaultFontSize}px` }} | ||
> | ||
{children} | ||
</li> | ||
); | ||
} | ||
|
||
ProblemListItem.defaultProps = { | ||
fontSize: defaultFontSize, | ||
className: '', | ||
label: defaultLabel, | ||
}; | ||
|
||
export default ProblemListItem; |
Oops, something went wrong.