Skip to content

Commit ce0735e

Browse files
marjisoundJamieB-gu
andcommitted
gallery main media in progress
Co-authored-by: Jamie B <[email protected]>
1 parent 24eef8f commit ce0735e

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import type { Meta, StoryObj } from '@storybook/react';
2+
import { gridContainerDecorator } from '../../.storybook/decorators/gridDecorators';
23
import { images } from '../../fixtures/generated/images';
3-
import { grid } from '../grid';
44
import { ArticleDesign, ArticleDisplay, Pillar } from '../lib/articleFormat';
55
import { MainMediaGallery } from './MainMediaGallery';
66

77
const meta = {
88
title: 'Components/MainMediaGallery',
99
component: MainMediaGallery,
10+
decorators: gridContainerDecorator,
1011
} satisfies Meta<typeof MainMediaGallery>;
1112

1213
export default meta;
1314

1415
type Story = StoryObj<typeof meta>;
1516

16-
export const FirstStory = {
17+
export const Default = {
1718
args: {
1819
mainMedia: images[0],
1920
format: {
@@ -22,12 +23,11 @@ export const FirstStory = {
2223
theme: Pillar.News,
2324
},
2425
},
25-
decorators: [
26-
// To make it easier to see the top border above the date
27-
(Story) => (
28-
<div css={[grid.container]}>
29-
<Story />
30-
</div>
31-
),
32-
],
3326
} satisfies Story;
27+
28+
export const PortraitImage = {
29+
args: {
30+
...Default.args,
31+
mainMedia: images[7],
32+
},
33+
};

dotcom-rendering/src/components/MainMediaGallery.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { grid } from '../grid';
44
import { type ArticleFormat } from '../lib/articleFormat';
55
import { getImage } from '../lib/image';
66
import { type ImageBlockElement } from '../types/content';
7+
import { minHeaderHeightPx } from './Masthead/Titlepiece/constants';
78
import { generateSources, Sources } from './Picture';
89

910
type Props = {
@@ -13,10 +14,9 @@ type Props = {
1314

1415
const styles = css`
1516
${grid.column.all}
16-
height: calc(80vh - 48px);
17-
grid-row: 1/5;
17+
height: calc(80vh - ${minHeaderHeightPx}px);
1818
${from.desktop} {
19-
height: calc(100vh - 48px);
19+
height: calc(100vh - ${minHeaderHeightPx}px);
2020
}
2121
`;
2222

@@ -42,7 +42,7 @@ export const MainMediaGallery = ({ mainMedia, format }: Props) => {
4242
{ breakpoint: breakpoints.desktop, width: 1140 },
4343
{ breakpoint: breakpoints.leftCol, width: 1300 },
4444
{ breakpoint: breakpoints.wide, width: 1900 },
45-
] as const);
45+
]);
4646

4747
const fallbackSource = sources[0];
4848

@@ -53,8 +53,11 @@ export const MainMediaGallery = ({ mainMedia, format }: Props) => {
5353
<img
5454
alt={mainMedia.data.alt}
5555
src={fallbackSource?.lowResUrl}
56-
width={fallbackSource?.width}
57-
height={(fallbackSource?.width ?? 1) * 1.0}
56+
css={css`
57+
object-fit: cover;
58+
height: 100%;
59+
width: 100%;
60+
`}
5861
/>
5962
</picture>
6063
</figure>

0 commit comments

Comments
 (0)