import { FC, useState } from "react"; import { useTranslation } from "react-i18next"; import styled from "styled-components"; import ViewState from "../../../../../ReactViewModels/ViewState"; import Box from "../../../../../Styled/Box"; import { TextSpan } from "../../../../../Styled/Text"; import Button from "../../../../../Styled/Button"; import { downloadImg } from "./PrintView"; import Spacing from "../../../../../Styled/Spacing"; interface IPrintSectionProps { viewState: ViewState; } export const PrintSection: FC = ({ viewState }) => { const { t } = useTranslation(); const [isDownloading, setIsDownloading] = useState(false); const printView = () => { const newWindow = window.open(); viewState.setPrintWindow(newWindow); }; const downloadMap = () => { setIsDownloading(true); viewState.terria.currentViewer .captureScreenshot() .then((dataString) => { downloadImg(dataString); }) .finally(() => setIsDownloading(false)); }; return ( {t("share.printTitle")} {t("share.printExplanation")} {t("share.downloadMap")} {t("share.printViewButton")} ); }; const PrintButton = styled(Button)` border-radius: 4px; `; const Explanation = styled(TextSpan)` opacity: 0.8; `;