pdf-compile-button-inner.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. >
  31. <Icon type="refresh" spin={compiling} />
  32. <span className="toolbar-hide-medium toolbar-hide-small btn-recompile-label">
  33. {compileButtonLabel}
  34. </span>
  35. </Button>
  36. </OverlayTrigger>
  37. )
  38. }
  39. PdfCompileButtonInner.propTypes = {
  40. compiling: PropTypes.bool.isRequired,
  41. startCompile: PropTypes.func.isRequired,
  42. }
  43. export default memo(PdfCompileButtonInner)