2024-04-05 04:05:44 -04:00
|
|
|
import { Col } from 'react-bootstrap-5'
|
|
|
|
import { Col as BS3Col } from 'react-bootstrap'
|
|
|
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
|
|
|
|
2024-05-15 10:31:00 -04:00
|
|
|
type OLColProps = React.ComponentProps<typeof Col> & {
|
2024-04-05 04:05:44 -04:00
|
|
|
bs3Props?: Record<string, unknown>
|
|
|
|
}
|
|
|
|
|
2024-05-15 10:31:00 -04:00
|
|
|
function OLCol(props: OLColProps) {
|
2024-04-05 04:05:44 -04:00
|
|
|
const { bs3Props, ...rest } = props
|
|
|
|
const sizes = new Set(['xs', 'sm', 'md', 'lg', 'xl', 'xxl'])
|
|
|
|
|
|
|
|
const getBs3Sizes = (obj: typeof rest) => {
|
|
|
|
return Object.entries(obj).reduce(
|
|
|
|
(prev, [key, value]) => {
|
|
|
|
if (sizes.has(key)) {
|
|
|
|
if (typeof value === 'object') {
|
|
|
|
prev[key] = value.span
|
|
|
|
prev[`${key}Offset`] = value.offset
|
|
|
|
} else {
|
|
|
|
prev[key] = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return prev
|
|
|
|
},
|
|
|
|
{} as Record<string, (typeof rest)['xs']>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const bs3ColProps: React.ComponentProps<typeof BS3Col> = {
|
|
|
|
children: rest.children,
|
|
|
|
className: rest.className,
|
|
|
|
...getBs3Sizes(rest),
|
|
|
|
...bs3Props,
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<BootstrapVersionSwitcher
|
|
|
|
bs3={<BS3Col {...bs3ColProps} />}
|
|
|
|
bs5={<Col {...rest} />}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-05-15 10:31:00 -04:00
|
|
|
export default OLCol
|