mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
fefc8384fb
GitOrigin-RevId: 9b6e5c60dade356549bb1b3fd9c6254ab00ace56
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { memo } from 'react'
|
|
import { Button } from 'react-bootstrap'
|
|
import classNames from 'classnames'
|
|
import Icon from '../../../shared/components/icon'
|
|
import { useDetachCompileContext } from '../../../shared/context/detach-compile-context'
|
|
import Tooltip from '../../../shared/components/tooltip'
|
|
|
|
const modifierKey = /Mac/i.test(navigator.platform) ? 'Cmd' : 'Ctrl'
|
|
|
|
function DetachCompileButton() {
|
|
const { t } = useTranslation()
|
|
const { compiling, startCompile, hasChanges } = useDetachCompileContext()
|
|
|
|
const compileButtonLabel = compiling ? `${t('compiling')}…` : t('recompile')
|
|
const tooltipElement = (
|
|
<>
|
|
{t('recompile_pdf')}{' '}
|
|
<span className="keyboard-shortcut">({modifierKey} + Enter)</span>
|
|
</>
|
|
)
|
|
|
|
return (
|
|
<div className="detach-compile-button-container">
|
|
<Tooltip
|
|
id="detach-compile"
|
|
description={tooltipElement}
|
|
tooltipProps={{ className: 'keyboard-tooltip' }}
|
|
overlayProps={{ delayShow: 500 }}
|
|
>
|
|
<Button
|
|
bsStyle="primary"
|
|
onClick={() => startCompile()}
|
|
disabled={compiling}
|
|
className={classNames('detach-compile-button', {
|
|
'btn-striped-animated': hasChanges,
|
|
'detach-compile-button-disabled': compiling,
|
|
})}
|
|
>
|
|
<Icon type="refresh" spin={compiling} />
|
|
<span className="detach-compile-button-label">
|
|
{compileButtonLabel}
|
|
</span>
|
|
</Button>
|
|
</Tooltip>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default memo(DetachCompileButton)
|