Skip to content

Commit 819aa76

Browse files
Merge branch 'mob/scrollable-products' into oa/navigation-arrows
2 parents ff53da0 + de9d97e commit 819aa76

File tree

6 files changed

+62
-49
lines changed

6 files changed

+62
-49
lines changed

dotcom-rendering/src/components/ScrollableCarousel.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,10 @@ const generateFixedWidthColumStyles = ({
209209
`);
210210
for (const { breakpoint, width } of fixedSlideWidth.widthFromBreakpoints) {
211211
fixedWidths.push(css`
212-
${from[breakpoint]}; {
213-
grid-template-columns: repeat(
214-
${carouselLength},
215-
${width}px
216-
);
217-
}
218-
`);
212+
${from[breakpoint]} {
213+
grid-template-columns: repeat(${carouselLength}, ${width}px);
214+
}
215+
`);
219216
}
220217
return fixedWidths;
221218
};

dotcom-rendering/src/frontend/feFront.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ export interface FEMediaAsset {
112112
platform: string;
113113
mimeType?: string;
114114
assetType: string;
115+
dimensions?: {
116+
width: number;
117+
height: number;
118+
};
115119
}
116120

117121
/** @see https://github.com/guardian/frontend/blob/0bf69f55a/common/app/model/content/Atom.scala#L158-L169 */
@@ -128,10 +132,6 @@ export interface FEMediaAtom {
128132
activeVersion?: number;
129133
videoPlayerFormat?: 'Default' | 'Loop' | 'Cinemagraph';
130134
// channelId?: string; // currently unused
131-
dimensions?: {
132-
width: number;
133-
height: number;
134-
};
135135
}
136136

137137
export type FEFrontCard = {

dotcom-rendering/src/frontend/schemas/feFront.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,21 +3247,6 @@
32473247
"Loop"
32483248
],
32493249
"type": "string"
3250-
},
3251-
"dimensions": {
3252-
"type": "object",
3253-
"properties": {
3254-
"width": {
3255-
"type": "number"
3256-
},
3257-
"height": {
3258-
"type": "number"
3259-
}
3260-
},
3261-
"required": [
3262-
"height",
3263-
"width"
3264-
]
32653250
}
32663251
},
32673252
"required": [
@@ -3287,6 +3272,21 @@
32873272
},
32883273
"assetType": {
32893274
"type": "string"
3275+
},
3276+
"dimensions": {
3277+
"type": "object",
3278+
"properties": {
3279+
"width": {
3280+
"type": "number"
3281+
},
3282+
"height": {
3283+
"type": "number"
3284+
}
3285+
},
3286+
"required": [
3287+
"height",
3288+
"width"
3289+
]
32903290
}
32913291
},
32923292
"required": [

dotcom-rendering/src/frontend/schemas/feTagPage.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,21 +1420,6 @@
14201420
"Loop"
14211421
],
14221422
"type": "string"
1423-
},
1424-
"dimensions": {
1425-
"type": "object",
1426-
"properties": {
1427-
"width": {
1428-
"type": "number"
1429-
},
1430-
"height": {
1431-
"type": "number"
1432-
}
1433-
},
1434-
"required": [
1435-
"height",
1436-
"width"
1437-
]
14381423
}
14391424
},
14401425
"required": [
@@ -1460,6 +1445,21 @@
14601445
},
14611446
"assetType": {
14621447
"type": "string"
1448+
},
1449+
"dimensions": {
1450+
"type": "object",
1451+
"properties": {
1452+
"width": {
1453+
"type": "number"
1454+
},
1455+
"height": {
1456+
"type": "number"
1457+
}
1458+
},
1459+
"required": [
1460+
"height",
1461+
"width"
1462+
]
14631463
}
14641464
},
14651465
"required": [

dotcom-rendering/src/model/enhanceCards.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ describe('Enhance Cards', () => {
1111
platform: 'Url',
1212
mimeType: 'video/mp4',
1313
assetType: 'Video',
14+
dimensions: {
15+
height: 400,
16+
width: 500,
17+
},
1418
},
1519
{
1620
id: 'https://guim-example.co.uk/atomID-1.m3u8',
1721
version: 1,
1822
platform: 'Url',
1923
mimeType: 'application/x-mpegURL',
2024
assetType: 'Video',
25+
dimensions: {
26+
height: 400,
27+
width: 500,
28+
},
2129
},
2230
];
2331
const mediaAtom: FEMediaAtom = {
@@ -73,13 +81,21 @@ describe('Enhance Cards', () => {
7381
platform: 'Url',
7482
mimeType: 'application/x-mpegURL',
7583
assetType: 'Video',
84+
dimensions: {
85+
height: 400,
86+
width: 500,
87+
},
7688
},
7789
{
7890
id: 'https://guim-example.co.uk/atomID-1.mp4',
7991
version: 1,
8092
platform: 'Url',
8193
mimeType: 'video/mp4',
8294
assetType: 'Video',
95+
dimensions: {
96+
height: 400,
97+
width: 500,
98+
},
8399
},
84100
];
85101
const mediaAtom: FEMediaAtom = {

dotcom-rendering/src/model/enhanceCards.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ export const getActiveMediaAtom = (
204204
({ version }) => version === mediaAtom.activeVersion,
205205
);
206206

207-
const videoAssets = assets.filter(
207+
const firstVideoAsset = assets.filter(
208208
({ assetType }) => assetType === 'Video',
209-
);
210-
if (!videoAssets.length) return undefined;
209+
)[0];
210+
if (!firstVideoAsset) return undefined;
211211

212212
const image = decideMediaAtomImage(
213213
videoReplace,
@@ -219,7 +219,7 @@ export const getActiveMediaAtom = (
219219
* Each version of a media atom will contain assets for self-hosted OR YouTube, but not both.
220220
* Therefore, we check the platform of the first asset and assume the rest are the same.
221221
*/
222-
if (assets[0]?.platform === 'Url') {
222+
if (firstVideoAsset.platform === 'Url') {
223223
/**
224224
* Take one source for each supported video file type.
225225
*/
@@ -249,20 +249,20 @@ export const getActiveMediaAtom = (
249249
})),
250250
subtitleSource: subtitleAsset?.id,
251251
duration: mediaAtom.duration ?? 0,
252-
width: mediaAtom.dimensions?.width ?? 500,
253-
height: mediaAtom.dimensions?.height ?? 400,
252+
width: firstVideoAsset.dimensions?.width ?? 500,
253+
height: firstVideoAsset.dimensions?.height ?? 400,
254254
image,
255255
};
256256
}
257257

258258
/**
259259
* There should only be one asset for Youtube atoms.
260260
*/
261-
if (assets[0]?.platform === 'Youtube') {
261+
if (firstVideoAsset.platform === 'Youtube') {
262262
return {
263263
type: 'YoutubeVideo',
264264
id: mediaAtom.id,
265-
videoId: assets[0].id,
265+
videoId: firstVideoAsset.id,
266266
duration: mediaAtom.duration ?? 0,
267267
title: mediaAtom.title,
268268
// Size fixed to a 5:3 ratio

0 commit comments

Comments
 (0)