-
Notifications
You must be signed in to change notification settings - Fork 935
Add the Black Friday announcement modal #22507
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
Merged
thijsoo
merged 13 commits into
feature/bf-2025
from
746-black-friday-ads-2025---announcement-modal
Aug 21, 2025
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4275521
Decouple the intermediate content component from the initializer, to …
leonidasmi ee23ffe
Make sure that the non-prioritized introductions will be shown in the…
leonidasmi 1a77656
Merge feature branch
leonidasmi 79df1d7
Fix PHPCS
leonidasmi 347c5e4
Rename stuff to make it year-agnostic when it comes to BF naming
leonidasmi 2cc5f05
Show the BF modal only when Premium is not enabled
leonidasmi 2b5324b
Fix and add tests
leonidasmi 6e7bafb
All non-BF modals for the Yoast pages should have lower prio
leonidasmi b47d5a3
Finalize styling of BF modal
leonidasmi 0f63d69
Remove unused trait
leonidasmi 9ec42e6
Add ctb attributes
leonidasmi 016613a
Improve naming when finding the introduction with the highest prio
leonidasmi 4876d7f
Improve naming of CTB attribute
leonidasmi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export { Content } from "./content"; | ||
export { Introduction } from "./introduction"; | ||
export { Modal } from "./modal"; | ||
export { IntroductionProvider, useIntroductionsContext } from "./provider"; |
This file contains hidden or 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
158 changes: 158 additions & 0 deletions
158
packages/js/src/introductions/components/modals/black-friday-announcement.js
This file contains hidden or 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,158 @@ | ||
import { useSelect } from "@wordpress/data"; | ||
import { useMemo } from "@wordpress/element"; | ||
import { __, sprintf } from "@wordpress/i18n"; | ||
import { Button, useModalContext } from "@yoast/ui-library"; | ||
import { LockOpenIcon } from "@heroicons/react/outline"; | ||
import { STORE_NAME_INTRODUCTIONS } from "../../constants"; | ||
import { Modal } from "../modal"; | ||
import { get } from "lodash"; | ||
|
||
/** | ||
* @param {Object} thumbnail The thumbnail: img props. | ||
* @param {string} buttonLink The button link. | ||
* @param {Boolean} isWooEnabled Whether WooCommerce is enabled. | ||
* @returns {JSX.Element} The element. | ||
*/ | ||
const BlackFridayAnnouncementContent = ( { | ||
thumbnail, | ||
buttonLink, | ||
isWooEnabled, | ||
} ) => { | ||
const { onClose, initialFocus } = useModalContext(); | ||
|
||
const productName = useMemo( () => { | ||
return isWooEnabled ? "Yoast WooCommerce SEO" : "Yoast SEO Premium"; | ||
}, [ isWooEnabled ] ); | ||
|
||
const buttonLabel = useMemo( () => { | ||
const product = isWooEnabled ? "WooCommerce SEO" : "Premium"; | ||
|
||
return sprintf( | ||
/* translators: %1$s expands to either Premium or WooCommerce SEO. */ | ||
__( "Get %1$s with 30%% off", "wordpress-seo" ), | ||
product | ||
); | ||
}, [ isWooEnabled ] ); | ||
|
||
const iconClass = useMemo( () => { | ||
return isWooEnabled ? "yst-cart-icon" : "yst-logo-icon"; | ||
}, [ isWooEnabled ] ); | ||
|
||
const introductionClass = useMemo( () => { | ||
return isWooEnabled ? "yst-woo-introduction-gradient" : "yst-introduction-gradient"; | ||
}, [ isWooEnabled ] ); | ||
|
||
const ctb = useMemo( () => { | ||
return isWooEnabled ? "c7e7baa1-2020-420c-a427-89701700b607" : "f6a84663-465f-4cb5-8ba5-f7a6d72224b2"; | ||
}, [ isWooEnabled ] ); | ||
|
||
const description = useMemo( () => { | ||
/* eslint-disable stylistic/max-len */ | ||
return isWooEnabled | ||
? sprintf( | ||
/* translators: %1$s expands to Premium, %2$s expands to Local, %3$s expands to News, %4$s expands to Video SEO, %5$s expands to Google. */ | ||
__( "We added even more value than ever this year: %1$s, %2$s, %3$s, %4$s, and seamless %5$s Docs add-on, all included. If you've been waiting to upgrade, now’s the time..", "wordpress-seo" ), | ||
"Premium", | ||
"Local", | ||
"News", | ||
"Video SEO", | ||
"Google" | ||
) | ||
: sprintf( | ||
/* translators: %1$s expands to Local, %2$s expands to News, %3$s expands to Video SEO, %4$s expands to Google. */ | ||
__( "We added even more value than ever this year: %1$s, %2$s, %3$s, and seamless %4$s Docs add-on, all included. If you've been waiting to upgrade, now’s the time.", "wordpress-seo" ), | ||
"Local", | ||
"News", | ||
"Video SEO", | ||
"Google" | ||
); | ||
/* eslint-enable stylistic/max-len */ | ||
}, [ isWooEnabled ] ); | ||
|
||
return ( | ||
<> | ||
<div className={ `yst-px-10 yst-pt-10 yst-text-center ${introductionClass}` }> | ||
<img | ||
className="yst-w-full yst-h-auto yst-rounded-md yst-drop-shadow-md" | ||
alt={ __( "Thumbnail for the Black Friday announcement", "wordpress-seo" ) } | ||
loading="lazy" | ||
decoding="async" | ||
{ ...thumbnail } | ||
/> | ||
<div className="yst-mt-6 yst-text-xs yst-font-medium yst-flex yst-flex-col yst-items-center"> | ||
<span className="yst-introduction-modal-uppercase yst-flex yst-gap-2 yst-items-center"> | ||
<span className={ iconClass } /> | ||
{ productName } | ||
</span> | ||
</div> | ||
</div> | ||
<div className="yst-px-10 yst-pb-4 yst-flex yst-flex-col yst-items-center"> | ||
<div className="yst-mt-4 yst-mx-1.5 yst-text-center"> | ||
<h3 className="yst-text-slate-900 yst-text-lg yst-font-medium"> | ||
{ | ||
__( "Black Friday: Our biggest sale just dropped!", "wordpress-seo" ) | ||
} | ||
</h3> | ||
<div className="yst-mt-2 yst-text-slate-600 yst-text-sm"> | ||
<p>{ description }</p> | ||
</div> | ||
</div> | ||
<div className="yst-w-full yst-flex yst-mt-6"> | ||
<Button | ||
as="a" | ||
className="yst-grow yst-border-slate-200" | ||
size="extra-large" | ||
variant="upsell" | ||
href={ buttonLink } | ||
target="_blank" | ||
ref={ initialFocus } | ||
data-action="load-nfd-ctb" | ||
data-ctb-id={ ctb } | ||
leonidasmi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
> | ||
<LockOpenIcon className="yst--ms-1 yst-me-2 yst-h-5 yst-w-5" /> | ||
{ buttonLabel } | ||
<span className="yst-sr-only"> | ||
{ | ||
/* translators: Hidden accessibility text. */ | ||
__( "(Opens in a new browser tab)", "wordpress-seo" ) | ||
} | ||
</span> | ||
</Button> | ||
</div> | ||
<Button | ||
className="yst-mt-2" | ||
variant="tertiary" | ||
onClick={ onClose } | ||
> | ||
{ __( "Close", "wordpress-seo" ) } | ||
</Button> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
/** | ||
* @returns {JSX.Element} The element. | ||
*/ | ||
export const BlackFridayAnnouncement = () => { | ||
const imageLink = useSelect( select => select( STORE_NAME_INTRODUCTIONS ).selectImageLink( "ai-brand-insights-pre-launch.png" ), [] ); | ||
const isWooEnabled = useMemo( () => Boolean( get( window, "wpseoIntroductions.isWooEnabled", false ) ), [] ); | ||
const buttonPremiumLink = useSelect( select => select( STORE_NAME_INTRODUCTIONS ).selectLink( "https://yoa.st/black-friday-modal-premium/" ), [] ); | ||
const buttonWooLink = useSelect( select => select( STORE_NAME_INTRODUCTIONS ).selectLink( "https://yoa.st/black-friday-modal-ecommerce/" ), [] ); | ||
|
||
const thumbnail = useMemo( () => ( { | ||
src: imageLink, | ||
width: "432", | ||
height: "243", | ||
} ), [ imageLink ] ); | ||
|
||
return ( | ||
<Modal> | ||
<BlackFridayAnnouncementContent | ||
buttonLink={ isWooEnabled ? buttonWooLink : buttonPremiumLink } | ||
thumbnail={ thumbnail } | ||
isWooEnabled={ isWooEnabled } | ||
/> | ||
</Modal> | ||
); | ||
}; |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
Fixed here.