-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/microsoft/pxt into thspar…
…ks/teachertool/block_picker
- Loading branch information
Showing
13 changed files
with
116 additions
and
29 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
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 |
---|---|---|
@@ -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
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