From acbde7bcf8783834eea8d30c32ba73da1480c09f Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 28 Nov 2026 19:54:23 +0700 Subject: [PATCH 1/2] feat(campaign): a Black Friday notice on load, and no dot, arrow or glow on the sale - CampaignNotice opens once per page load while the sale is live: a modal dialog from 640px (the two offers, the countdown, Buy Pro one-time, See both offers, Not now), a non-blocking card at the bottom below it. - It stays shut on /black-friday and Pricing (the banner prop's `notice`), while the consent bar asks, for a reader whose regional discount takes more off, and once closed: `tablepro:campaign-closed` holds `{id}:notice`, which keeps the banner; closing the banner still closes both. - The sale's banner, the license banner, the language bar and /black-friday lose the accent dot, the trailing arrows, the glow and the light under the pointer. The banner writes its call to action out at every width. - The language bar now takes the slot from the sale's banner: the rule that hid it lost on specificity, so both bars stacked. --- app/Support/Banner.php | 24 +- docs/architecture.md | 6 +- docs/rebuild/design/design-system.md | 2 +- docs/rebuild/design/positioning.md | 9 + resources/css/app.css | 48 +-- .../components/campaign/campaign-banner.tsx | 19 +- .../components/campaign/campaign-ground.tsx | 26 +- .../components/campaign/campaign-notice.tsx | 372 ++++++++++++++++++ .../js/components/campaign/countdown.tsx | 25 +- .../js/components/campaign/pro-features.tsx | 5 +- resources/js/components/site/language-bar.tsx | 3 +- .../js/components/site/support-banner.tsx | 4 +- resources/js/hooks/use-regional-pricing.ts | 19 +- resources/js/i18n/messages/de/campaign.ts | 14 + resources/js/i18n/messages/en/campaign.ts | 17 +- resources/js/i18n/messages/es/campaign.ts | 14 + resources/js/i18n/messages/fr/campaign.ts | 14 + resources/js/i18n/messages/id/campaign.ts | 14 + resources/js/i18n/messages/it/campaign.ts | 14 + resources/js/i18n/messages/ja/campaign.ts | 14 + resources/js/i18n/messages/ko/campaign.ts | 14 + resources/js/i18n/messages/pt-BR/campaign.ts | 14 + resources/js/i18n/messages/vi/campaign.ts | 14 + .../js/i18n/messages/zh-Hans/campaign.ts | 14 + .../js/i18n/messages/zh-Hant/campaign.ts | 14 + resources/js/layouts/landing-layout.tsx | 2 + resources/js/lib/campaign.ts | 25 ++ resources/js/pages/BlackFriday.tsx | 6 +- resources/js/types/shared-props.ts | 6 +- tests/Feature/Pages/CampaignTest.php | 6 +- tests/js/campaign.test.ts | 37 +- 31 files changed, 713 insertions(+), 102 deletions(-) create mode 100644 resources/js/components/campaign/campaign-notice.tsx diff --git a/app/Support/Banner.php b/app/Support/Banner.php index 48594c10..ef7a2bc2 100644 --- a/app/Support/Banner.php +++ b/app/Support/Banner.php @@ -44,6 +44,14 @@ final class Banner */ public const CAMPAIGN_PAGE = 'landing.black-friday'; + /** + * Base route names where the sale's banner shows but its notice does not + * open over the page: Pricing already carries the sale on its plan cards. + * + * @var list + */ + public const CAMPAIGN_NOTICE_HIDDEN_ON = ['landing.pricing']; + public const KIND_CAMPAIGN = 'campaign'; public const KIND_LICENSE = 'license'; @@ -75,15 +83,23 @@ public static function hiddenOnIosDevices(Request $request): bool /** * The shared `banner` prop, or null where no banner is on this page. Null * rather than a flag, so the component renders nothing at all. Only which - * banner and its link: the words are the `banner` and `campaign` catalogs', - * and neither banner can be closed, so there is no version to close it at. + * banner and its link: the words are the `banner` and `campaign` catalogs'. + * The license banner cannot be closed, so there is no version to close it at. + * + * The sale's carries `notice`: whether its notice (`CampaignNotice`) may + * open over this page on load. Whether it does is the reader's browser's + * call, since the page sits in the edge cache. * - * @return array{kind: string, href: string}|null + * @return array{kind: string, href: string, notice?: bool}|null */ public static function forRequest(Request $request): ?array { return match (self::kind($request)) { - self::KIND_CAMPAIGN => ['kind' => self::KIND_CAMPAIGN, 'href' => '/black-friday'], + self::KIND_CAMPAIGN => [ + 'kind' => self::KIND_CAMPAIGN, + 'href' => '/black-friday', + 'notice' => ! in_array(self::page($request), self::CAMPAIGN_NOTICE_HIDDEN_ON, true), + ], self::KIND_LICENSE => ['kind' => self::KIND_LICENSE, 'href' => (string) config('banner.href')], default => null, }; diff --git a/docs/architecture.md b/docs/architecture.md index 42638dd9..3e54448e 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -400,7 +400,11 @@ Events keep the names the Plausible goals had: `download_click` (`location`, `newsletter_signup_clicked` (`source`). The license banner adds `license_banner_view` and `license_banner_click`, without parameters, so a banner's clicks can be compared with its views and with `checkout_started`. -It cannot be closed, so there is no dismiss event. GA4 stores the parameters +It cannot be closed, so there is no dismiss event. The dated sale's banner sends +`campaign_banner_view`, `campaign_banner_click` and `campaign_banner_close`; +its notice (`CampaignNotice`) sends `campaign_notice_view` (`kind`: `dialog` +or `card`), `campaign_notice_click` (`action`: `buy`, `both` or `deal`) and +`campaign_notice_close` (`action`: what closed it). GA4 stores the parameters from the first hit but only shows them in reports once each is registered as an event-scoped custom dimension under Admin → Custom definitions. Page changes between Inertia visits are counted by enhanced measurement's "page changes diff --git a/docs/rebuild/design/design-system.md b/docs/rebuild/design/design-system.md index 1a043c1c..b7bb758f 100644 --- a/docs/rebuild/design/design-system.md +++ b/docs/rebuild/design/design-system.md @@ -1040,6 +1040,7 @@ One shared file, `components/shared/theme-control.tsx` (architecture §1.10 and - Actions are right-aligned: **Cancel** (`quiet`, default focus on destructive dialogs), then **confirm** (`danger` or `primary`). - Below 480 the actions stack full width in the same order. - Escape cancels. The confirm button shows a busy state; on error the dialog stays open with an inline `Callout danger`. +- The dated sale's notice (`CampaignNotice`, positioning "Dated sales") is the one dialog outside this shape: 520px, on the sale's black ground, focus on the dialog itself when it opens, one `primary` action full width and `Not now` as `quiet`. Escape, the backdrop and every action close it. **Toast:** @@ -1325,7 +1326,6 @@ The ceiling drops from 320ms to 240ms, and `--dur-row` goes with the row bar. - **The load sequence,** once per visit: the headline settles (`sale-rise`, 560ms, `--ease-panel`), a drawn line strikes the list prices, then the sale prices arrive. Under a second in all. - **The countdown digits roll**, each one only when it changes (`roll-in`, `roll-out`, 320ms). -- **The light under the pointer** (`campaign-spot`): a 30rem accent radial at 13% that follows a mouse, never a finger, and fades out when the pointer leaves. - **The Pro capture crossfade** (`sale-stage`, `--dur-panel`): only when the reader picks another feature. **Pricing** (owner decision, 2026-11-06), on the plan block wherever it shows (/pricing, the homepage, /teams), never under reduced motion: diff --git a/docs/rebuild/design/positioning.md b/docs/rebuild/design/positioning.md index 711c254e..2ba09cc4 100644 --- a/docs/rebuild/design/positioning.md +++ b/docs/rebuild/design/positioning.md @@ -446,6 +446,15 @@ says what a discount takes off and how long is left. It is a real discount at th prices, with a code that works only inside the window (`App\Support\Pricing\Campaign`, `lib/campaign.ts`). - **Where, while it is live:** the banner slot on every page but the sale's own, and the plan cards of the cycles it covers. No band above a page's hero (owner, 2026-11-23). Checkout from the site attaches the code. +- **The notice** (owner, 2026-11-28, `CampaignNotice`): once per page load, as the page opens. From 640px a modal + dialog on the black ground: the percentage off, the two offers as ruled rows with their struck prices, the + countdown, a button that buys Pro one-time at its sale price, a link to the sale's page and "Not now". Below + 640px a card at the bottom of the screen that blocks nothing (Google's guidance on intrusive dialogs): the + percentage, Pro one-time's sale price, the countdown and the sale's page. It never opens on the sale's page or + Pricing, while the consent bar is asking (one thing asks at a time), for a reader whose regional discount takes + more off, or again once the reader has answered it, a click on an offer included: closing it or the banner closes + it for the rest of the sale (`tablepro:campaign-closed`). No coloured dot, glow or accent rule on it; the accent + is the one button. Before and after the window, only the sale's own page mentions it. - **The sale's own page,** `/black-friday`, keeps one URL from year to year and is black throughout, in both themes. Before the sale it states the window and the prices, and offers a calendar file for the start instead of a button that cannot be pressed; during it the offers diff --git a/resources/css/app.css b/resources/css/app.css index 7a2e6826..345281d7 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -222,7 +222,13 @@ html.has-language-bar .support-banner { * The banner and the sale page's ground are an island of the dark theme * whatever the reader chose: the element carries `.dark`, so every token * inside resolves to its dark value and the design system's text pairs hold. - * The glow is the brand hue thinning out from the top right. Positioning §12.2. + * Flat black: no glow and no light under the pointer (owner, 2026-11-28), as + * the accent never colours a glow (design-system §1). Positioning §12.2. + * + * The slot holds one bar: the language bar, when it shows, takes it from the + * sale's banner as it does from the license banner. The rule names all three + * classes so it outweighs the one that shows the banner; with only + * `has-language-bar` it lost on specificity and both bars stacked. */ .campaign-banner { display: none; @@ -233,7 +239,7 @@ html.has-banner.campaign-live .campaign-banner { height: var(--banner-h); } -html.has-language-bar .campaign-banner { +html.has-language-bar.has-banner.campaign-live .campaign-banner { display: none; } @@ -259,20 +265,6 @@ html[data-theme-forced] .theme-setting { border-bottom: 1px solid color-mix(in oklab, var(--accent) 45%, var(--rule)); } -.campaign-glow { - background-image: radial-gradient( - 56rem 28rem at 100% 0%, - color-mix(in oklab, var(--accent) 16%, transparent), - transparent 70% - ); -} - -@media (forced-colors: active) { - .campaign-glow { - background-image: none; - } -} - /* The global rails are drawn in the page's theme; on the black ground they would be a light line in the light theme. */ .campaign-rails { position: absolute; @@ -302,30 +294,6 @@ html[data-theme-forced] .theme-setting { } } -/* The light under the pointer on the sale's black ground. Mouse only. */ -.campaign-spot { - position: absolute; - inset: 0; - pointer-events: none; - opacity: 0; - background: radial-gradient( - 30rem circle at var(--spot-x, 50%) var(--spot-y, 50%), - color-mix(in oklab, var(--accent) 13%, transparent), - transparent 70% - ); - transition: opacity var(--dur-panel) var(--ease-feedback); -} - -[data-spot="on"] > .campaign-spot { - opacity: 1; -} - -@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce), (forced-colors: active) { - .campaign-spot { - display: none; - } -} - .sale-display { font-size: clamp(3.5rem, 15vw, 9.5rem); line-height: 0.92; diff --git a/resources/js/components/campaign/campaign-banner.tsx b/resources/js/components/campaign/campaign-banner.tsx index 2a754976..4f49c8c6 100644 --- a/resources/js/components/campaign/campaign-banner.tsx +++ b/resources/js/components/campaign/campaign-banner.tsx @@ -8,7 +8,8 @@ import { trackEvent } from '@/lib/analytics'; import { PRICING } from '@/lib/data/pricing'; import Countdown from './countdown'; -// Local storage: the id of the sale whose banner the reader closed. Listed in the privacy policy. +// Local storage: the id of the sale whose banner the reader closed, or `{id}:notice` once they closed only its notice +// (`noticeClosedValue`, CampaignNotice). Listed in the privacy policy as the closed sale notice. export const CLOSED_KEY = 'tablepro:campaign-closed'; // Closable, because its countdown updates by itself on every page (WCAG 2.2.2). @@ -55,19 +56,15 @@ export default function CampaignBanner() { trackEvent('campaign_banner_click')} - className="type-small flex h-full min-w-0 flex-1 items-center gap-x-3 whitespace-nowrap no-underline" + className="type-small flex h-full min-w-0 flex-1 items-center gap-x-2 whitespace-nowrap no-underline sm:gap-x-3" > - - + {m.campaign.name} {fmt(copy.message, { percent: campaign.percent })} - {fmt(copy.short, { percent: campaign.percent })} + {/* Below 360px the name and the call to action are what fits. */} + {fmt(copy.short, { percent: campaign.percent })} - - {copy.cta} - - + {/* Written out at every width, with no arrow or dot: the words say where it leads. */} + {copy.cta} + + +

+ {fmt(copy.headline, { percent: campaign.percent })} + {copy.product} +

+

{fmt(copy.window, { endsOn: prop.endsOn, endsAtTime: prop.endsAtTime })}

+ + + + + + + {flow.error !== null && ( + +

{flow.error.message}

+
+ )} + +
+ { + trackEvent('campaign_notice_click', { action: 'both' }); + onClose('both'); + }} + className={textLinkClasses('standalone', 'type-small py-2.5 font-medium')} + > + {copy.both} + + +
+ +

{fmt(copy.footnote, { listPriceSince: prop.listPriceSince })}

+ + + ); +} + +function NoticeCard({ campaign, href, onClose }: NoticeProps) { + const { m, fmt } = useI18n(); + const titleId = useId(); + const card = useRef(null); + + // Keeps a focused element from scrolling underneath it (WCAG 2.4.11), as the consent bar does. + useEffect(() => { + const root = document.documentElement; + const node = card.current; + + if (node === null || root.style.scrollPaddingBottom !== '') { + return; + } + + root.style.scrollPaddingBottom = `${node.offsetHeight + 24}px`; + + return () => { + root.style.scrollPaddingBottom = ''; + }; + }, []); + const copy = m.campaign.notice; + const lifetime = discountedAmount(PRICING.tiers.starter.prices.lifetime, campaign.percent); + + return ( +
+
+

+ {fmt(copy.card, { percent: campaign.percent })} +

+ +
+
+
+

{fmt(copy.cardPrice, { price: formatUsd(lifetime, m.pricing.currency) })}

+ +
+ { + trackEvent('campaign_notice_click', { action: 'deal' }); + onClose('deal'); + }} + className="inline-flex min-h-11 shrink-0 items-center rounded-control bg-accent px-4 text-sm font-medium text-accent-foreground transition-colors duration-(--dur-tap) ease-(--ease-feedback) hover:bg-accent-hover active:bg-accent-active" + > + {m.campaign.banner.cta} + +
+
+ ); +} diff --git a/resources/js/components/campaign/countdown.tsx b/resources/js/components/campaign/countdown.tsx index f2328f26..7c53ebd4 100644 --- a/resources/js/components/campaign/countdown.tsx +++ b/resources/js/components/campaign/countdown.tsx @@ -7,8 +7,9 @@ import { cn } from '@/lib/utils'; interface CountdownProps { to: 'start' | 'end'; - // `inline`: one line of text, for the banner. `digits`: large rolling digits with their units, for the band and the sale's page. - variant: 'inline' | 'digits'; + // `inline`: one line of text, for the banner. `row`: one line of rolling digits with their units, for the sale's notice. + // `digits`: large rolling digits with their units, for the band and the sale's page. + variant: 'inline' | 'row' | 'digits'; className?: string; } @@ -52,6 +53,26 @@ export default function Countdown({ to, variant, className }: CountdownProps) { [left.seconds, copy.units.seconds], ]; + if (variant === 'row') { + return ( +
+ + {left !== null && ( + + )} +
+ ); + } + return (

{item.detail}{' '} - + {/* Underlined, not arrowed: beside the muted sentence, colour alone would not mark it (WCAG 1.4.1). */} + {item.link} -

diff --git a/resources/js/components/site/language-bar.tsx b/resources/js/components/site/language-bar.tsx index 6aca9e07..b30ab848 100644 --- a/resources/js/components/site/language-bar.tsx +++ b/resources/js/components/site/language-bar.tsx @@ -11,7 +11,7 @@ import { languageCopy } from '@/i18n'; * the header and in place of the license banner (TopBanner). * * It speaks the language it offers, never the page's, since the reader it is - * for may not read the page's: "Đọc trang này bằng tiếng Việt →" on an English + * for may not read the page's: "Đọc trang này bằng tiếng Việt" on an English * page. Those few strings ship for every locale (`languageCopy`). The link is * the switcher's own option for that language, a plain `` to the same page * there, and following it is the reader's pick (`pickLanguage`). ✕ means that @@ -50,7 +50,6 @@ export default function LanguageBar() { className={textLinkClasses('standalone', 'relative whitespace-nowrap after:absolute after:-inset-x-1 after:-inset-y-3')} > {copy.action} -