-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(pong): bottom banner #9883
Changes from all commits
d3b00a9
76144bf
8d6836e
d356e3b
62a1513
544d8bf
c7eae51
a572bbe
4056c57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ interface PlacementRenderArgs { | |
user: User; | ||
style: object; | ||
version?: number; | ||
typ: string; | ||
} | ||
|
||
const INTERSECTION_OPTIONS = { | ||
|
@@ -148,6 +149,7 @@ export function HpMainPlacement() { | |
placementData: placementData?.hpMain, | ||
imageWidth: 970, | ||
imageHeight: 250, | ||
typ: "hp-main", | ||
}); | ||
} | ||
|
||
|
@@ -157,17 +159,20 @@ export function HpFooterPlacement() { | |
placementData: placementData?.hpFooter, | ||
imageWidth: 728, | ||
imageHeight: 90, | ||
typ: "hp-footer", | ||
}); | ||
} | ||
|
||
function HpPlacement({ | ||
placementData, | ||
imageWidth, | ||
imageHeight, | ||
typ, | ||
}: { | ||
placementData?: PlacementData; | ||
imageWidth: number; | ||
imageHeight: number; | ||
typ: string; | ||
}) { | ||
const { backgroundColor } = placementData?.colors || {}; | ||
const css = Object.fromEntries( | ||
|
@@ -185,19 +190,30 @@ function HpPlacement({ | |
imageHeight={imageHeight} | ||
style={css} | ||
renderer={RenderHpPlacement} | ||
typ="hp-main" | ||
typ={typ} | ||
></PlacementInner> | ||
); | ||
} | ||
|
||
export function BottomBanner() { | ||
return ( | ||
const placementData = usePlacement()?.bottom; | ||
const { backgroundColor, textColor } = placementData?.colors || {}; | ||
const css = Object.fromEntries( | ||
[ | ||
["--place-bottom-banner-background", backgroundColor], | ||
["--place-bottom-banner-color", textColor], | ||
].filter(([_, v]) => Boolean(v)) | ||
); | ||
return placementData ? ( | ||
<PlacementInner | ||
pong={{ status: Status.empty }} | ||
pong={placementData} | ||
imageWidth={728} | ||
imageHeight={90} | ||
style={css} | ||
renderer={RenderBottomBanner} | ||
typ="bottom-banner" | ||
/> | ||
); | ||
></PlacementInner> | ||
) : null; | ||
} | ||
|
||
export function PlacementInner({ | ||
|
@@ -278,6 +294,7 @@ export function PlacementInner({ | |
user, | ||
style, | ||
version, | ||
typ, | ||
})} | ||
</> | ||
); | ||
|
@@ -295,6 +312,7 @@ function RenderSideOrTopBanner({ | |
user, | ||
style, | ||
version = 1, | ||
typ, | ||
}: PlacementRenderArgs) { | ||
return ( | ||
<section | ||
|
@@ -305,7 +323,7 @@ function RenderSideOrTopBanner({ | |
<p className="pong-box"> | ||
<a | ||
className="pong" | ||
data-glean="pong: pong->click" | ||
data-glean={`pong: pong->click ${typ}`} | ||
href={`/pong/click?code=${encodeURIComponent( | ||
click | ||
)}&version=${version}`} | ||
|
@@ -324,8 +342,10 @@ function RenderSideOrTopBanner({ | |
{cta && ( | ||
<a | ||
className="pong-cta" | ||
data-glean="pong: pong->click" | ||
href={`/pong/click?code=${encodeURIComponent(click)}`} | ||
data-glean={`pong: pong->click ${typ}`} | ||
href={`/pong/click?code=${encodeURIComponent( | ||
click | ||
)}&version=${version}`} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
|
@@ -369,6 +389,8 @@ function RenderHpPlacement({ | |
imageHeight, | ||
copy, | ||
style, | ||
version = 1, | ||
typ, | ||
}: PlacementRenderArgs) { | ||
return ( | ||
<section | ||
|
@@ -378,8 +400,10 @@ function RenderHpPlacement({ | |
> | ||
<a | ||
className="pong" | ||
data-glean="pong: pong->click" | ||
href={`/pong/click?code=${encodeURIComponent(click)}`} | ||
data-glean={`pong: pong->click ${typ}`} | ||
href={`/pong/click?code=${encodeURIComponent( | ||
click | ||
)}&version=${version}`} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
|
@@ -394,6 +418,64 @@ function RenderHpPlacement({ | |
); | ||
} | ||
|
||
function RenderBottomBanner({ place }: PlacementRenderArgs) { | ||
return <div ref={place} className="empty-place bottom-banner"></div>; | ||
function RenderBottomBanner({ | ||
place, | ||
extraClassNames = [], | ||
click, | ||
image, | ||
imageWidth, | ||
imageHeight, | ||
copy, | ||
user, | ||
style, | ||
version = 1, | ||
typ, | ||
}: PlacementRenderArgs) { | ||
return ( | ||
<div className="bottom-banner-container" style={style}> | ||
<section | ||
ref={place} | ||
className={["place", "bottom-banner", ...extraClassNames].join(" ")} | ||
> | ||
<a | ||
className="pong" | ||
data-glean={`pong: pong->click ${typ}`} | ||
href={`/pong/click?code=${encodeURIComponent( | ||
click | ||
)}&version=${version}`} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
<img | ||
src={`/pimg/${encodeURIComponent(image || "")}`} | ||
alt={copy} | ||
width={imageWidth} | ||
height={imageHeight} | ||
></img> | ||
</a> | ||
<a | ||
href="/en-US/advertising" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Why |
||
className="pong-note" | ||
data-glean="pong: pong->about" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Mozilla ads | ||
</a> | ||
<a | ||
className="no-pong" | ||
data-glean={ | ||
"pong: " + (user?.isSubscriber ? "pong->settings" : "pong->plus") | ||
} | ||
href={ | ||
user?.isSubscriber | ||
? "/en-US/plus/settings?ref=nope" | ||
: "/en-US/plus?ref=nope#subscribe" | ||
} | ||
> | ||
Don't want to see ads? | ||
</a> | ||
Comment on lines
+440
to
+477
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think we could DRY up all this across all the renderers? But ok for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. |
||
</section> | ||
</div> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Should these constants live somewhere else?