Skip to content

Commit c401707

Browse files
authored
Merge pull request #14381 from guardian/doml/scrollable-highlights-design-tweaks
Scrollable highlights design tweaks
2 parents e6e1a7c + 80387ec commit c401707

File tree

2 files changed

+68
-38
lines changed

2 files changed

+68
-38
lines changed

dotcom-rendering/src/components/Masthead/HighlightsCard.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ const container = css`
3838
display: flex;
3939
flex-direction: column;
4040
justify-content: space-between;
41+
height: 100%;
4142
column-gap: ${space[2]}px;
4243
/** Relative positioning is required to absolutely position the card link overlay */
4344
position: relative;
44-
padding: 10px 10px 0 10px;
45+
padding: ${space[2]}px ${space[2]}px 0 ${space[2]}px;
4546
background-color: ${palette('--highlights-card-background')};
4647
4748
/**
@@ -55,22 +56,17 @@ const container = css`
5556
${until.mobileMedium} {
5657
min-height: 174px;
5758
}
58-
5959
${between.mobileMedium.and.tablet} {
6060
min-height: 194px;
61-
height: 100%;
6261
}
63-
6462
${from.tablet} {
65-
height: 100%;
6663
width: 160px;
64+
padding: 10px 10px 0 10px;
6765
}
68-
6966
${from.tablet} {
7067
width: 280px;
7168
flex-direction: row;
7269
}
73-
7470
${from.desktop} {
7571
width: 300px;
7672
}
@@ -105,6 +101,7 @@ const content = css`
105101
padding-bottom: 10px;
106102
}
107103
`;
104+
108105
const starWrapper = css`
109106
width: fit-content;
110107
margin-top: ${space[1]}px;

dotcom-rendering/src/components/ScrollableHighlights.importable.tsx

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css } from '@emotion/react';
2-
import { from, space, until } from '@guardian/source/foundations';
2+
import { from, space } from '@guardian/source/foundations';
33
import {
44
Button,
55
Hide,
@@ -19,16 +19,24 @@ type Props = {
1919
};
2020

2121
const containerStyles = css`
22+
padding: ${space[2]}px 0 ${space[3]}px;
2223
${from.tablet} {
23-
padding: 0 ${space[5]}px;
24+
padding: ${space[2]}px ${space[5]}px;
2425
}
2526
${from.wide} {
2627
padding-right: 100px;
2728
}
2829
`;
2930

31+
const cardGap = 10;
32+
const horizontalPaddingMobile = 10;
33+
const horizontalPaddingMobileLandscape = 20;
34+
3035
const carouselStyles = css`
3136
display: grid;
37+
gap: ${cardGap}px;
38+
padding: 0 ${horizontalPaddingMobile}px;
39+
scroll-padding-left: ${horizontalPaddingMobile}px;
3240
grid-auto-columns: 1fr;
3341
grid-auto-flow: column;
3442
overflow-x: auto;
@@ -37,11 +45,15 @@ const carouselStyles = css`
3745
scroll-behavior: smooth;
3846
overscroll-behavior-x: contain;
3947
overscroll-behavior-y: auto;
40-
${until.tablet} {
41-
scroll-padding-left: 10px;
48+
49+
${from.mobileLandscape} {
50+
padding: 0 ${horizontalPaddingMobileLandscape}px;
51+
scroll-padding-left: ${horizontalPaddingMobileLandscape}px;
4252
}
4353
${from.tablet} {
54+
padding: 0;
4455
scroll-padding-left: 120px;
56+
gap: ${space[5]}px;
4557
}
4658
${from.desktop} {
4759
scroll-padding-left: 240px;
@@ -70,29 +82,20 @@ const itemStyles = css`
7082
scroll-snap-align: start;
7183
grid-area: span 1;
7284
position: relative;
73-
margin: ${space[2]}px 10px ${space[3]}px;
74-
:first-child {
75-
${from.tablet} {
76-
margin-left: 0;
77-
}
78-
}
79-
:last-child {
80-
${from.tablet} {
81-
margin-right: 0;
82-
}
83-
}
8485
`;
8586

8687
const verticalLineStyles = css`
87-
:not(:last-child)::after {
88-
content: '';
89-
position: absolute;
90-
top: 0;
91-
bottom: 0;
92-
right: -10px;
93-
width: 1px;
94-
background-color: ${palette('--highlights-container-separator')};
95-
transform: translateX(-50%);
88+
${from.tablet} {
89+
:not(:first-child)::before {
90+
content: '';
91+
position: absolute;
92+
top: 0;
93+
bottom: 0;
94+
left: -10px;
95+
width: 1px;
96+
background-color: ${palette('--highlights-container-separator')};
97+
transform: translateX(-50%);
98+
}
9699
}
97100
`;
98101

@@ -138,20 +141,50 @@ const nextButtonFadeStyles = css`
138141
* @returns {string} - The CSS styles for the grid layout.
139142
*/
140143
const generateCarouselColumnStyles = (totalCards: number) => {
141-
const peepingCardWidth = space[8];
144+
const peepingCardWidthMobile = 150; // Screens below 375px. Only one card is fully visible;
145+
const peepingCardWidthMobileMedium = space[8];
142146

143147
return css`
144-
${until.mobileMedium} {
145-
grid-template-columns: repeat(${totalCards}, 70%) max(30%);
146-
}
147-
148+
grid-template-columns: repeat(
149+
${totalCards},
150+
max(
151+
180px,
152+
calc(
153+
100vw -
154+
(
155+
${horizontalPaddingMobile +
156+
cardGap +
157+
peepingCardWidthMobile}px
158+
)
159+
)
160+
)
161+
);
148162
${from.mobileMedium} {
149163
grid-template-columns: repeat(
150164
${totalCards},
151-
calc((100% - ${peepingCardWidth}px) / 2)
165+
calc(
166+
(
167+
100vw -
168+
${horizontalPaddingMobile +
169+
2 * cardGap +
170+
peepingCardWidthMobileMedium}px
171+
) / 2
172+
)
173+
);
174+
}
175+
${from.mobileLandscape} {
176+
grid-template-columns: repeat(
177+
${totalCards},
178+
calc(
179+
(
180+
100vw -
181+
${horizontalPaddingMobileLandscape +
182+
2 * cardGap +
183+
peepingCardWidthMobileMedium}px
184+
) / 2
185+
)
152186
);
153187
}
154-
155188
${from.tablet} {
156189
grid-template-columns: repeat(${totalCards}, 1fr);
157190
}

0 commit comments

Comments
 (0)