Skip to content

Commit d7815ac

Browse files
authored
Merge pull request #14137 from guardian/add-gallery-sub-meta
Add gallery sub meta
2 parents 6fecdc2 + a2ecd44 commit d7815ac

File tree

4 files changed

+96
-20
lines changed

4 files changed

+96
-20
lines changed

dotcom-rendering/src/components/SubMeta.stories.tsx

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { css } from '@emotion/react';
22
import type { StoryProps } from '../../.storybook/decorators/splitThemeDecorator';
3-
import { splitTheme } from '../../.storybook/decorators/splitThemeDecorator';
3+
import {
4+
defaultFormats,
5+
splitTheme,
6+
} from '../../.storybook/decorators/splitThemeDecorator';
47
import {
58
ArticleDesign,
69
ArticleDisplay,
710
getAllThemes,
11+
Pillar,
812
} from '../lib/articleFormat';
13+
import { palette } from '../palette';
914
import { SubMeta } from './SubMeta';
1015

1116
export default {
@@ -74,7 +79,46 @@ export const StandardStory = ({ format }: StoryProps) => {
7479
);
7580
};
7681
StandardStory.storyName = 'Standard - All pillars';
77-
StandardStory.decorators = [splitTheme()];
82+
StandardStory.decorators = [
83+
splitTheme(
84+
[...defaultFormats].filter(
85+
(format) => format.design !== ArticleDesign.Gallery,
86+
),
87+
),
88+
];
89+
90+
export const GalleryStory = ({ format }: StoryProps) => {
91+
return (
92+
<SubMeta
93+
format={format}
94+
subMetaKeywordLinks={subMetaKeywordLinks}
95+
subMetaSectionLinks={subMetaSectionLinks}
96+
pageId=""
97+
webUrl=""
98+
webTitle=""
99+
showBottomSocialButtons={false} // Galelries do not have bottom social buttons
100+
/>
101+
);
102+
};
103+
GalleryStory.storyName = 'Gallery - All pillars';
104+
GalleryStory.decorators = [
105+
splitTheme(
106+
[
107+
{
108+
display: ArticleDisplay.Standard,
109+
design: ArticleDesign.Gallery,
110+
theme: Pillar.News,
111+
},
112+
],
113+
{ orientation: 'vertical' },
114+
),
115+
];
116+
GalleryStory.parameters = {
117+
colourSchemeBackground: {
118+
light: palette('--article-background'),
119+
dark: palette('--article-background'),
120+
},
121+
};
78122

79123
const allDeadBlogThemes = getAllThemes({
80124
display: ArticleDisplay.Standard,

dotcom-rendering/src/components/SubMeta.tsx

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { css } from '@emotion/react';
1+
import { css, type SerializedStyles } from '@emotion/react';
22
import {
33
from,
44
space,
@@ -7,13 +7,15 @@ import {
77
until,
88
} from '@guardian/source/foundations';
99
import { LinkButton } from '@guardian/source/react-components';
10+
import { grid } from '../grid';
1011
import { ArticleDesign, type ArticleFormat } from '../lib/articleFormat';
1112
import type { BaseLinkType } from '../model/extract-nav';
1213
import { palette } from '../palette';
1314
import { Island } from './Island';
1415
import { ShareButton } from './ShareButton.importable';
1516

16-
const labelStyles = css`
17+
const labelStyles = (design: ArticleDesign): SerializedStyles => css`
18+
${design === ArticleDesign.Gallery ? grid.column.centre : undefined};
1719
${textSans12};
1820
display: block;
1921
color: ${palette('--sub-meta-label-text')};
@@ -46,7 +48,7 @@ const setMetaWidth = css`
4648
}
4749
`;
4850

49-
const listStyleNone = css`
51+
const listStyles = css`
5052
list-style: none;
5153
/* https://developer.mozilla.org/en-US/docs/Web/CSS/list-style#accessibility_concerns */
5254
/* Needs double escape char: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#es2018_revision_of_illegal_escape_sequences */
@@ -79,7 +81,8 @@ const listStyleNone = css`
7981
background-repeat: no-repeat;
8082
`;
8183

82-
const listWrapper = css`
84+
const listWrapper = (design: ArticleDesign): SerializedStyles => css`
85+
${design === ArticleDesign.Gallery ? grid.column.centre : undefined};
8386
padding-bottom: 0.75rem;
8487
margin-bottom: 6px;
8588
border-bottom: 1px solid ${palette('--article-border')};
@@ -143,20 +146,31 @@ export const SubMeta = ({
143146
};
144147
};
145148
const { links, hasLinks } = createLinks();
149+
150+
const showSyndicationButton =
151+
format.design !== ArticleDesign.Interactive &&
152+
format.design !== ArticleDesign.Gallery;
153+
146154
return (
147155
<div
148156
data-print-layout="hide"
149-
css={
157+
css={[
158+
bottomPadding,
150159
format.design === ArticleDesign.Interactive
151-
? [bottomPadding, setMetaWidth]
152-
: bottomPadding
153-
}
160+
? setMetaWidth
161+
: undefined,
162+
format.design === ArticleDesign.Gallery
163+
? grid.container
164+
: undefined,
165+
]}
154166
>
155167
{hasLinks && (
156168
<>
157-
<span css={labelStyles}>Explore more on these topics</span>
158-
<div css={listWrapper}>
159-
<ul css={listStyleNone}>
169+
<span css={labelStyles(format.design)}>
170+
Explore more on these topics
171+
</span>
172+
<div css={listWrapper(format.design)}>
173+
<ul css={listStyles}>
160174
{links.map((link) => (
161175
<li css={listItemStyles} key={link.url}>
162176
<a css={linkStyles} href={link.url}>
@@ -184,7 +198,7 @@ export const SubMeta = ({
184198
/>
185199
</Island>
186200
<div css={syndicationButtonOverrides}>
187-
{format.design === ArticleDesign.Interactive ? null : (
201+
{showSyndicationButton ? (
188202
<LinkButton
189203
priority="tertiary"
190204
size="xsmall"
@@ -209,7 +223,7 @@ export const SubMeta = ({
209223
>
210224
Reuse this content
211225
</LinkButton>
212-
)}
226+
) : null}
213227
</div>
214228
</div>
215229
)}

dotcom-rendering/src/layouts/GalleryLayout.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ArticleTitle } from '../components/ArticleTitle';
77
import { MainMediaGallery } from '../components/MainMediaGallery';
88
import { Masthead } from '../components/Masthead/Masthead';
99
import { Standfirst } from '../components/Standfirst';
10+
import { SubMeta } from '../components/SubMeta';
1011
import { grid } from '../grid';
1112
import type { ArticleFormat } from '../lib/articleFormat';
1213
import type { NavType } from '../model/extract-nav';
@@ -167,7 +168,18 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
167168
</div>
168169
</header>
169170
<div css={border}>Body</div>
170-
<div css={border}>Submeta</div>
171+
<SubMeta
172+
format={format}
173+
subMetaKeywordLinks={frontendData.subMetaKeywordLinks}
174+
subMetaSectionLinks={frontendData.subMetaSectionLinks}
175+
pageId={frontendData.pageId}
176+
webUrl={frontendData.webURL}
177+
webTitle={frontendData.webTitle}
178+
showBottomSocialButtons={
179+
frontendData.showBottomSocialButtons &&
180+
props.renderingTarget === 'Web'
181+
}
182+
/>
171183
</main>
172184
</>
173185
);

dotcom-rendering/src/paletteDeclarations.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3731,6 +3731,8 @@ const subMetaLabelTextLight: PaletteFunction = ({ theme, design }) => {
37313731
case ArticleDesign.Video:
37323732
case ArticleDesign.Audio:
37333733
return sourcePalette.neutral[60];
3734+
case ArticleDesign.Gallery:
3735+
return sourcePalette.neutral[73];
37343736
default:
37353737
return sourcePalette.neutral[46];
37363738
}
@@ -3775,6 +3777,7 @@ const subMetaBackgroundLight: PaletteFunction = ({
37753777
case ArticleDesign.Picture:
37763778
case ArticleDesign.Video:
37773779
case ArticleDesign.Audio:
3780+
case ArticleDesign.Gallery:
37783781
switch (theme) {
37793782
case ArticleSpecial.Labs:
37803783
return sourcePalette.neutral[86];
@@ -3840,6 +3843,7 @@ const subMetaTextLight: PaletteFunction = ({ design, theme }) => {
38403843
case ArticleDesign.Picture:
38413844
case ArticleDesign.Video:
38423845
case ArticleDesign.Audio:
3846+
case ArticleDesign.Gallery:
38433847
return sourcePalette.neutral[86];
38443848
case ArticleDesign.DeadBlog:
38453849
case ArticleDesign.LiveBlog:
@@ -3889,10 +3893,12 @@ const subMetaTextDark: PaletteFunction = ({ design, theme }) => {
38893893
case ArticleSpecial.SpecialReportAlt:
38903894
return sourcePalette.specialReportAlt[300];
38913895
default:
3892-
if (design === ArticleDesign.Picture) {
3893-
return sourcePalette.neutral[86];
3894-
} else {
3895-
return pillarPalette(theme, 500);
3896+
switch (design) {
3897+
case ArticleDesign.Picture:
3898+
case ArticleDesign.Gallery:
3899+
return sourcePalette.neutral[86];
3900+
default:
3901+
return pillarPalette(theme, 500);
38963902
}
38973903
}
38983904
};

0 commit comments

Comments
 (0)