-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4146 from mozilla/holiday-promo-code-banner
MPP-3588: 2023 Holiday promo banner
- Loading branch information
Showing
9 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
frontend/src/components/layout/images/holiday-promo-banner-pattern-desktop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions
9
frontend/src/components/layout/images/holiday-promo-banner-pattern-laptop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions
9
frontend/src/components/layout/images/holiday-promo-banner-pattern-mobile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions
9
frontend/src/components/layout/images/holiday-promo-banner-pattern-tablet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 104 additions & 0 deletions
104
frontend/src/components/layout/topmessage/HolidayPromoBanner.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
@import "../../../styles/tokens.scss"; | ||
@import "~@mozilla-protocol/core/protocol/css/includes/lib"; | ||
|
||
// Hardcoding #5015cd after talking with design, no token for this color exists yet in Nebula. | ||
$banner-gradient: linear-gradient( | ||
90.13deg, | ||
$color-purple-90 -2.39%, | ||
#5015cd 50.81%, | ||
$color-purple-50 104% | ||
); | ||
|
||
.wrapper { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: $spacing-md; | ||
color: $color-white; | ||
position: relative; | ||
background-image: url("../images/holiday-promo-banner-pattern-mobile.svg"), | ||
$banner-gradient; | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
flex-direction: column; | ||
gap: $spacing-md; | ||
|
||
@media screen and #{$mq-sm} { | ||
flex-direction: row; | ||
gap: $spacing-2xl; | ||
background-image: url("../images/holiday-promo-banner-pattern-tablet.svg"), | ||
$banner-gradient; | ||
} | ||
@media screen and #{$mq-md} { | ||
gap: $layout-xl; | ||
background-image: url("../images/holiday-promo-banner-pattern-laptop.svg"), | ||
$banner-gradient; | ||
} | ||
@media screen and #{$mq-xl} { | ||
background-image: url("../images/holiday-promo-banner-pattern-desktop.svg"), | ||
$banner-gradient; | ||
} | ||
|
||
.left-promo-container { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
gap: $spacing-md; | ||
|
||
@media screen and #{$mq-sm} { | ||
gap: 0; | ||
} | ||
@media screen and #{$mq-lg} { | ||
flex-direction: row; | ||
gap: $layout-xl; | ||
} | ||
} | ||
|
||
.promo-container { | ||
text-align: center; | ||
} | ||
|
||
.cta-button { | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
cursor: pointer; | ||
background-color: $color-white; | ||
padding: $spacing-sm $spacing-md; | ||
border-radius: $border-radius-sm; | ||
color: $color-purple-90; | ||
font-weight: 700; | ||
margin-bottom: $spacing-xs; | ||
|
||
&:hover { | ||
cursor: pointer; | ||
opacity: 0.9; | ||
} | ||
} | ||
|
||
.promo-code-expiry { | ||
color: rgba($color-white, 0.7); | ||
font-weight: 700; | ||
display: block; | ||
|
||
@include text-body-xs; | ||
} | ||
|
||
.banner-pattern { | ||
width: 100%; | ||
position: absolute; | ||
} | ||
|
||
.promo-text { | ||
@include text-body-lg; | ||
|
||
font-family: $font-stack-base; | ||
} | ||
|
||
.promo-text-bolded { | ||
@include text-body-xl; | ||
|
||
font-weight: 700; | ||
font-family: $font-stack-firefox; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
frontend/src/components/layout/topmessage/HolidayPromoBanner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import Link from "next/link"; | ||
import { useL10n } from "../../../hooks/l10n"; | ||
import { Localized } from "../../Localized"; | ||
import styles from "./HolidayPromoBanner.module.scss"; | ||
import { RuntimeData } from "../../../hooks/api/runtimeData"; | ||
import { | ||
getPeriodicalPremiumSubscribeLink, | ||
isPeriodicalPremiumAvailableInCountry, | ||
} from "../../../functions/getPlan"; | ||
import { ProfileData } from "../../../hooks/api/profile"; | ||
|
||
type Props = { | ||
isLoading: boolean; | ||
profile?: ProfileData; | ||
runtimeData?: RuntimeData; | ||
}; | ||
|
||
export const HolidayPromoBanner = (props: Props) => { | ||
const l10n = useL10n(); | ||
const coupon = "HOLIDAY20"; | ||
const subscribeLink = isPeriodicalPremiumAvailableInCountry(props.runtimeData) | ||
? getPeriodicalPremiumSubscribeLink(props.runtimeData, "yearly") | ||
: null; | ||
const todaysDate = new Date(); | ||
const expiryDate = new Date("December 31, 2023"); | ||
const isPastExpiry = todaysDate > expiryDate; | ||
|
||
if (props.isLoading || !subscribeLink || props.profile || isPastExpiry) { | ||
return null; | ||
} | ||
|
||
const subscriberLinkWithCoupon = `${subscribeLink}&coupon=${coupon}`; | ||
|
||
return ( | ||
<aside className={styles.wrapper}> | ||
<div className={styles["left-promo-container"]}> | ||
<div className={styles["promo-container"]}> | ||
<p className={styles["promo-text"]}> | ||
{l10n.getString("holiday-promo-banner-protect-inbox")} | ||
</p> | ||
<p className={styles["promo-text-bolded"]}> | ||
{l10n.getString("holiday-promo-banner-code-desc")} | ||
</p> | ||
</div> | ||
<div className={styles["promo-container"]}> | ||
<Localized | ||
id="holiday-promo-banner-code-usage" | ||
vars={{ couponCode: coupon }} | ||
elems={{ | ||
coupon: <span className={styles["promo-text-bolded"]} />, | ||
}} | ||
> | ||
<p className={styles["promo-text"]} /> | ||
</Localized> | ||
</div> | ||
</div> | ||
<div className={styles["promo-container"]}> | ||
<Link href={subscriberLinkWithCoupon} className={styles["cta-button"]}> | ||
{l10n.getString("holiday-promo-banner-cta-button")} | ||
</Link> | ||
<small className={styles["promo-code-expiry"]}> | ||
{l10n.getString("holiday-promo-banner-promo-expiry")} | ||
</small> | ||
</div> | ||
</aside> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters