Skip to content

Commit

Permalink
Merge branch 'bose/2433' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
BorghildSelle committed Aug 27, 2024
2 parents 6f6dc69 + ef86f5a commit 82916bc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions web/pageComponents/shared/SanityImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const DEFAULT_MAX_WIDTH = 1440

const Image = ({ image, aspectRatio, sizes = DEFAULT_SIZES, maxWidth = DEFAULT_MAX_WIDTH, fill, ...rest }: Props) => {
const imageProps = useSanityLoader(image, maxWidth, aspectRatio)
console.log('image iamge', image)
if (!image?.asset) return <></>
const { width, height, src } = imageProps

Expand Down
5 changes: 3 additions & 2 deletions web/templates/newsroom/NewsSections/NewsHeadliner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ const NewsHeadliner = forwardRef<HTMLLIElement, NewsHeadlinerProps>(function New
return (
<section ref={ref} {...rest} className={envisTwMerge('', className)}>
<BaseLink href={slug} className="group flex flex-col gap-2 pb-12">
{(heroImage ?? fallbackImage) && (
{(heroImage?.image?.asset || fallbackImage) && (
<div className="aspect-video relative max-h-[324px] mb-2">
<Image
image={heroImage?.image ?? fallbackImage}
//@ts-ignore: TODO Fix SanityImage to take SanityImageObject
image={heroImage?.image?.asset ? heroImage?.image : fallbackImage}
fill
priority
aspectRatio={Ratios.NINE_TO_SIXTEEN}
Expand Down
6 changes: 4 additions & 2 deletions web/templates/newsroom/NewsSections/NewsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const NewsItem = forwardRef<HTMLLIElement, NewsListItemProps>(function NewsItem(
) {
const { slug, pageTitle, publishDateTime, heroImage } = data || {}

console.log('heroImage', heroImage)
return (
<section ref={ref} className={envisTwMerge('', className)} {...rest}>
<BaseLink href={slug} className="group grid grid-cols-[1fr_25vw] lg:grid-cols-[1fr_10vw] gap-4 lg:gap-6">
Expand All @@ -33,9 +34,10 @@ const NewsItem = forwardRef<HTMLLIElement, NewsListItemProps>(function NewsItem(
)}
</div>
<div className="lg:w-[173px] h-full aspect-5/4 lg:aspect-video relative">
{(heroImage ?? fallbackImage) && (
{(heroImage?.image?.asset || fallbackImage) && (
<Image
image={heroImage?.image ?? fallbackImage}
//@ts-ignore: TODO Fix SanityImage to take SanityImageObject
image={heroImage?.image?.asset ? heroImage?.image : fallbackImage}
aria-hidden
aspectRatio={Ratios.NINE_TO_SIXTEEN}
sizes="(max-width: 800px) 100vw, 800px"
Expand Down
6 changes: 4 additions & 2 deletions web/templates/newsroom/NewsSections/NewsSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const NewsSections = forwardRef<HTMLDivElement, NewsSectionsProps>(function News
return <FormattedMessage id="newsroom_no_hits" defaultMessage="Your search returned no results" />
}

console.log('fallbackImages', fallbackImages)

return (
<div ref={ref} className={envisTwMerge(`flex flex-col gap-4`, className)}>
{items.map((hit, index) => {
Expand All @@ -29,7 +31,7 @@ const NewsSections = forwardRef<HTMLDivElement, NewsSectionsProps>(function News
key={hit.objectID}
//@ts-ignore: TODO Hit<BaseHit> into a NewsRoomNewsItem
data={hit}
{...(!hit?.heroImage &&
{...(!hit?.heroImage?.image?.asset &&
fallbackImages && {
fallbackImage: fallbackImages[Math.floor(Math.random() * fallbackImages?.length)],
})}
Expand All @@ -39,7 +41,7 @@ const NewsSections = forwardRef<HTMLDivElement, NewsSectionsProps>(function News
key={hit.objectID}
//@ts-ignore: TODO Hit<BaseHit> into a NewsRoomNewsItem
data={hit}
{...(!hit?.heroImage &&
{...(!hit?.heroImage?.image?.asset &&
fallbackImages && {
fallbackImage: fallbackImages[Math.floor(Math.random() * fallbackImages?.length)],
})}
Expand Down

0 comments on commit 82916bc

Please sign in to comment.