overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-download-button.js
Miguel Serrano 48233cd593 Merge pull request #6027 from overleaf/ae-disabled-download-pdf-tooltip
Fix tooltip on disabled download PDF button

GitOrigin-RevId: d1814e75886d8a530331c3ded01499dcad8a4289
2021-12-08 09:03:16 +00:00

37 lines
989 B
JavaScript

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