Skip to content

Commit

Permalink
feat: worksheet footer
Browse files Browse the repository at this point in the history
  • Loading branch information
asartalo committed Aug 9, 2021
1 parent 1ecf24b commit ac0fb34
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 43 deletions.
69 changes: 69 additions & 0 deletions src/components/WorksheetFooter.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<section
className={classes.footer}
style={{
bottom: options.margin,
right: options.margin,
}}
>
<div className={classes.footerName}>
<strong className={classes.label}>Score:</strong>
<span className={classes.footerBlank} />
<span>
out of
{' '}
{ itemCount }
</span>
</div>
<div className={classes.footerDate}>
<strong className={classes.label}>Time:</strong>
<span className={classes.footerBlank} />
<span>minutes</span>
</div>
</section>
</>
);
};

export default WorksheetFooter;
54 changes: 54 additions & 0 deletions src/components/WorksheetHeader.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<section className={classes.header}>
<div className={classes.headerName}>
<strong className={classes.label}>Name:</strong>
<span className={classes.headerBlank} />
</div>
<div className={classes.headerDate}>
<strong className={classes.label}>Date:</strong>
<span className={classes.headerBlank} />
</div>
</section>
<p className={classes.instructions}>
Complete the addition facts by filling in the blanks.
</p>
</>
);
};

export default WorksheetHeader;
47 changes: 4 additions & 43 deletions src/pages/additionFillTheBlanks/PreviewAftb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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',
},
Expand Down Expand Up @@ -80,23 +56,8 @@ const PreviewAftb = ({
return (
<>
<MultiPaperPage
header={(
<>
<section className={classes.header}>
<div className={classes.headerName}>
<strong className={classes.label}>Name:</strong>
<span className={classes.headerBlank} />
</div>
<div className={classes.headerDate}>
<strong className={classes.label}>Date:</strong>
<span className={classes.headerBlank} />
</div>
</section>
<p className={classes.instructions}>
Complete the addition facts by filling in the blanks.
</p>
</>
)}
header={(<WorksheetHeader />)}
footer={(<WorksheetFooter itemCount={data.length} />)}
contentWrapper="ol"
contentWrapperClassName={`${classes.list} problems`}
data={data}
Expand Down

0 comments on commit ac0fb34

Please sign in to comment.