From ac0fb34393d0cbe710e7e46bad274d2a00b1b82a Mon Sep 17 00:00:00 2001 From: Wayne Duran Date: Mon, 9 Aug 2021 10:49:57 +0800 Subject: [PATCH] feat: worksheet footer --- src/components/WorksheetFooter.tsx | 69 +++++++++++++++++++ src/components/WorksheetHeader.tsx | 54 +++++++++++++++ .../additionFillTheBlanks/PreviewAftb.tsx | 47 ++----------- 3 files changed, 127 insertions(+), 43 deletions(-) create mode 100644 src/components/WorksheetFooter.tsx create mode 100644 src/components/WorksheetHeader.tsx diff --git a/src/components/WorksheetFooter.tsx b/src/components/WorksheetFooter.tsx new file mode 100644 index 0000000..d7b45db --- /dev/null +++ b/src/components/WorksheetFooter.tsx @@ -0,0 +1,69 @@ +import { makeStyles } from '@material-ui/core'; +import React from 'react'; +import { usePaperOptions } from './PaperOptionsProvider'; + +const footerStyles = makeStyles(() => ({ + footer: { + display: 'flex', + padding: '10mm 5mm 5mm 0', + width: '60%', + position: 'absolute', + bottom: 0, + right: 0, + }, + footerName: { + flexGrow: 1, + display: 'flex', + paddingRight: '2em', + }, + label: { + flexGrow: 0, + fontWeight: 'normal', + paddingRight: '0.3em', + }, + footerDate: { + flexGrow: 1, + display: 'flex', + }, + footerBlank: { + flexGrow: 1, + borderBottom: '1px solid black', + }, +})); + +interface WorksheetFooterProps { + itemCount: number; +} + +const WorksheetFooter = ({ itemCount }: WorksheetFooterProps): JSX.Element => { + const { options } = usePaperOptions(); + const classes = footerStyles(); + return ( + <> +
+
+ Score: + + + out of + {' '} + { itemCount } + +
+
+ Time: + + minutes +
+
+ + ); +}; + +export default WorksheetFooter; diff --git a/src/components/WorksheetHeader.tsx b/src/components/WorksheetHeader.tsx new file mode 100644 index 0000000..e6c305d --- /dev/null +++ b/src/components/WorksheetHeader.tsx @@ -0,0 +1,54 @@ +import { makeStyles } from '@material-ui/core'; +import React from 'react'; + +const headerStyles = makeStyles(() => ({ + header: { + display: 'flex', + }, + headerName: { + flexGrow: 4, + display: 'flex', + paddingRight: '2em', + }, + label: { + flexGrow: 0, + fontWeight: 'normal', + paddingRight: '0.3em', + }, + headerDate: { + flexGrow: 2, + display: 'flex', + }, + headerBlank: { + flexGrow: 1, + borderBottom: '1px solid black', + }, + instructions: { + marginBottom: 0, + marginTop: '10mm', + fontSize: '16px', + }, +})); + +const WorksheetHeader = (): JSX.Element => { + const classes = headerStyles(); + return ( + <> +
+
+ Name: + +
+
+ Date: + +
+
+

+ Complete the addition facts by filling in the blanks. +

+ + ); +}; + +export default WorksheetHeader; diff --git a/src/pages/additionFillTheBlanks/PreviewAftb.tsx b/src/pages/additionFillTheBlanks/PreviewAftb.tsx index fa27ae6..b5229d8 100644 --- a/src/pages/additionFillTheBlanks/PreviewAftb.tsx +++ b/src/pages/additionFillTheBlanks/PreviewAftb.tsx @@ -5,6 +5,8 @@ import NumberGenerator from '../../lib/NumberGenerator'; import RandomNumberGenerator from '../../lib/RandomNumberGenerator'; import AdditionSentence, { generateAdditionSentences } from './AdditionSentence'; import AftbData from './AftbData'; +import WorksheetHeader from '../../components/WorksheetHeader'; +import WorksheetFooter from '../../components/WorksheetFooter'; interface PreviewAftbProps { aftbData: AftbData; @@ -14,32 +16,6 @@ interface PreviewAftbProps { const defaultGenerator = new RandomNumberGenerator(Math.random); const pageStyles = makeStyles(() => ({ - header: { - display: 'flex', - }, - headerName: { - flexGrow: 4, - display: 'flex', - paddingRight: '2em', - }, - label: { - flexGrow: 0, - fontWeight: 'normal', - paddingRight: '0.3em', - }, - headerDate: { - flexGrow: 2, - display: 'flex', - }, - headerBlank: { - flexGrow: 1, - borderBottom: '1px solid black', - }, - instructions: { - marginBottom: 0, - marginTop: '10mm', - fontSize: '16px', - }, heading: { textAlign: 'center', }, @@ -80,23 +56,8 @@ const PreviewAftb = ({ return ( <> -
-
- Name: - -
-
- Date: - -
-
-

- Complete the addition facts by filling in the blanks. -

- - )} + header={()} + footer={()} contentWrapper="ol" contentWrapperClassName={`${classes.list} problems`} data={data}