Skip to content

Commit

Permalink
🎨 updates to newsroom #2631 (#2635)
Browse files Browse the repository at this point in the history
* 🎨 updates to newsroom

* 🐛 correct url
  • Loading branch information
BorghildSelle authored Nov 4, 2024
1 parent 057beff commit b4f1788
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 24 deletions.
4 changes: 4 additions & 0 deletions web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export default withBundle({
source: '/legacy/:slug*',
destination: `${archiveServerHostname}/:slug*`,
},
{
source: 'https://envisstoragedev.blob.core.windows.net/:slug*',
destination: `${archiveServerHostname}/:slug*`,
},
].filter((e) => e)
},
async headers() {
Expand Down
40 changes: 28 additions & 12 deletions web/templates/newsroom/NewsSections/NewsHeadliner.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FormattedDate } from '@components/FormattedDateTime'
import { forwardRef, HTMLAttributes } from 'react'
import Img from 'next/image'
import { BaseLink } from '@core/Link'
import { Typography } from '@core/Typography'
import Image, { Ratios } from '../../../pageComponents/shared/SanityImage'
Expand All @@ -17,23 +18,38 @@ const NewsHeadliner = forwardRef<HTMLLIElement, NewsHeadlinerProps>(function New
{ data, fallbackImage, className = '', ...rest },
ref,
) {
const { slug, title, ingress, publishDateTime, heroImage } = data
const { slug, title, ingress, publishDateTime, heroImage, thumbnailUrl } = data

return (
<section ref={ref} {...rest} className={envisTwMerge('', className)}>
<BaseLink href={slug} className="group flex flex-col gap-2 pb-6">
{(heroImage?.image?.asset || fallbackImage) && (
{(heroImage?.image?.asset || fallbackImage || thumbnailUrl) && (
<div className="aspect-video relative max-h-[324px] mb-2">
<Image
//@ts-ignore: TODO Fix SanityImage to take SanityImageObject
image={heroImage?.image?.asset ? heroImage?.image : fallbackImage}
fill
priority
aspectRatio={Ratios.NINE_TO_SIXTEEN}
sizes="(max-width: 800px) 100vw, 1440px"
className="rounded-xs"
aria-hidden
/>
{thumbnailUrl ? (
<div className="relative rounded-xs">
<Img
src={thumbnailUrl}
alt=""
style={{ objectFit: 'cover' }}
fill
sizes="(max-width: 800px) 100vw, 800px"
role={'presentation'}
/>
</div>
) : (
(heroImage?.image?.asset || fallbackImage) && (
<Image
//@ts-ignore: TODO Fix SanityImage to take SanityImageObject
image={heroImage?.image?.asset ? heroImage?.image : fallbackImage}
aria-hidden
priority
aspectRatio={Ratios.NINE_TO_SIXTEEN}
sizes="(max-width: 800px) 100vw, 800px"
fill
className="rounded-xs"
/>
)
)}
</div>
)}
{publishDateTime && (
Expand Down
42 changes: 30 additions & 12 deletions web/templates/newsroom/NewsSections/NewsItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FormattedDate } from '@components/FormattedDateTime'
import { forwardRef, HTMLAttributes } from 'react'
import Img from 'next/image'
import { BaseLink } from '@core/Link'
import { Typography } from '@core/Typography'
import Image, { Ratios } from '../../../pageComponents/shared/SanityImage'
Expand All @@ -17,12 +18,12 @@ const NewsItem = forwardRef<HTMLLIElement, NewsListItemProps>(function NewsItem(
{ data, fallbackImage, className = '', ...rest },
ref,
) {
const { slug, title, publishDateTime, heroImage } = data || {}
const { slug, title, publishDateTime, heroImage, thumbnailUrl } = data || {}

return (
<section ref={ref} className={envisTwMerge('', className)} {...rest}>
<BaseLink href={slug} className="group flex justify-between gap-4 lg:gap-6">
<div className=" max-w-[65%]">
<div className="max-w-[65%]">
{publishDateTime && (
<FormattedDate datetime={publishDateTime} uppercase className="text-2xs font-normal leading-normal pb-1" />
)}
Expand All @@ -33,16 +34,33 @@ const NewsItem = forwardRef<HTMLLIElement, NewsListItemProps>(function NewsItem(
)}
</div>
<div className="w-[30%] lg:h-full aspect-5/4 lg:aspect-video relative">
{(heroImage?.image?.asset || fallbackImage) && (
<Image
//@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"
fill
className="rounded-xs"
/>
{(heroImage?.image?.asset || fallbackImage || thumbnailUrl) && (
<>
{thumbnailUrl ? (
<div className="relative rounded-xs">
<Img
src={thumbnailUrl}
alt=""
style={{ objectFit: 'cover' }}
fill
sizes="(max-width: 800px) 100vw, 800px"
role={'presentation'}
/>
</div>
) : (
(heroImage?.image?.asset || fallbackImage) && (
<Image
//@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"
fill
className="rounded-xs"
/>
)
)}
</>
)}
</div>
</BaseLink>
Expand Down
1 change: 1 addition & 0 deletions web/types/algoliaIndexPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type NewsRoomNewsItem = {
publishDateTime?: string
firstPublishedAt?: string
heroImage: ImageWithCaptionData
thumbnailUrl?: string
ingress?: string
}

Expand Down

0 comments on commit b4f1788

Please sign in to comment.