pdf-compile-button-inner.tsx 1.3 KB

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