mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 10:04:10 -05:00
5731463d32
Tooltip usage refactoring GitOrigin-RevId: f4b2d4d57722172141a081dd60e4394ff7fff332
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { Button } from 'react-bootstrap'
|
|
import Tooltip from '../../../shared/components/tooltip'
|
|
import Icon from '../../../shared/components/icon'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { memo } from 'react'
|
|
|
|
const modifierKey = /Mac/i.test(navigator.platform) ? 'Cmd' : 'Ctrl'
|
|
|
|
type PdfCompileButtonInnerProps = {
|
|
startCompile: () => void
|
|
compiling: boolean
|
|
}
|
|
|
|
function PdfCompileButtonInner({
|
|
startCompile,
|
|
compiling,
|
|
}: PdfCompileButtonInnerProps) {
|
|
const { t } = useTranslation()
|
|
|
|
const compileButtonLabel = compiling ? t('compiling') + '…' : t('recompile')
|
|
|
|
return (
|
|
<Tooltip
|
|
id="logs-toggle"
|
|
description={
|
|
<>
|
|
{t('recompile_pdf')}{' '}
|
|
<span className="keyboard-shortcut">({modifierKey} + Enter)</span>
|
|
</>
|
|
}
|
|
tooltipProps={{ className: 'keyboard-tooltip' }}
|
|
overlayProps={{ delayShow: 500 }}
|
|
>
|
|
<Button
|
|
className="btn-recompile"
|
|
bsStyle="success"
|
|
onClick={() => startCompile()}
|
|
aria-label={compileButtonLabel}
|
|
disabled={compiling}
|
|
>
|
|
<Icon type="refresh" spin={compiling} />
|
|
<span className="toolbar-hide-medium toolbar-hide-small btn-recompile-label">
|
|
{compileButtonLabel}
|
|
</span>
|
|
</Button>
|
|
</Tooltip>
|
|
)
|
|
}
|
|
|
|
export default memo(PdfCompileButtonInner)
|