Skip to content

Commit cb6d415

Browse files
committed
Bug 1965944 - Visual updates for medium card UI. r=home-newtab-reviewers,nbarrett,npypchenko
Differential Revision: https://phabricator.services.mozilla.com/D249215 UltraBlame original commit: e38f01b20ab30a31a910a4a7e543f03707f0e017
1 parent 383dce3 commit cb6d415

File tree

9 files changed

+241
-30
lines changed

9 files changed

+241
-30
lines changed

browser/extensions/newtab/content-src/components/DiscoveryStreamComponents/CardGrid/CardGrid.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const PREF_BILLBOARD_ENABLED = "newtabAdSize.billboard";
3131
const PREF_LEADERBOARD_ENABLED = "newtabAdSize.leaderboard";
3232
const PREF_LEADERBOARD_POSITION = "newtabAdSize.leaderboard.position";
3333
const PREF_BILLBOARD_POSITION = "newtabAdSize.billboard.position";
34+
const PREF_REFINED_CARDS_ENABLED = "discoverystream.refinedCardsLayout.enabled";
3435
const INTERSECTION_RATIO = 0.5;
3536
const VISIBLE = "visible";
3637
const VISIBILITY_CHANGE_EVENT = "visibilitychange";
@@ -361,6 +362,8 @@ export class _CardGrid extends React.PureComponent {
361362
const listFeedSelectedFeed = prefs[PREF_LIST_FEED_SELECTED_FEED];
362363
const billboardEnabled = prefs[PREF_BILLBOARD_ENABLED];
363364
const leaderboardEnabled = prefs[PREF_LEADERBOARD_ENABLED];
365+
const refinedCardsLayout = prefs[PREF_REFINED_CARDS_ENABLED];
366+
364367
// filter out recs that should be in ListFeed
365368
const recs = this.props.data.recommendations
366369
.filter(item => !item.feedName)
@@ -395,8 +398,8 @@ export class _CardGrid extends React.PureComponent {
395398
features={rec.features}
396399
showTopics={showTopics}
397400
selectedTopics={selectedTopics}
401+
excerpt={refinedCardsLayout && rec.excerpt}
398402
availableTopics={availableTopics}
399-
excerpt={rec.excerpt}
400403
url={rec.url}
401404
id={rec.id}
402405
shim={rec.shim}

browser/extensions/newtab/content-src/components/DiscoveryStreamComponents/CardGrid/_CardGrid.scss

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@
77
border-radius: var(--border-radius-medium);
88
box-shadow: $shadow-card;
99

10-
.img-wrapper .img {
11-
img,
12-
.placeholder-image {
13-
border-radius: var(--border-radius-medium) var(--border-radius-medium) 0 0;
14-
}
10+
img,
11+
.placeholder-image {
12+
border-radius: var(--border-radius-medium) var(--border-radius-medium) 0 0;
1513
}
1614
}
1715
}
1816

17+
.ds-card.refined-cards:not(.placeholder) {
18+
.img-wrapper .img {
19+
height: 172px;
20+
width: 100%;
21+
}
22+
}
23+
1924
.ds-onboarding-container {
2025
padding-inline-start: 16px;
2126
padding-inline-end: 16px;
@@ -121,14 +126,17 @@
121126
display: grid;
122127
grid-gap: 24px;
123128
position: relative;
124-
// Bug 1926056: Row/column Gap spacing to allow for IAB fixed ad sizes
125-
row-gap: 24px;
126-
column-gap: 18px;
127129

128130
&.ds-card-grid-compact {
129131
grid-gap: 20px;
130132
}
131133

134+
&.ad-sizing-variant-a,
135+
&.ad-sizing-variant-b {
136+
row-gap: 24px;
137+
column-gap: 18px;
138+
}
139+
132140
&.ds-card-grid-recent-saves {
133141
.ds-card {
134142
// Hide the second row orphan on narrow screens.

browser/extensions/newtab/content-src/components/DiscoveryStreamComponents/CardSections/CardSections.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ const PREF_BILLBOARD_ENABLED = "newtabAdSize.billboard";
3232
const PREF_LEADERBOARD_ENABLED = "newtabAdSize.leaderboard";
3333
const PREF_LEADERBOARD_POSITION = "newtabAdSize.leaderboard.position";
3434
const PREF_BILLBOARD_POSITION = "newtabAdSize.billboard.position";
35+
const PREF_REFINED_CARDS_ENABLED = "discoverystream.refinedCardsLayout.enabled";
3536

36-
function getLayoutData(responsiveLayouts, index) {
37+
function getLayoutData(responsiveLayouts, index, refinedCardsLayout) {
3738
let layoutData = {
3839
classNames: [],
3940
imageSizes: {},
@@ -51,7 +52,15 @@ function getLayoutData(responsiveLayouts, index) {
5152
// The API tells us whether the tile should show the excerpt or not.
5253
// Apply extra styles accordingly.
5354
if (tile.hasExcerpt) {
54-
layoutData.classNames.push(`col-${layout.columnCount}-show-excerpt`);
55+
if (tile.size === "medium" && refinedCardsLayout) {
56+
layoutData.classNames.push(
57+
`col-${layout.columnCount}-hide-excerpt`
58+
);
59+
} else {
60+
layoutData.classNames.push(
61+
`col-${layout.columnCount}-show-excerpt`
62+
);
63+
}
5564
} else {
5665
layoutData.classNames.push(`col-${layout.columnCount}-hide-excerpt`);
5766
}
@@ -114,6 +123,7 @@ function CardSection({
114123
const mayHaveThumbsUpDown = prefs[PREF_THUMBS_UP_DOWN_ENABLED];
115124
const selectedTopics = prefs[PREF_TOPICS_SELECTED];
116125
const availableTopics = prefs[PREF_TOPICS_AVAILABLE];
126+
const refinedCardsLayout = prefs[PREF_REFINED_CARDS_ENABLED];
117127

118128
const { saveToPocketCard } = useSelector(state => state.DiscoveryStream);
119129
const mayHaveSectionsPersonalization =
@@ -260,7 +270,8 @@ function CardSection({
260270
{section.data.slice(0, maxTile).map((rec, index) => {
261271
const { classNames, imageSizes } = getLayoutData(
262272
responsiveLayouts,
263-
index
273+
index,
274+
refinedCardsLayout
264275
);
265276

266277
if (!rec || rec.placeholder) {

browser/extensions/newtab/content-src/components/DiscoveryStreamComponents/CardSections/_CardSections.scss

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
grid-column: span 1;
66
padding: var(--space-large);
77

8+
&.refined-cards.ds-card.sections-card-ui {
9+
height: fit-content;
10+
}
11+
12+
&.refined-cards {
13+
.ds-card-link {
14+
padding: var(--space-xsmall) var(--space-small);
15+
flex-grow: 0;
16+
}
17+
18+
.img-wrapper {
19+
width: 110px;
20+
height: 117px;
21+
}
22+
}
823

924
&.ds-card.sections-card-ui {
1025
padding: unset;
@@ -21,7 +36,6 @@
2136
align-items: center;
2237
gap: var(--space-medium);
2338
padding: var(--space-large);
24-
2539
}
2640

2741
.img-wrapper {
@@ -77,7 +91,6 @@
7791
}
7892
}
7993

80-
8194
@mixin section-card-medium {
8295
grid-row: span 2;
8396
grid-column: span 1;
@@ -86,6 +99,23 @@
8699
align-items: initial;
87100
gap: initial;
88101

102+
&.refined-cards.ds-card.sections-card-ui {
103+
height: unset;
104+
}
105+
106+
// .refined-medium-card only appears if refinedCardsLayout.enabled pref is set to true
107+
&.refined-cards {
108+
.ds-card-link {
109+
padding: unset;
110+
flex-grow: unset;
111+
}
112+
113+
.img-wrapper {
114+
width: 100%;
115+
height: 172px;
116+
}
117+
}
118+
89119
.card-stp-button-position-wrapper {
90120
inset-inline-end: 10px;
91121
}
@@ -120,6 +150,8 @@
120150
padding: var(--space-medium) var(--space-large);
121151

122152
.info-wrap {
153+
flex-grow: initial;
154+
123155
.title {
124156
-webkit-line-clamp: 3;
125157
margin-block: 0 var(--space-small);
@@ -131,6 +163,10 @@
131163
-webkit-line-clamp: 3;
132164
}
133165
}
166+
167+
.sections-card-footer {
168+
margin-top: auto;
169+
}
134170
}
135171
}
136172

@@ -153,11 +189,14 @@
153189

154190
.img-wrapper {
155191
width: 265px;
192+
height: 100%;
156193
}
157194

158195
.ds-image.img {
159196
// Square ratio
160197
aspect-ratio: 1/1;
198+
width: 100%;
199+
height: 100%;
161200

162201
img {
163202
border-radius: var(--border-radius-medium);

browser/extensions/newtab/content-src/components/DiscoveryStreamComponents/DSCard/DSCard.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ export class _DSCard extends React.PureComponent {
208208
this.onMenuShow = this.onMenuShow.bind(this);
209209
this.onThumbsUpClick = this.onThumbsUpClick.bind(this);
210210
this.onThumbsDownClick = this.onThumbsDownClick.bind(this);
211+
const refinedCardsLayout =
212+
this.props.Prefs.values["discoverystream.refinedCardsLayout.enabled"];
211213

212214
this.setContextMenuButtonHostRef = element => {
213215
this.contextMenuButtonHostElement = element;
@@ -284,7 +286,7 @@ export class _DSCard extends React.PureComponent {
284286
},
285287
medium: {
286288
width: 300,
287-
height: 150,
289+
height: refinedCardsLayout ? 172 : 150,
288290
},
289291
large: {
290292
width: 265,

browser/extensions/newtab/content-src/components/DiscoveryStreamComponents/DSCard/_DSCard.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,17 @@ $ds-card-image-gradient-solid: rgba(0, 0, 0, 100%);
8787
position: relative;
8888
}
8989

90+
&.refined-cards {
91+
.card-stp-button-hover-background {
92+
height: 172px;
93+
}
94+
}
95+
9096
.card-stp-button-hover-background {
9197
opacity: 0;
9298
width: 100%;
9399
position: absolute;
94100
top: 0;
95-
height: 0;
96101
transition: opacity;
97102
transition-duration: 0s;
98103
padding-block-start: 50%;

0 commit comments

Comments
 (0)