mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-14 04:30:56 -05:00
1d4737ac69
* Add Story for `PdfCompileButton` * Set the CompileButton height so it's similar to BS3 * Add the CompileButton animations * Remove `sm` from CompileButton: makes font size bigger * Use MaterialIcon in compile-button dropdown-toggle * Use MaterialIcon in LayoutDropdown * Fix stripe alignment on Recompile button * Set padding around dropdown caret Per Alexandru's instructions * Prevent border from disappearing on hover * Set the padding of the compile button even on both sides Before: left 12px, right 16px; After: left 16px, right 16px; * Change px values to spacing var * Add some button classes for BS5 only * Don't render the hidden "Compiling…" in BS5, it changes the button width * Prevent `loading="[object Object]"` in the DOM Co-authored-by: Rebeka <rebeka.dekany@overleaf.com> --------- Co-authored-by: Rebeka <rebeka.dekany@overleaf.com> GitOrigin-RevId: 34f1eed03e63f3459243a37c878612a623f321f8
76 lines
2.4 KiB
TypeScript
76 lines
2.4 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { memo } from 'react'
|
|
import classnames from 'classnames'
|
|
import Icon from '../../../shared/components/icon'
|
|
import { useDetachCompileContext } from '../../../shared/context/detach-compile-context'
|
|
import OLTooltip from '@/features/ui/components/ol/ol-tooltip'
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
import { bsVersion } from '@/features/utils/bootstrap-5'
|
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
|
|
|
const modifierKey = /Mac/i.test(navigator.platform) ? 'Cmd' : 'Ctrl'
|
|
|
|
function DetachCompileButton() {
|
|
const { t } = useTranslation()
|
|
const { compiling, startCompile, hasChanges } = useDetachCompileContext()
|
|
|
|
const compileButtonLabel = compiling ? `${t('compiling')}…` : t('recompile')
|
|
const tooltipElement = (
|
|
<>
|
|
{t('recompile_pdf')}{' '}
|
|
<span className="keyboard-shortcut">({modifierKey} + Enter)</span>
|
|
</>
|
|
)
|
|
|
|
return (
|
|
<div
|
|
className={classnames(
|
|
'detach-compile-button-container',
|
|
bsVersion({ bs5: 'ms-1' })
|
|
)}
|
|
>
|
|
<OLTooltip
|
|
id="detach-compile"
|
|
description={tooltipElement}
|
|
tooltipProps={{ className: 'keyboard-tooltip' }}
|
|
overlayProps={{ delay: { show: 500, hide: 0 } }}
|
|
>
|
|
<OLButton
|
|
variant="primary"
|
|
onClick={() => startCompile()}
|
|
disabled={compiling}
|
|
className={classnames('detach-compile-button', {
|
|
'btn-striped-animated': hasChanges,
|
|
'detach-compile-button-disabled': compiling,
|
|
})}
|
|
size="sm"
|
|
isLoading={compiling}
|
|
bs3Props={{
|
|
loading: compiling && (
|
|
<>
|
|
<Icon type="refresh" spin={compiling} />
|
|
<span className="detach-compile-button-label">
|
|
{compileButtonLabel}
|
|
</span>
|
|
</>
|
|
),
|
|
}}
|
|
>
|
|
<BootstrapVersionSwitcher
|
|
bs3={
|
|
<>
|
|
<Icon type="refresh" spin={compiling} />
|
|
<span className="detach-compile-button-label">
|
|
{compileButtonLabel}
|
|
</span>
|
|
</>
|
|
}
|
|
bs5={t('recompile')}
|
|
/>
|
|
</OLButton>
|
|
</OLTooltip>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default memo(DetachCompileButton)
|