Skip to content

Commit

Permalink
🐛 fix missing aspect ratio in figure (#2512)
Browse files Browse the repository at this point in the history
  • Loading branch information
BorghildSelle authored Sep 11, 2024
1 parent 13cae47 commit d26faf5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions web/lib/queries/common/pageContentFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ _type == "keyNumbers" =>{
},
"designOptions": {
${background},
"aspectRatio": coalesce(aspectRatio, '16:9'),
},
},
_type == "textWithIconArray"=>{
Expand Down
1 change: 1 addition & 0 deletions web/pageComponents/shared/SanityImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum Ratios {
THREE_TO_TEN = 0.3,
NINETEEN_TO_FORTY = 0.475,
ONE_TO_TWO = 0.5,
SIXTEEN_TO_NINE = 1.77,
NINE_TO_SIXTEEN = 0.5625,
THREE_TO_FOUR = 0.75,
FOUR_TO_FIVE = 0.8,
Expand Down
11 changes: 6 additions & 5 deletions web/pageComponents/topicPages/Figure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import type { FigureData } from '../../types/types'
import { BackgroundContainer, FigureCaption } from '@components'
import Image, { Ratios } from '../shared/SanityImage'

type TeaserProps = {
type FigureProps = {
data: FigureData
anchor?: string
className?: string
}

const FullWidthImage = ({ data, anchor, className }: TeaserProps) => {
const Figure = ({ data, anchor, className }: FigureProps) => {
const { figure, designOptions } = data

// With previews in Sanity, we need to support work in progress figures
Expand All @@ -23,13 +23,14 @@ const FullWidthImage = ({ data, anchor, className }: TeaserProps) => {
className={className}
renderFragmentWhenPossible
>
<figure className="pb-page-content px-layout-lg max-w-viewport mx-auto">
{designOptions.aspectRatio === '9:16' ? (
<figure className={`pb-page-content px-layout-md max-w-viewport mx-auto`}>
{designOptions.aspectRatio === '16:9' ? (
<Image
image={image}
aspectRatio={Ratios.NINE_TO_SIXTEEN}
maxWidth={920}
sizes={'(min-width: 2060px) 920px, (min-width: 440px) calc(34.56vw + 215px), calc(76.67vw + 38px)'}
className={`aspect-video`}
/>
) : (
<Image
Expand All @@ -50,4 +51,4 @@ const FullWidthImage = ({ data, anchor, className }: TeaserProps) => {
)
}

export default FullWidthImage
export default Figure
2 changes: 1 addition & 1 deletion web/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export type TableHeaderData = {
headerCell: PortableTextBlock[]
}

export type FigureRatio = 'original' | '9:16'
export type FigureRatio = 'original' | '16:9'

export type CellData = {
id: string
Expand Down

0 comments on commit d26faf5

Please sign in to comment.