-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Teacher tool: print results page (#9916)
* printing hooked up * not showing add notes button, chevron for status on print * showing a toast if printing errors * keep the label for notes and make the individual result larger if there are notes * got rid of pill on status, made height on criteria entries shorter * got rid of useref in evalresultdisplay * rename withrefprops * use prop interface in evalresultdisplay * update ternary operator in classlist on result notes Co-authored-by: Thomas Sparks <[email protected]> * sanitizing project name for print document title * get rid of unused onHandlePrint * ran prettier * renamed printref to resultsref, split toolbar buttons, tabpanels props into their own thing * using rubric name - project name for the printed document title * sanitizing rubric name, too --------- Co-authored-by: Thomas Sparks <[email protected]>
- Loading branch information
Showing
7 changed files
with
84 additions
and
21 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 |
---|---|---|
@@ -1,17 +1,24 @@ | ||
import * as React from "react"; | ||
import { useRef } from "react"; | ||
import { useReactToPrint } from "react-to-print"; | ||
import { Toolbar } from "./Toolbar"; | ||
import { stateAndDispatch } from "../state"; | ||
import { showToast } from "../state/actions"; | ||
import { makeToast } from "../utils"; | ||
import { Strings } from "../constants"; | ||
import { getSafeRubricName } from "../state/helpers"; | ||
|
||
interface PrintButtonProps { | ||
printRef: React.RefObject<HTMLDivElement>; | ||
onHandlePrint: () => void; | ||
} | ||
|
||
export const PrintButton: React.FC<PrintButtonProps> = ({ printRef, onHandlePrint }) => { | ||
export const PrintButton: React.FC<PrintButtonProps> = ({ printRef }) => { | ||
const { state: teacherTool } = stateAndDispatch(); | ||
const handlePrint = useReactToPrint({ | ||
content: () => printRef.current, | ||
onAfterPrint: onHandlePrint, | ||
onPrintError: () => showToast(makeToast("error", lf("Unable to print evaluation results"), 2000)), | ||
documentTitle: `${pxt.Util.sanitizeFileName(getSafeRubricName(teacherTool)!)} - ${pxt.Util.sanitizeFileName( | ||
teacherTool.projectMetadata?.name || Strings.UntitledProject | ||
)}`, | ||
}); | ||
return <Toolbar.Button icon="fas fa-print" title={lf("Print")} onClick={handlePrint} />; | ||
}; |
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