overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-download-button.tsx
Alf Eaton bce320f4bc Merge pull request #8037 from overleaf/ii-refactor-tooltip-usage-fix
Place the download PDF tooltip to the bottom

GitOrigin-RevId: e2171c4417de66f2143be66dc76ca7c450c43234
2022-05-20 08:04:20 +00:00

35 lines
978 B
TypeScript

import { useTranslation } from 'react-i18next'
import { Button } from 'react-bootstrap'
import Tooltip from '../../../shared/components/tooltip'
import Icon from '../../../shared/components/icon'
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
function PdfHybridDownloadButton() {
const { pdfDownloadUrl } = useCompileContext()
const { t } = useTranslation()
const description = pdfDownloadUrl
? t('download_pdf')
: t('please_compile_pdf_before_download')
return (
<Tooltip
id="logs-toggle"
description={description}
overlayProps={{ placement: 'bottom' }}
>
<Button
bsStyle="link"
disabled={!pdfDownloadUrl}
download
href={pdfDownloadUrl || '#'}
target="_blank"
style={{ pointerEvents: 'auto' }}
>
<Icon type="download" fw />
</Button>
</Tooltip>
)
}
export default PdfHybridDownloadButton