Repository navigation
feat(web): add Black Friday 2026 yearly-plan promotion #1085
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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,156 @@ | ||
| <script setup lang="ts"> | ||
| import { mdiChevronRight, mdiClose } from '@mdi/js' | ||
| import { BLACK_FRIDAY_END, isBlackFridayEligible } from '~/utils/black-friday' | ||
|
|
||
| const route = useRoute() | ||
| const authStore = useAuthStore() | ||
| const promotion = useBlackFridayStore() | ||
| const dismissed = useCookie<boolean>('httpsms_bf2026_dismissed', { | ||
| default: () => false, | ||
| expires: new Date(BLACK_FRIDAY_END), | ||
| sameSite: 'lax', | ||
| path: '/', | ||
| }) | ||
| const visible = computed( | ||
| () => | ||
| !dismissed.value && | ||
| promotion.active && | ||
| isBlackFridayEligible( | ||
| String(route.name), | ||
| authStore.authStateChanged, | ||
| authStore.authUser !== null, | ||
| authStore.user?.subscription_name, | ||
| ), | ||
| ) | ||
| const bannerElement = useTemplateRef<HTMLElement>('bannerElement') | ||
| const bannerHeight = ref(0) | ||
| const contentColumns = computed(() => { | ||
| switch (route.name) { | ||
| case 'settings': | ||
| case 'billing': | ||
| case 'phone-api-keys': | ||
| return { md: 9, offsetMd: 1, xl: 8, offsetXl: 2 } | ||
| case 'bulk-messages': | ||
| return { md: 10, offsetMd: 1, xxl: 8, offsetXxl: 2 } | ||
| case 'messages': | ||
| return { md: 8, offsetMd: 2, xl: 6, offsetXl: 3 } | ||
| default: | ||
| return {} | ||
| } | ||
| }) | ||
| const hasPagePadding = computed(() => | ||
| ['settings', 'messages'].includes(String(route.name)), | ||
| ) | ||
| let resizeObserver: ResizeObserver | undefined | ||
|
|
||
| watch(bannerElement, (element) => { | ||
| resizeObserver?.disconnect() | ||
| if (!element) return | ||
|
|
||
| const updateHeight = () => { | ||
| bannerHeight.value = element.getBoundingClientRect().height | ||
| } | ||
| updateHeight() | ||
| resizeObserver = new ResizeObserver(updateHeight) | ||
| resizeObserver.observe(element) | ||
| }) | ||
|
|
||
| onBeforeUnmount(() => { | ||
| resizeObserver?.disconnect() | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <v-layout-item | ||
| v-if="visible" | ||
| position="top" | ||
| :order="-1" | ||
| :size="bannerHeight" | ||
| model-value | ||
| > | ||
| <div ref="bannerElement"> | ||
| <v-toolbar | ||
| class="black-friday-banner" | ||
| color="transparent" | ||
| tag="aside" | ||
| aria-label="Black Friday promotion" | ||
| flat | ||
| > | ||
| <v-container fluid class="py-0" :class="{ 'px-0': !hasPagePadding }"> | ||
| <v-container :class="route.name === 'settings' ? 'pa-0' : 'py-0'"> | ||
| <v-row class="my-0"> | ||
| <v-col cols="12" v-bind="contentColumns" class="py-3"> | ||
| <div class="d-flex align-center ga-3"> | ||
| <div | ||
| class="black-friday-banner-offer d-flex align-center ga-3" | ||
| > | ||
| <strong class="text-warning text-uppercase" | ||
| >Black Friday</strong | ||
| > | ||
| <span> | ||
| Get <strong>40% off</strong> the yearly plans with | ||
| discount code | ||
| <strong class="text-warning">BF2026</strong> at checkout. | ||
| </span> | ||
| <v-btn | ||
| to="/billing" | ||
| class="d-none d-sm-inline-flex" | ||
| color="warning" | ||
| size="small" | ||
| :append-icon="mdiChevronRight" | ||
| > | ||
| Use now | ||
| </v-btn> | ||
| </div> | ||
| <div | ||
| class="black-friday-banner-timer d-none d-sm-block text-right" | ||
| > | ||
| <strong | ||
| class="text-no-wrap" | ||
| role="timer" | ||
| aria-label="Time remaining" | ||
| aria-live="off" | ||
| > | ||
| {{ promotion.countdown }} | ||
| </strong> | ||
| </div> | ||
| <v-btn | ||
| :icon="mdiClose" | ||
| class="align-self-start align-self-sm-center flex-shrink-0" | ||
| color="error" | ||
| density="compact" | ||
| size="small" | ||
| variant="text" | ||
| aria-label="Dismiss Black Friday promotion" | ||
| @click="dismissed = true" | ||
| /> | ||
| </div> | ||
| </v-col> | ||
| </v-row> | ||
| </v-container> | ||
| </v-container> | ||
| </v-toolbar> | ||
| </div> | ||
| </v-layout-item> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| .black-friday-banner { | ||
| background: linear-gradient(110deg, #090909 40%, #10545b); | ||
| } | ||
|
|
||
| .black-friday-banner :deep([class~='v-toolbar__content']) { | ||
| height: auto !important; | ||
| min-height: 64px; | ||
| } | ||
|
|
||
| .black-friday-banner-offer { | ||
| flex: 1; | ||
| flex-wrap: wrap; | ||
| min-width: 0; | ||
| } | ||
|
|
||
| .black-friday-banner-timer { | ||
| font-variant-numeric: tabular-nums; | ||
| } | ||
| </style> |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import assert from 'node:assert/strict' | ||
| import { test } from 'node:test' | ||
| import { createPinia, disposePinia, setActivePinia } from 'pinia' | ||
| import { computed } from 'vue' | ||
| import { getBlackFridayCheckoutUrl } from '../utils/black-friday' | ||
| import { useBlackFridayStore } from './blackFriday' | ||
|
|
||
| test('expires the countdown, cached offer, and checkout links together on an open page', (t) => { | ||
| t.mock.timers.enable({ | ||
| apis: ['Date', 'setInterval'], | ||
| now: new Date('2026-11-30T23:59:58Z'), | ||
| }) | ||
| const pinia = createPinia() | ||
| setActivePinia(pinia) | ||
| t.after(() => disposePinia(pinia)) | ||
| const promotion = useBlackFridayStore() | ||
| const offerVisible = computed(() => promotion.active) | ||
| const links = ['pro', 'enterprise'].map((product) => | ||
| computed( | ||
| () => | ||
| new URL( | ||
| getBlackFridayCheckoutUrl( | ||
| new URL(`https://store.lemonsqueezy.com/buy/${product}`), | ||
| 'free', | ||
| promotion.now, | ||
| ), | ||
| ), | ||
| ), | ||
| ) | ||
|
|
||
| assert.equal(offerVisible.value, true) | ||
| for (const link of links) { | ||
| assert.equal( | ||
| link.value.searchParams.get('checkout[discount_code]'), | ||
| 'BF2026', | ||
| ) | ||
| } | ||
| t.mock.timers.tick(1000) | ||
| assert.equal(promotion.countdown, '0 Days 00:00:01') | ||
| t.mock.timers.tick(1000) | ||
| assert.equal(promotion.countdown, null) | ||
| assert.equal(offerVisible.value, false) | ||
| for (const link of links) { | ||
| assert.equal(link.value.searchParams.has('checkout[discount_code]'), false) | ||
| } | ||
| const expiredAt = promotion.now | ||
| t.mock.timers.tick(10_000) | ||
| assert.equal(promotion.now, expiredAt) | ||
| }) | ||
|
|
||
| test('stops the shared clock when the store is disposed', (t) => { | ||
| t.mock.timers.enable({ | ||
| apis: ['Date', 'setInterval'], | ||
| now: new Date('2026-11-30T23:59:58Z'), | ||
| }) | ||
| const pinia = createPinia() | ||
| setActivePinia(pinia) | ||
| t.after(() => disposePinia(pinia)) | ||
| const promotion = useBlackFridayStore() | ||
| const initialTime = promotion.now | ||
|
|
||
| promotion.$dispose() | ||
| t.mock.timers.tick(2000) | ||
|
|
||
| assert.equal(promotion.now, initialTime) | ||
| }) |
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,24 @@ | ||
| import { defineStore } from 'pinia' | ||
| import { computed, onScopeDispose, ref } from 'vue' | ||
| import { | ||
| BLACK_FRIDAY_END, | ||
| getBlackFridayCountdown, | ||
| } from '../utils/black-friday' | ||
|
|
||
| export const useBlackFridayStore = defineStore('blackFriday', () => { | ||
| const now = ref(Date.now()) | ||
| const active = computed(() => now.value < BLACK_FRIDAY_END) | ||
| const countdown = computed(() => getBlackFridayCountdown(now.value)) | ||
| let timer: ReturnType<typeof setInterval> | undefined | ||
|
|
||
| if (active.value) { | ||
| timer = setInterval(() => { | ||
| now.value = Date.now() | ||
| if (!active.value) clearInterval(timer) | ||
| }, 1000) | ||
| } | ||
|
|
||
| onScopeDispose(() => clearInterval(timer)) | ||
|
|
||
| return { now, active, countdown } | ||
| }) |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.