Skip to content

Commit 95f9c26

Browse files
authored
feat(pong): new design experiment (#11367)
* feat(pong): new design
1 parent dee547c commit 95f9c26

File tree

7 files changed

+260
-13
lines changed

7 files changed

+260
-13
lines changed

Diff for: client/src/app.scss

+10-10
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,17 @@ pre {
208208

209209
a {
210210
color: var(--text-link);
211+
}
211212

212-
&.external:after {
213-
background-color: var(--icon-primary);
214-
content: "";
215-
display: inline-flex;
216-
height: 10px;
217-
margin-left: 4px;
218-
mask-image: url("./assets/icons/external.svg");
219-
mask-size: cover;
220-
width: 10px;
221-
}
213+
.external:after {
214+
background-color: var(--icon-primary);
215+
content: "";
216+
display: inline-flex;
217+
height: 10px;
218+
margin-left: 4px;
219+
mask-image: url("./assets/icons/external.svg");
220+
mask-size: cover;
221+
width: 10px;
222222
}
223223

224224
button.button[disabled],

Diff for: client/src/blog/post.scss

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
grid-area: place;
6868
margin-top: 0;
6969

70+
> .pong-box2,
7071
> .pong-box {
7172
margin-top: 2rem;
7273
}

Diff for: client/src/playground/index.scss

+44
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ main.play {
219219
max-width: 20rem;
220220
min-height: 10rem;
221221

222+
.pong-box2,
222223
.pong-box {
223224
width: 100%;
224225

@@ -230,6 +231,49 @@ main.play {
230231
margin-top: 0;
231232
}
232233
}
234+
235+
&.new-side {
236+
height: 12rem;
237+
max-width: 30rem;
238+
min-height: 12rem;
239+
240+
.pong-box2 {
241+
height: 21rem;
242+
min-height: 0;
243+
width: 25rem;
244+
245+
> div {
246+
.pong-cta {
247+
margin: 0.5rem auto 1rem 1rem;
248+
}
249+
250+
.pong-note {
251+
margin: 0.5rem 0.5rem auto auto;
252+
}
253+
254+
.pong {
255+
> img {
256+
height: 100%;
257+
width: auto;
258+
}
259+
260+
> div.content {
261+
align-items: end;
262+
background: linear-gradient(
263+
to left,
264+
#111 16rem,
265+
transparent
266+
);
267+
flex-direction: column;
268+
height: 100%;
269+
justify-content: end;
270+
padding-left: 8rem;
271+
width: 100%;
272+
}
273+
}
274+
}
275+
}
276+
}
233277
}
234278
}
235279

Diff for: client/src/ui/organisms/placement/index.scss

+100
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,102 @@ section.place {
1010
text-decoration: none;
1111
}
1212

13+
.pong-box2 {
14+
--border-radius: 0.5rem;
15+
border: 1px solid var(--border-primary);
16+
border-radius: var(--border-radius);
17+
margin: 0;
18+
min-height: 20rem;
19+
overflow: hidden;
20+
position: relative;
21+
width: 11rem;
22+
23+
> div {
24+
height: 100%;
25+
width: 100%;
26+
27+
.pong-note {
28+
background-color: #fff6;
29+
border-radius: 0.25rem;
30+
color: #fff;
31+
font-size: 0.625rem;
32+
margin: 0.5rem;
33+
padding: 0 0.25rem;
34+
position: absolute;
35+
right: 0;
36+
text-decoration: none;
37+
text-decoration: underline;
38+
text-transform: uppercase;
39+
top: 0;
40+
width: max-content;
41+
42+
&:hover {
43+
background-color: #fff;
44+
color: #111;
45+
}
46+
}
47+
48+
.pong {
49+
height: 100%;
50+
width: 100%;
51+
52+
> img {
53+
height: auto;
54+
width: 100%;
55+
}
56+
57+
> div.content {
58+
background: linear-gradient(to top, #111 9rem, transparent);
59+
border-radius: var(--border-radius);
60+
color: #fff;
61+
display: flex;
62+
flex-direction: column;
63+
gap: 0.25rem;
64+
height: 100%;
65+
justify-content: end;
66+
position: absolute;
67+
top: 0;
68+
width: 100%;
69+
70+
strong {
71+
font-size: 0.8875rem;
72+
line-height: 1.25;
73+
padding: 0 1rem;
74+
}
75+
76+
span {
77+
font-size: 0.75rem;
78+
line-height: 1.25;
79+
padding: 0 1rem;
80+
}
81+
82+
.pong-cta {
83+
--color: #fff;
84+
--icon-primary: var(--color);
85+
background-color: #fff1;
86+
border: solid 2px;
87+
border-radius: 2rem;
88+
color: var(--color);
89+
font-size: 0.75rem;
90+
font-weight: 600;
91+
margin: 0.5rem auto 1rem 1rem;
92+
padding: 0.5em 1em;
93+
transition: all 0.3s ease-in-out;
94+
95+
&::after {
96+
transition: all 0.3s ease-in-out;
97+
}
98+
99+
&:hover {
100+
--color: #111;
101+
background-color: #fff;
102+
}
103+
}
104+
}
105+
}
106+
}
107+
}
108+
13109
.pong-box {
14110
background-color: var(--background-secondary);
15111
border: 1px solid var(--border-primary);
@@ -82,6 +178,10 @@ section.place {
82178
min-height: 20rem;
83179
}
84180

181+
&.new-side {
182+
min-height: 22rem;
183+
}
184+
85185
&.top {
86186
align-items: center;
87187
display: grid;

Diff for: client/src/ui/organisms/placement/index.tsx

+88-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interface PlacementRenderArgs {
3030
style: object;
3131
version?: number;
3232
typ: string;
33+
heading?: string;
3334
}
3435

3536
const INTERSECTION_OPTIONS = {
@@ -52,6 +53,16 @@ export function SidePlacement() {
5253

5354
return !placementData?.side ? (
5455
<section className="place side"></section>
56+
) : placementData.side.cta ? (
57+
<PlacementInner
58+
pong={placementData.side}
59+
extraClassNames={["side", "new-side"]}
60+
imageWidth={125}
61+
imageHeight={125}
62+
cta={placementData.side.cta}
63+
renderer={RenderNewSideBanner}
64+
typ="side"
65+
></PlacementInner>
5566
) : (
5667
<PlacementInner
5768
pong={placementData.side}
@@ -274,7 +285,7 @@ export function PlacementInner({
274285
};
275286
}, [isVisible, isIntersecting, sendViewed]);
276287

277-
const { image, copy, alt, click, version } = pong || {};
288+
const { image, copy, alt, click, version, heading } = pong || {};
278289
return (
279290
<>
280291
{!isServer &&
@@ -293,6 +304,7 @@ export function PlacementInner({
293304
style,
294305
version,
295306
typ,
307+
heading,
296308
})}
297309
</>
298310
);
@@ -480,3 +492,78 @@ function RenderBottomBanner({
480492
</div>
481493
);
482494
}
495+
496+
function RenderNewSideBanner({
497+
place,
498+
extraClassNames = [],
499+
click,
500+
image,
501+
alt,
502+
imageWidth,
503+
imageHeight,
504+
copy,
505+
cta,
506+
user,
507+
style,
508+
version = 1,
509+
typ,
510+
heading,
511+
}: PlacementRenderArgs) {
512+
return (
513+
<section
514+
ref={place}
515+
className={["place", ...extraClassNames].join(" ")}
516+
style={style}
517+
>
518+
<p className="pong-box2">
519+
<div>
520+
<a
521+
className="pong"
522+
data-glean={`pong: pong->click ${typ}`}
523+
href={`/pong/click?code=${encodeURIComponent(
524+
click
525+
)}&version=${version}`}
526+
target="_blank"
527+
rel="sponsored noreferrer"
528+
>
529+
<img
530+
src={`/pimg/${encodeURIComponent(image || "")}`}
531+
aria-hidden={!Boolean(alt)}
532+
alt={alt || ""}
533+
width={imageWidth}
534+
height={imageHeight}
535+
></img>
536+
<div className="content">
537+
<strong>{heading}</strong>
538+
<span>{copy}</span>
539+
{cta && <span className="pong-cta external">{cta}</span>}
540+
</div>
541+
</a>
542+
<a
543+
href="/en-US/advertising"
544+
className="pong-note"
545+
data-glean="pong: pong->about"
546+
target="_blank"
547+
rel="noreferrer"
548+
>
549+
Ad
550+
</a>
551+
</div>
552+
</p>
553+
554+
<a
555+
className="no-pong"
556+
data-glean={
557+
"pong: " + (user?.isSubscriber ? "pong->settings" : "pong->plus")
558+
}
559+
href={
560+
user?.isSubscriber
561+
? "/en-US/plus/settings?ref=nope"
562+
: "/en-US/plus?ref=nope#subscribe"
563+
}
564+
>
565+
Don't want to see ads?
566+
</a>
567+
</section>
568+
);
569+
}

Diff for: libs/pong/pong2.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ export function createPong2GetHandler(zoneKeys, coder) {
2121
)}${userAgent ? `&useragent=${encodeURIComponent(userAgent)}` : ""}`
2222
)
2323
).json();
24+
2425
const {
2526
ads: [
2627
{
2728
statlink = null,
2829
statimp,
2930
Description,
3031
Image,
32+
LargeImage,
3133
ImageTitle,
3234
BackgroundColor,
3335
BackgroundColorLight,
@@ -40,6 +42,7 @@ export function createPong2GetHandler(zoneKeys, coder) {
4042
TextColor,
4143
TextColorLight,
4244
TextColorDark,
45+
Heading,
4346
},
4447
] = [],
4548
} = res;
@@ -51,10 +54,11 @@ export function createPong2GetHandler(zoneKeys, coder) {
5154
: {
5255
click: coder.encodeAndSign(statlink),
5356
view: coder.encodeAndSign(statimp),
54-
image: coder.encodeAndSign(Image),
57+
image: coder.encodeAndSign(LargeImage || Image),
5558
alt: ImageTitle && he.decode(ImageTitle),
5659
copy: Description && he.decode(Description),
5760
cta: CallToAction && he.decode(CallToAction),
61+
heading: Heading && he.decode(Heading),
5862
colors: {
5963
textColor: TextColor || TextColorLight,
6064
backgroundColor: BackgroundColor || BackgroundColorLight,
@@ -91,7 +95,16 @@ export function createPong2GetHandler(zoneKeys, coder) {
9195
if (v === null) {
9296
return null;
9397
}
94-
const { copy, image, alt, click, view, cta, colors = {} } = v;
98+
const {
99+
copy,
100+
image,
101+
alt,
102+
click,
103+
view,
104+
cta,
105+
colors,
106+
heading = {},
107+
} = v;
95108
return [
96109
p,
97110
{
@@ -103,6 +116,7 @@ export function createPong2GetHandler(zoneKeys, coder) {
103116
colors,
104117
click,
105118
view,
119+
heading,
106120
version: 2,
107121
},
108122
];

Diff for: libs/pong/types.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ export type Payload = {
1919
cta?: string;
2020
colors?: Colors;
2121
version: number;
22+
heading?: string;
2223
};

0 commit comments

Comments
 (0)