overleaf/services/web/frontend/js/features/ui/components/ol/ol-icon-button.tsx
Tim Down 29837ec838 Merge pull request #18733 from overleaf/td-bs5-button-props
Simplify handling of BS3 props in button wrapper component

GitOrigin-RevId: 12a6b1374da5084e075775f3cef23f0b24d098fc
2024-06-07 08:04:24 +00:00

37 lines
1.1 KiB
TypeScript

import { bs3ButtonProps, BS3ButtonSize } from './ol-button'
import { Button as BS3Button } from 'react-bootstrap'
import type { IconButtonProps } from '@/features/ui/components/types/icon-button-props'
import BootstrapVersionSwitcher from '../bootstrap-5/bootstrap-version-switcher'
import Icon, { IconProps } from '@/shared/components/icon'
import IconButton from '../bootstrap-5/icon-button'
export type OLIconButtonProps = IconButtonProps & {
bs3Props?: {
loading?: React.ReactNode
fw?: IconProps['fw']
className?: string
bsSize?: BS3ButtonSize
}
}
export default function OLIconButton(props: OLIconButtonProps) {
const { bs3Props, ...rest } = props
const { fw, ...bs3Rest } = bs3Props || {}
return (
<BootstrapVersionSwitcher
bs3={
<BS3Button {...bs3ButtonProps(rest)} {...bs3Rest}>
{bs3Props?.loading}
<Icon
type={rest.icon}
fw={fw}
accessibilityLabel={rest.accessibilityLabel}
/>
</BS3Button>
}
bs5={<IconButton {...rest} />}
/>
)
}