overleaf/services/web/frontend/js/features/source-editor/components/switch-to-pdf-button.js
Davinder Singh c6f8b17647 Merge pull request #10286 from overleaf/jel-ds-toggle
Fix toggle and  `Switch to PDF` aligment

GitOrigin-RevId: d3c77ff34829af875d2b8b9e3797e0e7db867631
2022-11-16 09:04:26 +00:00

36 lines
763 B
JavaScript

import { useTranslation } from 'react-i18next'
import { Button } from 'react-bootstrap'
import Icon from '../../../shared/components/icon'
import { useLayoutContext } from '../../../shared/context/layout-context'
function SwitchToPDFButton() {
const { pdfLayout, setView, detachRole } = useLayoutContext()
const { t } = useTranslation()
if (detachRole) {
return null
}
if (pdfLayout === 'sideBySide') {
return null
}
function handleClick() {
setView('pdf')
}
return (
<Button
bsStyle="default"
bsSize="xs"
onClick={handleClick}
className="toolbar-btn-secondary"
>
<Icon type="file-pdf-o" className="me-1" />
{t('switch_to_pdf')}
</Button>
)
}
export default SwitchToPDFButton