fix(BOOK-506): Hiding campaign banner on more hotel-reservation routes and make whole banner clickable
Approved-by: Bianca Widstam
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
"use client"
|
||||
|
||||
import NextLink from "next/link"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
import { trackClick } from "@scandic-hotels/tracking/base"
|
||||
|
||||
import { MarqueeText } from "@/components/MarqueeText"
|
||||
|
||||
@@ -22,7 +20,7 @@ export function DesktopCampaignBanner({
|
||||
const intl = useIntl()
|
||||
|
||||
return (
|
||||
<div className={styles.innerContent}>
|
||||
<>
|
||||
<Typography variant="Tag/sm">
|
||||
<span className={styles.tag}>{tag}</span>
|
||||
</Typography>
|
||||
@@ -53,22 +51,16 @@ export function DesktopCampaignBanner({
|
||||
|
||||
{link ? (
|
||||
<Typography variant="Link/sm">
|
||||
<NextLink
|
||||
href={link.url}
|
||||
className={styles.link}
|
||||
onClick={() => trackClick("BW read more")}
|
||||
>
|
||||
<span>
|
||||
{link.title ||
|
||||
intl.formatMessage({
|
||||
id: "common.readMore",
|
||||
defaultMessage: "Read more",
|
||||
})}
|
||||
</span>
|
||||
</NextLink>
|
||||
<span className={styles.fakeLink}>
|
||||
{link.title ||
|
||||
intl.formatMessage({
|
||||
id: "common.readMore",
|
||||
defaultMessage: "Read more",
|
||||
})}
|
||||
</span>
|
||||
</Typography>
|
||||
) : null}
|
||||
</MarqueeText>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
"use client"
|
||||
|
||||
import { cx } from "class-variance-authority"
|
||||
import NextLink from "next/link"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
import { trackClick } from "@scandic-hotels/tracking/base"
|
||||
|
||||
import { MarqueeText } from "@/components/MarqueeText"
|
||||
|
||||
@@ -22,91 +20,63 @@ export function MobileCampaignBanner({
|
||||
}: CampaignBannerProps) {
|
||||
const intl = useIntl()
|
||||
|
||||
return (
|
||||
<InnerContent link={link} bookingCode={bookingCode}>
|
||||
{bookingCode ? (
|
||||
<p>
|
||||
<Typography variant="Title/Overline/sm">
|
||||
<span className={cx(styles.tag, styles.withBookingCode)}>
|
||||
{tag}
|
||||
</span>
|
||||
</Typography>
|
||||
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||
<span>
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
<> ∙ {text} </>
|
||||
<Typography variant="Body/Supporting text (caption)/smBold">
|
||||
<span className={styles.bookingCode}>
|
||||
{intl.formatMessage(
|
||||
{
|
||||
id: "campaignBanner.codeWithBookingCode",
|
||||
defaultMessage: "Code: {bookingCode}",
|
||||
},
|
||||
{ bookingCode }
|
||||
)}
|
||||
<MaterialIcon
|
||||
icon="arrow_forward"
|
||||
color="CurrentColor"
|
||||
size={16}
|
||||
/>
|
||||
</span>
|
||||
</Typography>
|
||||
</span>
|
||||
</Typography>
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<Typography variant="Tag/sm">
|
||||
<span className={styles.tag}>{tag}</span>
|
||||
</Typography>
|
||||
<MarqueeText
|
||||
backgroundColor="var(--Surface-Brand-Primary-3-Default)"
|
||||
className={styles.marquee}
|
||||
textWrapperClassName={styles.marqueeText}
|
||||
>
|
||||
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||
<span>{text}</span>
|
||||
if (bookingCode) {
|
||||
return (
|
||||
<p>
|
||||
<Typography variant="Title/Overline/sm">
|
||||
<span className={cx(styles.tag, styles.withBookingCode)}>{tag}</span>
|
||||
</Typography>
|
||||
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||
<span>
|
||||
{/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */}
|
||||
<> ∙ {text} </>
|
||||
<Typography variant="Body/Supporting text (caption)/smBold">
|
||||
<span className={styles.bookingCode}>
|
||||
{intl.formatMessage(
|
||||
{
|
||||
id: "campaignBanner.codeWithBookingCode",
|
||||
defaultMessage: "Code: {bookingCode}",
|
||||
},
|
||||
{ bookingCode }
|
||||
)}
|
||||
<MaterialIcon
|
||||
icon="arrow_forward"
|
||||
color="CurrentColor"
|
||||
size={16}
|
||||
/>
|
||||
</span>
|
||||
</Typography>
|
||||
{link ? (
|
||||
<Typography variant="Link/sm">
|
||||
<span>
|
||||
{link.title ||
|
||||
intl.formatMessage({
|
||||
id: "common.readMore",
|
||||
defaultMessage: "Read more",
|
||||
})}
|
||||
</span>
|
||||
</Typography>
|
||||
) : null}
|
||||
</MarqueeText>
|
||||
</>
|
||||
)}
|
||||
</InnerContent>
|
||||
)
|
||||
}
|
||||
</span>
|
||||
</Typography>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
function InnerContent({
|
||||
link,
|
||||
bookingCode,
|
||||
children,
|
||||
}: React.PropsWithChildren<Pick<CampaignBannerProps, "link" | "bookingCode">>) {
|
||||
return link ? (
|
||||
<NextLink
|
||||
href={link.url}
|
||||
className={cx(styles.innerContent, {
|
||||
[styles.withBookingCode]: !!bookingCode,
|
||||
})}
|
||||
onClick={() => trackClick("BW campaign banner")}
|
||||
>
|
||||
{children}
|
||||
</NextLink>
|
||||
) : (
|
||||
<div
|
||||
className={cx(styles.innerContent, {
|
||||
[styles.withBookingCode]: !!bookingCode,
|
||||
})}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
return (
|
||||
<>
|
||||
<Typography variant="Tag/sm">
|
||||
<span className={styles.tag}>{tag}</span>
|
||||
</Typography>
|
||||
<MarqueeText
|
||||
backgroundColor="var(--Surface-Brand-Primary-3-Default)"
|
||||
className={styles.marquee}
|
||||
textWrapperClassName={styles.marqueeText}
|
||||
>
|
||||
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||
<span>{text}</span>
|
||||
</Typography>
|
||||
{link ? (
|
||||
<Typography variant="Link/sm">
|
||||
<span className={styles.fakeLink}>
|
||||
{link.title ||
|
||||
intl.formatMessage({
|
||||
id: "common.readMore",
|
||||
defaultMessage: "Read more",
|
||||
})}
|
||||
</span>
|
||||
</Typography>
|
||||
) : null}
|
||||
</MarqueeText>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@
|
||||
text-decoration: none;
|
||||
color: var(--Text-Inverted);
|
||||
padding: var(--Space-x025) 0;
|
||||
|
||||
&:not(.withBookingCode) {
|
||||
gap: var(--Space-x15);
|
||||
}
|
||||
gap: var(--Space-x15);
|
||||
}
|
||||
|
||||
.text {
|
||||
@@ -61,10 +58,14 @@
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.link {
|
||||
.fakeLink {
|
||||
color: var(--Text-Inverted);
|
||||
}
|
||||
|
||||
.innerContent:hover .fakeLink {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.bookingCode {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -7,6 +7,9 @@ const SHARED_HIDE_ROUTES = [
|
||||
"/hotelreservation/details",
|
||||
"/hotelreservation/booking-confirmation",
|
||||
"/hotelreservation/my-stay",
|
||||
"/hotelreservation/gla-payment-callback",
|
||||
"/hotelreservation/payment-callback",
|
||||
"/hotelreservation/get-booking",
|
||||
]
|
||||
|
||||
export const CAMPAIGN_BANNER_HIDE_CONDITIONS = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import NextLink from "next/link"
|
||||
import { usePathname } from "next/navigation"
|
||||
import { useCallback, useEffect, useRef, useState } from "react"
|
||||
import { useIntl } from "react-intl"
|
||||
@@ -19,6 +20,8 @@ import { shouldShowCampaignBanner } from "./utils"
|
||||
|
||||
import styles from "./campaignBanner.module.css"
|
||||
|
||||
import type { CampaignBannerProps } from "@/components/CampaignBanner/types"
|
||||
|
||||
export default function CampaignBanner() {
|
||||
const lang = useLang()
|
||||
const intl = useIntl()
|
||||
@@ -97,21 +100,23 @@ export default function CampaignBanner() {
|
||||
}}
|
||||
>
|
||||
<div className={styles.content}>
|
||||
{isMobile ? (
|
||||
<MobileCampaignBanner
|
||||
tag={campaignBanner.tag}
|
||||
text={campaignBanner.text}
|
||||
link={isOnSamePage ? null : campaignBanner.link}
|
||||
bookingCode={campaignBanner.booking_code}
|
||||
/>
|
||||
) : (
|
||||
<DesktopCampaignBanner
|
||||
tag={campaignBanner.tag}
|
||||
text={campaignBanner.text}
|
||||
link={isOnSamePage ? null : campaignBanner.link}
|
||||
bookingCode={campaignBanner.booking_code}
|
||||
/>
|
||||
)}
|
||||
<InnerContent link={isOnSamePage ? null : campaignBanner.link}>
|
||||
{isMobile ? (
|
||||
<MobileCampaignBanner
|
||||
tag={campaignBanner.tag}
|
||||
text={campaignBanner.text}
|
||||
link={isOnSamePage ? null : campaignBanner.link}
|
||||
bookingCode={campaignBanner.booking_code}
|
||||
/>
|
||||
) : (
|
||||
<DesktopCampaignBanner
|
||||
tag={campaignBanner.tag}
|
||||
text={campaignBanner.text}
|
||||
link={isOnSamePage ? null : campaignBanner.link}
|
||||
bookingCode={campaignBanner.booking_code}
|
||||
/>
|
||||
)}
|
||||
</InnerContent>
|
||||
<IconButton
|
||||
className={styles.closeButton}
|
||||
theme="Inverted"
|
||||
@@ -128,3 +133,22 @@ export default function CampaignBanner() {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function InnerContent({
|
||||
link,
|
||||
children,
|
||||
}: React.PropsWithChildren<{
|
||||
link: CampaignBannerProps["link"]
|
||||
}>) {
|
||||
return link ? (
|
||||
<NextLink
|
||||
href={link.url}
|
||||
className={styles.innerContent}
|
||||
onClick={() => trackClick("BW campaign banner")}
|
||||
>
|
||||
{children}
|
||||
</NextLink>
|
||||
) : (
|
||||
<div className={styles.innerContent}>{children}</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export function shouldShowCampaignBanner(
|
||||
const fullRoute = removeTrailingSlash(
|
||||
removeMultipleSlashes(`/${lang}${route}`)
|
||||
)
|
||||
return cleanPathname === fullRoute
|
||||
return cleanPathname.startsWith(fullRoute)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user