Skip to content

Commit 977783b

Browse files
committed
Football nav atom for euros
A draft change to see if we can render a navigation atom for the euros.
1 parent 01555ed commit 977783b

File tree

8 files changed

+52
-4
lines changed

8 files changed

+52
-4
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { css } from '@emotion/react';
2+
import type { FootballNavAtom as FootballNavAtomModel } from '../footballNavAtom';
3+
import { grid } from '../grid';
4+
import { unifyPageContent } from '../lib/unifyPageContent';
5+
6+
export const FootballNavAtom = ({
7+
navAtom,
8+
}: {
9+
navAtom: FootballNavAtomModel | undefined;
10+
}) =>
11+
navAtom !== undefined ? (
12+
<iframe
13+
title="Navigation for the current football competition"
14+
css={{
15+
width: '100%',
16+
['&']: css(grid.column.all),
17+
gridRow: 1,
18+
}}
19+
srcDoc={unifyPageContent({
20+
elementCss: navAtom.css,
21+
elementJs: navAtom.mainJS,
22+
elementHtml: navAtom.html,
23+
renderingTarget: 'Web',
24+
})}
25+
sandbox="allow-scripts"
26+
/>
27+
) : null;

dotcom-rendering/src/components/FootballTablesPage.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import {
55
space,
66
until,
77
} from '@guardian/source/foundations';
8+
import type { FootballNavAtom as FootballNavAtomModel } from '../footballNavAtom';
89
import type { FootballTableCompetition } from '../footballTables';
910
import { grid } from '../grid';
1011
import { palette } from '../palette';
1112
import type { Region } from '../sportDataPage';
1213
import { AdSlot } from './AdSlot.web';
14+
import { FootballNavAtom } from './FootballNavAtom';
1315
import { FootballTableList } from './FootballTableList';
1416
import { FootballTablesCompetitionSelect } from './FootballTablesCompetitionSelect.importable';
1517
import { Island } from './Island';
@@ -20,6 +22,7 @@ type Props = {
2022
tableCompetitions: FootballTableCompetition[];
2123
renderAds: boolean;
2224
guardianBaseUrl: string;
25+
navAtom?: FootballNavAtomModel;
2326
};
2427

2528
export const FootballTablesPage = ({
@@ -28,6 +31,7 @@ export const FootballTablesPage = ({
2831
tableCompetitions: competitions,
2932
renderAds,
3033
guardianBaseUrl,
34+
navAtom,
3135
}: Props) => (
3236
<main
3337
id="maincontent"
@@ -53,12 +57,13 @@ export const FootballTablesPage = ({
5357
padding-bottom: ${space[9]}px;
5458
`}
5559
>
60+
<FootballNavAtom navAtom={navAtom} />
5661
<h1
5762
css={css`
5863
${headlineBold20}
5964
padding: ${space[2]}px 0 ${space[3]}px;
6065
${grid.column.centre}
61-
grid-row: 1;
66+
grid-row: ${navAtom !== undefined ? 2 : 1};
6267
${from.leftCol} {
6368
${grid.between('left-column-start', 'centre-column-end')}
6469
}
@@ -71,7 +76,7 @@ export const FootballTablesPage = ({
7176
margin-top: ${space[3]}px;
7277
margin-bottom: ${space[6]}px;
7378
${grid.column.centre}
74-
grid-row: 2;
79+
grid-row: ${navAtom !== undefined ? 3 : 2};
7580
`}
7681
>
7782
<Island priority="feature" defer={{ until: 'visible' }}>
@@ -85,7 +90,7 @@ export const FootballTablesPage = ({
8590
<div
8691
css={css`
8792
${grid.column.centre}
88-
grid-row: 3;
93+
grid-row: ${navAtom !== undefined ? 4 : 3};
8994
${from.leftCol} {
9095
${grid.between('left-column-start', 'centre-column-end')}
9196
}
@@ -102,7 +107,7 @@ export const FootballTablesPage = ({
102107
css={css`
103108
${grid.column.right}
104109
/** This allows the ad to grow beyond the third row content (up to line 5) */
105-
grid-row: 1 / 4;
110+
grid-row: ${navAtom !== undefined ? '2 / 5' : '1 / 4'};
106111
${until.desktop} {
107112
display: none;
108113
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { FEFootballNavAtom } from './frontend/feFootballNavAtom';
2+
3+
export type FootballNavAtom = FEFootballNavAtom;

dotcom-rendering/src/frontend/feFootballMatchListPage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
FEFootballDataPage,
55
FERound,
66
} from './feFootballDataPage';
7+
import type { FEFootballNavAtom } from './feFootballNavAtom';
78

89
type FEStage = {
910
stageNumber: string;
@@ -95,4 +96,5 @@ export type FEFootballMatchListPage = FEFootballDataPage & {
9596
nextPage?: string;
9697
nextPageNoJs?: string;
9798
previousPage?: string;
99+
atom?: FEFootballNavAtom;
98100
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export type FEFootballNavAtom = {
2+
html: string;
3+
css: string;
4+
mainJS: string;
5+
};

dotcom-rendering/src/frontend/feFootballTablesPage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
FEFootballDataPage,
55
FERound,
66
} from './feFootballDataPage';
7+
import type { FEFootballNavAtom } from './feFootballNavAtom';
78

89
type FELeagueStats = {
910
played: number;
@@ -64,4 +65,5 @@ export type FEFootballTable = {
6465
export type FEFootballTablesPage = FEFootballDataPage & {
6566
filters: Record<string, FEFootballCompetition[]>;
6667
tables: FEFootballTable[];
68+
atom?: FEFootballNavAtom;
6769
};

dotcom-rendering/src/server/handler.sportDataPage.web.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const parseFEFootballMatchList = (
118118
isAdFreeUser: data.isAdFreeUser,
119119
canonicalUrl: data.canonicalUrl,
120120
contributionsServiceUrl: data.contributionsServiceUrl,
121+
navAtom: data.atom,
121122
};
122123
};
123124

@@ -157,6 +158,7 @@ const parseFEFootballTables = (
157158
isAdFreeUser: data.isAdFreeUser,
158159
canonicalUrl: data.canonicalUrl,
159160
contributionsServiceUrl: data.contributionsServiceUrl,
161+
navAtom: data.atom,
160162
};
161163
};
162164

dotcom-rendering/src/sportDataPage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { CricketMatch } from './cricketMatch';
22
import type { FootballMatch } from './footballMatch';
33
import type { FootballMatches } from './footballMatches';
4+
import type { FootballNavAtom } from './footballNavAtom';
45
import type { FootballTableCompetitions } from './footballTables';
56
import type { FESportPageConfig } from './frontend/feFootballDataPage';
67
import type { EditionId } from './lib/edition';
@@ -14,6 +15,7 @@ export type Region = {
1415

1516
export type FootballData = SportPageConfig & {
1617
regions: Region[];
18+
navAtom?: FootballNavAtom;
1719
};
1820

1921
export type SportPageConfig = {

0 commit comments

Comments
 (0)