overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-hybrid-code-check-button.jsx
ilkin-overleaf 92eade7502 Merge pull request #20708 from overleaf/ii-bs5-pdf-toolbar
[web] BS5 pdf toolbar

GitOrigin-RevId: a04091c9e936e52f47c3977b3149ffe613d43bb9
2024-10-14 11:06:17 +00:00

45 lines
1.3 KiB
JavaScript

import { memo, useCallback } from 'react'
import Icon from '../../../shared/components/icon'
import { useTranslation } from 'react-i18next'
import { useDetachCompileContext as useCompileContext } from '../../../shared/context/detach-compile-context'
import OLButton from '@/features/ui/components/ol/ol-button'
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
import MaterialIcon from '@/shared/components/material-icon'
import { bsVersion } from '@/features/utils/bootstrap-5'
function PdfHybridCodeCheckButton() {
const { codeCheckFailed, error, toggleLogs } = useCompileContext()
const { t } = useTranslation()
const handleClick = useCallback(() => {
toggleLogs()
}, [toggleLogs])
if (!codeCheckFailed) {
return null
}
return (
<OLButton
variant="danger"
size="sm"
disabled={Boolean(error)}
className="btn-toggle-logs toolbar-item"
onClick={handleClick}
bs3Props={{
bsSize: 'xsmall',
}}
>
<BootstrapVersionSwitcher
bs3={<Icon type="exclamation-triangle" />}
bs5={<MaterialIcon type="warning" />}
/>
<span className={bsVersion({ bs3: 'toolbar-text' })}>
{t('code_check_failed')}
</span>
</OLButton>
)
}
export default memo(PdfHybridCodeCheckButton)