Skip to content

Commit a31ba5f

Browse files
authored
chore(placement): add hpTop (#12228)
1 parent caf02a9 commit a31ba5f

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

Diff for: client/src/placement-context.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ export enum Status {
1414
empty = "empty",
1515
}
1616

17-
type PlacementType = "side" | "top" | "hpMain" | "hpFooter" | "bottom";
17+
type PlacementType =
18+
| "side"
19+
| "top"
20+
| "hpTop"
21+
| "hpMain"
22+
| "hpFooter"
23+
| "bottom";
1824
export interface PlacementContextData
1925
extends Partial<Record<PlacementType, PlacementData>> {
2026
plusAvailable?: boolean;
@@ -31,6 +37,10 @@ const PLACEMENT_MAP: Record<PlacementType, { typ: string; pattern: RegExp }> = {
3137
typ: "top-banner",
3238
pattern: /\/[^/]+\/(?!$|_homepage$).*/i,
3339
},
40+
hpTop: {
41+
typ: "top-banner",
42+
pattern: /\/[^/]+\/($|_homepage$)/i,
43+
},
3444
hpMain: {
3545
typ: "hp-main",
3646
pattern: /\/[^/]+\/($|_homepage$)/i,

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ function TopPlacementFallbackContent() {
127127
export function TopPlacement() {
128128
const isServer = useIsServer();
129129
const placementData = usePlacement();
130+
const data = placementData?.hpTop || placementData?.top;
130131
const {
131132
textColor,
132133
backgroundColor,
@@ -136,7 +137,7 @@ export function TopPlacement() {
136137
backgroundColorDark,
137138
ctaTextColorDark,
138139
ctaBackgroundColorDark,
139-
} = placementData?.top?.colors || {};
140+
} = data?.colors || {};
140141
const css = Object.fromEntries(
141142
[
142143
["--place-top-background-light", backgroundColor],
@@ -156,23 +157,23 @@ export function TopPlacement() {
156157
const status =
157158
isServer || placementData?.status === Status.loading
158159
? "loading"
159-
: placementData?.top
160+
: data
160161
? "visible"
161162
: "fallback";
162163

163164
return (
164165
<div className={`top-banner ${status}`} style={css}>
165-
{isServer || !placementData?.top ? (
166+
{isServer || !data ? (
166167
<section className="place top container">
167168
{!isServer && placementData?.status !== Status.loading && (
168169
<TopPlacementFallbackContent />
169170
)}
170171
</section>
171172
) : (
172173
<PlacementInner
173-
pong={placementData.top}
174+
pong={data}
174175
extraClassNames={["top", "container"]}
175-
cta={placementData.top?.cta}
176+
cta={data?.cta}
176177
imageHeight={50}
177178
renderer={RenderSideOrTopBanner}
178179
typ="top-banner"

0 commit comments

Comments
 (0)