switch-to-pdf-button.tsx 724 B

12345678910111213141516171819202122232425262728293031
  1. import { useTranslation } from 'react-i18next'
  2. import MaterialIcon from '@/shared/components/material-icon'
  3. import OLButton from '@/shared/components/ol/ol-button'
  4. import { useLayoutContext } from '../../../shared/context/layout-context'
  5. function SwitchToPDFButton() {
  6. const { pdfLayout, setView, detachRole } = useLayoutContext()
  7. const { t } = useTranslation()
  8. if (detachRole) {
  9. return null
  10. }
  11. if (pdfLayout === 'sideBySide') {
  12. return null
  13. }
  14. function handleClick() {
  15. setView('pdf')
  16. }
  17. return (
  18. <OLButton variant="secondary" size="sm" onClick={handleClick}>
  19. <MaterialIcon type="picture_as_pdf" />
  20. {t('switch_to_pdf')}
  21. </OLButton>
  22. )
  23. }
  24. export default SwitchToPDFButton