diff --git a/src/components/Banner/Banner.tsx b/src/components/Banner/Banner.tsx index 673442b..1cc125b 100644 --- a/src/components/Banner/Banner.tsx +++ b/src/components/Banner/Banner.tsx @@ -1,12 +1,24 @@ +import Image from 'next/image' +import type { CSSProperties } from 'react' import { Logo } from '@/components/Logo/Logo' +import type { Media } from '@/payload-types' import styles from "./styles.module.scss" +const backgroundSizeToObjectFit: Record< + 'cover' | 'contain' | 'auto', + CSSProperties['objectFit'] +> = { + cover: 'cover', + contain: 'contain', + auto: 'none', +} + export interface BannerProps { textLine1?: string | null textLine2?: string | null textLine3?: string | null backgroundColor?: string | null - backgroundImage?: string | null + backgroundImage?: Media | null backgroundPosition?: | 'center center' | 'top center' @@ -30,15 +42,27 @@ export const Banner = ({ backgroundPosition = 'center center', backgroundSize = 'cover', }: BannerProps) => { - const bannerStyle: React.CSSProperties = { + const bannerStyle: CSSProperties = { ...(backgroundColor && { backgroundColor }), - ...(backgroundImage && { backgroundImage: `url(${backgroundImage})` }), - ...(backgroundPosition && { backgroundPosition }), - ...(backgroundSize && { backgroundSize }), } return (