Skip to content

Commit f66c847

Browse files
authored
Merge pull request #14261 from guardian/add-main-media-caption
Add gallery main media caption
2 parents c479c60 + 4ba00e7 commit f66c847

File tree

2 files changed

+24
-32
lines changed

2 files changed

+24
-32
lines changed

dotcom-rendering/src/components/Caption.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
textSans14,
77
until,
88
} from '@guardian/source/foundations';
9+
import { grid } from '../grid';
910
import {
1011
ArticleDesign,
1112
ArticleDisplay,
@@ -208,12 +209,21 @@ const captionLink = css`
208209
}
209210
`;
210211

212+
const galleryStyles = css`
213+
${grid.column.centre}
214+
${from.leftCol} {
215+
${grid.column.left}
216+
grid-row-start: 8;
217+
}
218+
`;
219+
211220
const CameraIcon = ({ format }: IconProps) => {
212221
return (
213222
<span
214223
css={[
215224
iconStyle,
216-
format.display === ArticleDisplay.Immersive &&
225+
(format.display === ArticleDisplay.Immersive ||
226+
format.design === ArticleDesign.Gallery) &&
217227
hideIconBelowLeftCol,
218228
]}
219229
>
@@ -256,6 +266,8 @@ export const Caption = ({
256266
const hideCredit = !displayCredit;
257267
if (noCaption && (noCredit || hideCredit)) return null;
258268

269+
const isGallery = format.design === ArticleDesign.Gallery;
270+
259271
const isBlog =
260272
format.design === ArticleDesign.LiveBlog ||
261273
format.design === ArticleDesign.DeadBlog;
@@ -271,6 +283,7 @@ export const Caption = ({
271283
tabletCaptionPadding,
272284
padCaption && captionPadding,
273285
isImmersive && immersivePadding,
286+
isGallery && galleryStyles,
274287
]}
275288
data-spacefinder-role="inline"
276289
>

dotcom-rendering/src/layouts/GalleryLayout.tsx

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { css } from '@emotion/react';
2-
import {
3-
between,
4-
from,
5-
palette as sourcePalette,
6-
} from '@guardian/source/foundations';
2+
import { from, palette as sourcePalette } from '@guardian/source/foundations';
73
import { AppsFooter } from '../components/AppsFooter.importable';
84
import { ArticleHeadline } from '../components/ArticleHeadline';
95
import { ArticleMetaApps } from '../components/ArticleMeta.apps';
106
import { ArticleMeta } from '../components/ArticleMeta.web';
117
import { ArticleTitle } from '../components/ArticleTitle';
8+
import { Caption } from '../components/Caption';
129
import { Footer } from '../components/Footer';
1310
import { GalleryImage } from '../components/GalleryImage';
1411
import { Island } from '../components/Island';
@@ -19,6 +16,7 @@ import { Standfirst } from '../components/Standfirst';
1916
import { SubMeta } from '../components/SubMeta';
2017
import { grid } from '../grid';
2118
import type { ArticleFormat } from '../lib/articleFormat';
19+
import { decideMainMediaCaption } from '../lib/decide-caption';
2220
import type { NavType } from '../model/extract-nav';
2321
import { palette } from '../palette';
2422
import type { Gallery } from '../types/article';
@@ -60,6 +58,8 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
6058
const isWeb = props.renderingTarget === 'Web';
6159
const isApps = props.renderingTarget === 'Apps';
6260

61+
const captionText = decideMainMediaCaption(props.gallery.mainMedia);
62+
6363
const format: ArticleFormat = {
6464
design: gallery.design,
6565
display: gallery.display,
@@ -117,6 +117,11 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
117117
format={format}
118118
standfirst={frontendData.standfirst}
119119
/>
120+
<Caption
121+
captionText={captionText}
122+
format={format}
123+
isMainMedia={true}
124+
/>
120125
{isWeb ? (
121126
<ArticleMeta
122127
branding={
@@ -166,32 +171,6 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
166171
shortUrlId={frontendData.config.shortUrlId}
167172
/>
168173
) : null}
169-
<div
170-
css={[
171-
css`
172-
${grid.column.centre}
173-
${from.leftCol} {
174-
${grid.column.left}
175-
}
176-
position: relative;
177-
${between.tablet.and.leftCol} {
178-
&::before {
179-
content: '';
180-
position: absolute;
181-
left: -10px;
182-
top: 0;
183-
bottom: 0;
184-
width: 1px;
185-
background-color: ${palette(
186-
'--article-border',
187-
)};
188-
}
189-
}
190-
`,
191-
]}
192-
>
193-
Main media caption
194-
</div>
195174
</header>
196175
{gallery.images.map((element, idx) => (
197176
<GalleryImage

0 commit comments

Comments
 (0)