File tree Expand file tree Collapse file tree 3 files changed +30
-10
lines changed
dotcom-rendering/src/components Expand file tree Collapse file tree 3 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ type Props = {
11
11
visibleCardsOnMobile : number ;
12
12
visibleCardsOnTablet : number ;
13
13
sectionId ?: string ;
14
+ shouldStackCards ?: { desktop : boolean ; mobile : boolean } ;
14
15
} ;
15
16
16
17
/**
@@ -103,6 +104,20 @@ const itemStyles = css`
103
104
}
104
105
` ;
105
106
107
+ const stackedCardRowsStyles = ( {
108
+ mobile,
109
+ desktop,
110
+ } : {
111
+ mobile : boolean ;
112
+ desktop : boolean ;
113
+ } ) => css `
114
+ grid-template-rows : ${ mobile ? `1fr 1fr` : `1fr` } ;
115
+ ${ from . tablet } {
116
+ grid-auto-flow : ${ desktop ? `row` : `column` } ;
117
+ grid-template-rows : ${ desktop ? `1fr 1fr` : `1fr` } ;
118
+ }
119
+ ` ;
120
+
106
121
/**
107
122
* Generates CSS styles for a grid layout used in a carousel.
108
123
*
@@ -168,6 +183,7 @@ export const ScrollableCarousel = ({
168
183
visibleCardsOnMobile,
169
184
visibleCardsOnTablet,
170
185
sectionId,
186
+ shouldStackCards = { desktop : false , mobile : false } ,
171
187
} : Props ) => {
172
188
const carouselRef = useRef < HTMLOListElement | null > ( null ) ;
173
189
const [ previousButtonEnabled , setPreviousButtonEnabled ] = useState ( false ) ;
@@ -253,6 +269,7 @@ export const ScrollableCarousel = ({
253
269
visibleCardsOnMobile ,
254
270
visibleCardsOnTablet ,
255
271
) ,
272
+ stackedCardRowsStyles ( shouldStackCards ) ,
256
273
] }
257
274
data-heatphan-type = "carousel"
258
275
>
Original file line number Diff line number Diff line change @@ -35,14 +35,17 @@ export const ScrollableSmall = ({
35
35
aspectRatio,
36
36
sectionId,
37
37
} : Props ) => {
38
+ const mobileBottomCards = [ 1 , 3 ] ;
39
+ const desktopBottomCards = [ 2 , 3 ] ;
38
40
return (
39
41
< ScrollableCarousel
40
- carouselLength = { trails . length }
42
+ carouselLength = { Math . ceil ( trails . length / 2 ) }
41
43
visibleCardsOnMobile = { 1 }
42
44
visibleCardsOnTablet = { 2 }
43
45
sectionId = { sectionId }
46
+ shouldStackCards = { { desktop : trails . length > 2 , mobile : true } }
44
47
>
45
- { trails . map ( ( trail ) => {
48
+ { trails . map ( ( trail , index ) => {
46
49
return (
47
50
< ScrollableCarousel . Item key = { trail . url } >
48
51
< FrontCard
@@ -64,8 +67,10 @@ export const ScrollableSmall = ({
64
67
aspectRatio = { aspectRatio }
65
68
kickerText = { trail . kickerText }
66
69
showLivePlayable = { trail . showLivePlayable }
67
- showTopBarDesktop = { false }
68
- showTopBarMobile = { false }
70
+ showTopBarDesktop = { desktopBottomCards . includes (
71
+ index ,
72
+ ) }
73
+ showTopBarMobile = { mobileBottomCards . includes ( index ) }
69
74
canPlayInline = { false }
70
75
/>
71
76
</ ScrollableCarousel . Item >
Original file line number Diff line number Diff line change @@ -43,8 +43,6 @@ export default meta;
43
43
44
44
type Story = StoryObj < typeof ScrollableSmall > ;
45
45
46
- export const WithMultipleCards = { } ;
47
-
48
46
export const WithFourCards = {
49
47
args : {
50
48
trails : trails . slice ( 0 , 4 ) ,
@@ -57,15 +55,15 @@ export const WithThreeCards = {
57
55
} ,
58
56
} ;
59
57
60
- export const WithOneCard = {
58
+ export const WithTwoCards = {
61
59
args : {
62
- trails : trails . slice ( 0 , 1 ) ,
60
+ trails : trails . slice ( 0 , 2 ) ,
63
61
} ,
64
62
} ;
65
63
66
- export const WithTwoCards = {
64
+ export const WithOneCard = {
67
65
args : {
68
- trails : trails . slice ( 0 , 2 ) ,
66
+ trails : trails . slice ( 0 , 1 ) ,
69
67
} ,
70
68
} ;
71
69
You can’t perform that action at this time.
0 commit comments