import { ParallaxBanner, ParallaxBannerLayer } from 'react-scroll-parallax'
import Image from 'next/image'
import { LmComponentRender } from '@LmComponentRender'
import { LmSectionParallaxProps } from './sectionTypes'
import {
getOriginalImageDimensions,
getRootImageUrl
} from '../../utils/imageServices'
import { storyblokImageLoader } from '../../utils/storyblokImageLoader'
import Box from '@mui/material/Box'
import { BannerLayer } from 'react-scroll-parallax/dist/components/ParallaxBanner/types'
export default function LmSectionParallax({
content,
sectionPosition
}: LmSectionParallaxProps) {
const contentHeight = content.height
const isPriority = sectionPosition === 0 || !!content.disable_lazy_load
const Children =
content.elements?.map(
({
_uid,
always_complete_animation,
amount,
speed,
image,
parallax_item_data,
children,
expanded,
easing,
...props
}) => {
const layerProps: BannerLayer = {}
Object.keys(props).forEach((key) => {
const lProp = props[key].split(',').map((i: string) => {
const trimmed = i.trim()
return Number(trimmed) ? Number(trimmed) : trimmed
})
layerProps[key] = lProp
})
return (
<>
{image && (
)}
{children?.map((child) => (
))}
>
)
}
) ?? []
if (content.body?.length) {
Children.push(
.lm-grid-row__wrap': {
overflowX: 'hidden',
height: '100%'
}
}}
className={content.class_names?.values?.join(' ')}
>
{content.body.map((blok) => (
))}
)
}
return Children.length ? (
i.trim())
: undefined,
height: !content.ratio ? `${contentHeight || 50}vh` : undefined,
overflow: content.allow_overflow ? 'visible' : undefined
}}
>
{Children}
) : null
}