File tree Expand file tree Collapse file tree 2 files changed +28
-46
lines changed
dotcom-rendering/src/components Expand file tree Collapse file tree 2 files changed +28
-46
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ const styles = css`
36
36
` ;
37
37
38
38
const galleryBodyImageStyles = css `
39
- display : flex;
39
+ display : inline;
40
+ position : relative;
40
41
${ grid . column . all }
41
42
42
43
${ from . tablet } {
@@ -74,32 +75,33 @@ export const GalleryImage = ({
74
75
75
76
return (
76
77
< figure css = { styles } >
77
- < div css = { galleryBodyImageStyles } >
78
- < div
79
- css = { css `
80
- position : relative;
81
- ` }
82
- >
83
- < Picture
84
- alt = { image . data . alt ?? '' }
85
- format = { format }
78
+ < div
79
+ css = { galleryBodyImageStyles }
80
+ /**
81
+ * This ensures that the image height never goes above 96vh.
82
+ */
83
+ style = { {
84
+ maxWidth : `calc(${ width / height } * 96vh)` ,
85
+ } }
86
+ >
87
+ < Picture
88
+ alt = { image . data . alt ?? '' }
89
+ format = { format }
90
+ role = { image . role }
91
+ master = { asset . url }
92
+ width = { width }
93
+ height = { height }
94
+ loading = "lazy"
95
+ />
96
+ { renderingTarget === 'Web' && ! isUndefined ( image . position ) && (
97
+ < LightboxLink
86
98
role = { image . role }
87
- master = { asset . url }
88
- width = { width }
89
- height = { height }
90
- loading = "lazy"
99
+ format = { format }
100
+ elementId = { image . elementId }
101
+ isMainMedia = { false }
102
+ position = { image . position }
91
103
/>
92
- { renderingTarget === 'Web' &&
93
- ! isUndefined ( image . position ) && (
94
- < LightboxLink
95
- role = { image . role }
96
- format = { format }
97
- elementId = { image . elementId }
98
- isMainMedia = { false }
99
- position = { image . position }
100
- />
101
- ) }
102
- </ div >
104
+ ) }
103
105
</ div >
104
106
105
107
< GalleryCaption
Original file line number Diff line number Diff line change 1
1
import { css } from '@emotion/react' ;
2
2
import { breakpoints } from '@guardian/source/foundations' ;
3
- import {
4
- type CSSProperties ,
5
- Fragment ,
6
- useCallback ,
7
- useEffect ,
8
- useState ,
9
- } from 'react' ;
3
+ import { Fragment , useCallback , useEffect , useState } from 'react' ;
10
4
import {
11
5
ArticleDesign ,
12
6
ArticleDisplay ,
@@ -471,19 +465,6 @@ export const Sources = ({ sources }: { sources: ImageSource[] }) => {
471
465
) ;
472
466
} ;
473
467
474
- /**
475
- * This ensures that the image height never goes above 96vh.
476
- * The ratio parameter should be width:height.
477
- */
478
- const imageMaxWidth = (
479
- design : ArticleDesign ,
480
- ratio : number ,
481
- isMainMedia : boolean ,
482
- ) : CSSProperties | undefined =>
483
- design === ArticleDesign . Gallery && ! isMainMedia
484
- ? { maxWidth : `calc(${ ratio } * 96vh)` }
485
- : undefined ;
486
-
487
468
const styles = ( { design } : ArticleFormat , isLightbox : boolean ) => {
488
469
if ( design === ArticleDesign . Gallery ) {
489
470
return css ( css `
@@ -595,7 +576,6 @@ export const Picture = ({
595
576
height = { fallbackSource . width * ratio }
596
577
loading = { Picture . disableLazyLoading ? undefined : loading }
597
578
css = { isLightbox ? flex : block }
598
- style = { imageMaxWidth ( format . design , 1 / ratio , isMainMedia ) }
599
579
/>
600
580
</ picture >
601
581
) ;
You can’t perform that action at this time.
0 commit comments