pdf-expand-button.tsx 1010 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { useTranslation } from 'react-i18next'
  2. import { Button } from 'react-bootstrap'
  3. import Tooltip from '../../../shared/components/tooltip'
  4. import Icon from '../../../shared/components/icon'
  5. import { useMemo } from 'react'
  6. import { useLayoutContext } from '../../../shared/context/layout-context'
  7. function PdfExpandButton() {
  8. const { pdfLayout, switchLayout, detachRole } = useLayoutContext()
  9. const { t } = useTranslation()
  10. const text = useMemo(() => {
  11. return pdfLayout === 'sideBySide' ? t('full_screen') : t('split_screen')
  12. }, [pdfLayout, t])
  13. if (detachRole) {
  14. return null
  15. }
  16. return (
  17. <Tooltip
  18. id="expand-pdf-btn"
  19. description={text}
  20. overlayProps={{ placement: 'left' }}
  21. >
  22. <Button
  23. onClick={switchLayout}
  24. className="toolbar-pdf-expand-btn toolbar-item"
  25. aria-label={text}
  26. >
  27. <Icon type={pdfLayout === 'sideBySide' ? 'expand' : 'compress'} />
  28. </Button>
  29. </Tooltip>
  30. )
  31. }
  32. export default PdfExpandButton