import classNames from 'classnames'; import React, { FC, ReactElement } from 'react'; import Content from '../../components/Content'; import { getModifier } from '../../helpers/getModifier'; import SaleSVG from '../../assets/icons/ribbon-sale.svg'; export interface SliceProps { title: string; type?: string; description?: string; background: string; id?: string; children?: ReactElement; backgroundOdd?: boolean; fullWidthCampaign?: boolean; } import css from './index.module.css'; import { MilaGridColumn, MilaGridVoid } from '../../index'; const Slice: FC = ({ children, title, background, id, description, type, backgroundOdd = false, fullWidthCampaign = false, }) => { const sliceClassNames = classNames(css.slice, { [`${css[`slice${getModifier(background)}`]}`]: background, [`${css[`odd`]}`]: backgroundOdd && !background, [`${css[`even`]}`]: !backgroundOdd && !background, }); let sliceType = type || ''; if ( sliceType === 'ContentfulSliceRows' && children?.props?.variant === 'bubble' ) { sliceType = 'Bubble'; } if ( sliceType === 'ContentfulSliceRows' && children?.props?.variant === 'roles' ) { sliceType = 'Roles'; } if ( sliceType === 'ContentfulSliceRows' && children?.props?.variant === 'partners' ) { sliceType = 'Partners'; } if ( sliceType === 'ContentfulSliceRows' && children?.props?.variant === 'campaign' ) { sliceType = 'Campaign'; } switch (sliceType) { case 'ContentfulSliceCarousel': return (

{title}

{description && (
{description}
)}
{children}
); case 'Bubble': return (

{title}

{description && (
{description}
)}
{children}
); case 'Partners': return (

{title}

{description && (
{description}
)}
{children}
); case 'Roles': return (

{title}

{description && (
{description}
)}
2 ? { columns: ['sm-12', 'lg-10'], offset: ['lg-1'] } : { columns: ['sm-12', 'lg-10', 'xl-8', 'xxl-6'], offset: ['lg-1', 'xl-2', 'xxl-3'], })} >
{children}
); case 'Campaign': return (
{fullWidthCampaign && (
)} {title &&

{title}

} {description && (
{description}
)}
{children}
); default: return (
{title &&

{title}

} {description && (
{description}
)}
{children}
); } }; export default Slice;