pdf-compile-button-inner.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { Button, OverlayTrigger, Tooltip } from 'react-bootstrap'
  2. import PropTypes from 'prop-types'
  3. import Icon from '../../../shared/components/icon'
  4. import { useTranslation } from 'react-i18next'
  5. import { memo } from 'react'
  6. import { useLayoutContext } from '../../../shared/context/layout-context'
  7. const modifierKey = /Mac/i.test(navigator.platform) ? 'Cmd' : 'Ctrl'
  8. function PdfCompileButtonInner({ startCompile, compiling }) {
  9. const { detachRole } = useLayoutContext()
  10. const { t } = useTranslation()
  11. const compileButtonLabel = compiling ? t('compiling') + '…' : t('recompile')
  12. return (
  13. <OverlayTrigger
  14. placement="bottom"
  15. delayShow={500}
  16. overlay={
  17. <Tooltip id="tooltip-logs-toggle" className="keyboard-tooltip">
  18. {t('recompile_pdf')}{' '}
  19. {detachRole !== 'detached' && (
  20. <span className="keyboard-shortcut">({modifierKey} + Enter)</span>
  21. )}
  22. </Tooltip>
  23. }
  24. >
  25. <Button
  26. className="btn-recompile"
  27. bsStyle="success"
  28. onClick={() => startCompile()}
  29. aria-label={compileButtonLabel}
  30. disabled={compiling}
  31. >
  32. <Icon type="refresh" spin={compiling} />
  33. <span className="toolbar-hide-medium toolbar-hide-small btn-recompile-label">
  34. {compileButtonLabel}
  35. </span>
  36. </Button>
  37. </OverlayTrigger>
  38. )
  39. }
  40. PdfCompileButtonInner.propTypes = {
  41. compiling: PropTypes.bool.isRequired,
  42. startCompile: PropTypes.func.isRequired,
  43. }
  44. export default memo(PdfCompileButtonInner)