switch-to-pdf-button.jsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { useTranslation } from 'react-i18next'
  2. import Icon from '../../../shared/components/icon'
  3. import MaterialIcon from '@/shared/components/material-icon'
  4. import OLButton from '@/features/ui/components/ol/ol-button'
  5. import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
  6. import { useLayoutContext } from '../../../shared/context/layout-context'
  7. function SwitchToPDFButton() {
  8. const { pdfLayout, setView, detachRole } = useLayoutContext()
  9. const { t } = useTranslation()
  10. if (detachRole) {
  11. return null
  12. }
  13. if (pdfLayout === 'sideBySide') {
  14. return null
  15. }
  16. function handleClick() {
  17. setView('pdf')
  18. }
  19. return (
  20. <OLButton
  21. variant="secondary"
  22. size="sm"
  23. onClick={handleClick}
  24. bs3Props={{
  25. bsSize: 'xsmall',
  26. className: 'switch-to-pdf-btn toolbar-btn-secondary',
  27. }}
  28. >
  29. <BootstrapVersionSwitcher
  30. bs3={<Icon type="file-pdf-o" className="toolbar-btn-secondary-icon" />}
  31. bs5={<MaterialIcon type="picture_as_pdf" />}
  32. />
  33. {t('switch_to_pdf')}
  34. </OLButton>
  35. )
  36. }
  37. export default SwitchToPDFButton