import React from 'react' import Grid from '@mui/material/Unstable_Grid2' import { LmComponentRender } from '@LmComponentRender' import { BackgroundStoryblok } from '../../typings/generated/components-schema' import BackgroundImage from './BackgroundImage' import BackgroundElements from './BackgroundElements' import useBackgroundBox from './useBackgroundBox' import { LmGridColumnProps } from './sectionTypes' import WrapGridContainer from './WrapGridContainer' import Stack from '@mui/material/Stack' import clsx from 'clsx' const xsSpanMap = { 1: 3, 2: 6, 3: 9, 4: 12, false: false, auto: 'auto', true: true } const smSpanMap = { 1: 1, 2: 2, 3: 4, 4: 6, 5: 7, 6: 9, 7: 11, 8: 12, false: false, auto: 'auto', true: true } const mdSpanMap = { 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, false: false, auto: 'auto', true: true } export function LmGridColumn({ content, parent }: LmGridColumnProps): JSX.Element { const background: BackgroundStoryblok | undefined = content.background?.[0] const { className, style } = useBackgroundBox({ background, styles: content.styles, stylesMobile: content.styles_mobile, stylesTablet: content.styles_tablet, stylesHover: content.styles_hover }) const mdWidth = mdSpanMap[content.width_general as string] let smWidth = smSpanMap[content.width_tablet as string] if (!smWidth && mdWidth) { smWidth = mdWidth if (typeof mdWidth === 'number' && mdWidth > 8) { smWidth = 12 } } const renderStackElement = !['column', 'column-reverse'].includes(parent.direction) && (content.justify || content.align_content || content.align_items) return ( i) .join(' ')} style={style} hasCustomStyles={!!(style || className || background?.image)} > {background?.image && } {background?.background_elements && background.background_elements.length > 0 && ( )} {renderStackElement ? ( {content.body?.map((blok) => ( ))} ) : ( content.body?.map((blok) => ( )) )} ) }