@adminide-stack/clock-tik-mobile 0.0.0-stage → 12.0.37-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-flow/data/pending-insights.jsonl +43 -0
- package/.claude-flow/sessions/session-1794323376548.json +14 -0
- package/CHANGELOG.md +41 -0
- package/jest.config.cjs +22 -0
- package/lib/assets/home/loop-day.jpg +0 -0
- package/lib/assets/home/loop-day.mp4 +0 -0
- package/lib/assets/home/loop-time-back.jpg +0 -0
- package/lib/assets/home/loop-time-back.mp4 +0 -0
- package/lib/assets/home/loop-where.jpg +0 -0
- package/lib/assets/home/loop-where.mp4 +0 -0
- package/lib/assets/home/reel-gym.jpg +0 -0
- package/lib/assets/home/reel-gym.mp4 +0 -0
- package/lib/assets/home/reel-internet.jpg +0 -0
- package/lib/assets/home/reel-internet.mp4 +0 -0
- package/lib/assets/icon.png +0 -0
- package/lib/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
- package/lib/assets/lottie/lucy-mark-calendar.json +1827 -0
- package/lib/assets/lottie/lucy-mark-call.json +1470 -0
- package/lib/assets/lottie/lucy-mark-connect.json +2552 -0
- package/lib/assets/lottie/lucy-mark-details.json +1735 -0
- package/lib/assets/lottie/lucy-mark-email.json +1363 -0
- package/lib/assets/lottie/lucy-mark-message.json +1154 -0
- package/lib/assets/lottie/lucy-mark-search.json +1067 -0
- package/lib/assets/lottie/lucy-mark-think.json +1253 -0
- package/lib/assets/lottie/lucy-mark-write.json +1532 -0
- package/lib/assets/lottie/time-back.json +16458 -0
- package/lib/assets/lottie/where-lucy-works-chat.json +6170 -0
- package/lib/assets/lottie/where-lucy-works-cloud.json +10066 -0
- package/lib/assets/lottie/where-lucy-works-mine-none.json +2478 -0
- package/lib/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
- package/lib/assets/lottie/where-lucy-works-mine-online.json +7881 -0
- package/lib/assets/sounds/hours-back.m4a +0 -0
- package/lib/assets/sounds/meet-lucy.m4a +0 -0
- package/lib/assets/sounds/power-on.m4a +0 -0
- package/lib/assets/sounds/wind-back.m4a +0 -0
- package/lib/assets/sounds/youre-in.m4a +0 -0
- package/lib/chat/agent.js +358 -0
- package/lib/chat/agent.js.map +1 -0
- package/lib/chat/appFront.js +32 -0
- package/lib/chat/appFront.js.map +1 -0
- package/lib/chat/auth.js +370 -0
- package/lib/chat/auth.js.map +1 -0
- package/lib/chat/chores.js +360 -0
- package/lib/chat/chores.js.map +1 -0
- package/lib/chat/connectors.js +45 -0
- package/lib/chat/connectors.js.map +1 -0
- package/lib/chat/jobs.js +223 -0
- package/lib/chat/jobs.js.map +1 -0
- package/lib/chat/lucyMotion.js +6 -0
- package/lib/chat/lucyMotion.js.map +1 -0
- package/lib/chat/protocol.js +111 -0
- package/lib/chat/protocol.js.map +1 -0
- package/lib/chat/results.js +133 -0
- package/lib/chat/results.js.map +1 -0
- package/lib/chat/store.js +81 -0
- package/lib/chat/store.js.map +1 -0
- package/lib/chat/useDictation.js +168 -0
- package/lib/chat/useDictation.js.map +1 -0
- package/lib/chat/useLucyChat.js +451 -0
- package/lib/chat/useLucyChat.js.map +1 -0
- package/lib/chat/useMyComputer.js +32 -0
- package/lib/chat/useMyComputer.js.map +1 -0
- package/lib/chat/whereLucyWorks.js +52 -0
- package/lib/chat/whereLucyWorks.js.map +1 -0
- package/lib/chat/workspace.js +124 -0
- package/lib/chat/workspace.js.map +1 -0
- package/lib/components/AreaShot.js +289 -0
- package/lib/components/AreaShot.js.map +1 -0
- package/lib/components/Backdrops.js +262 -0
- package/lib/components/Backdrops.js.map +1 -0
- package/lib/components/BottomSheet.js +61 -0
- package/lib/components/BottomSheet.js.map +1 -0
- package/lib/components/ChatSheets.js +429 -0
- package/lib/components/ChatSheets.js.map +1 -0
- package/lib/components/ConnectorLogo.js +91 -0
- package/lib/components/ConnectorLogo.js.map +1 -0
- package/lib/components/CustomDrawer.js +534 -0
- package/lib/components/CustomDrawer.js.map +1 -0
- package/lib/components/IdeasPane.js +394 -0
- package/lib/components/IdeasPane.js.map +1 -0
- package/lib/components/ImessageSheet.js +261 -0
- package/lib/components/ImessageSheet.js.map +1 -0
- package/lib/components/KeyboardAvoider.js +29 -0
- package/lib/components/KeyboardAvoider.js.map +1 -0
- package/lib/components/Logo.js +81 -0
- package/lib/components/Logo.js.map +1 -0
- package/lib/components/LucyWorking.js +67 -0
- package/lib/components/LucyWorking.js.map +1 -0
- package/lib/components/Markdown.js +260 -0
- package/lib/components/Markdown.js.map +1 -0
- package/lib/components/Media.js +93 -0
- package/lib/components/Media.js.map +1 -0
- package/lib/components/MessagesAppIcon.js +23 -0
- package/lib/components/MessagesAppIcon.js.map +1 -0
- package/lib/components/MicButton.js +71 -0
- package/lib/components/MicButton.js.map +1 -0
- package/lib/components/ResultCards.js +974 -0
- package/lib/components/ResultCards.js.map +1 -0
- package/lib/components/SignInPrompt.js +148 -0
- package/lib/components/SignInPrompt.js.map +1 -0
- package/lib/components/SignedOut.js +38 -0
- package/lib/components/SignedOut.js.map +1 -0
- package/lib/components/TalkToLucyHero.js +487 -0
- package/lib/components/TalkToLucyHero.js.map +1 -0
- package/lib/components/TalkToLucySheet.js +182 -0
- package/lib/components/TalkToLucySheet.js.map +1 -0
- package/lib/components/WhereLucyWorks.js +277 -0
- package/lib/components/WhereLucyWorks.js.map +1 -0
- package/lib/components/WorkspaceSection.js +271 -0
- package/lib/components/WorkspaceSection.js.map +1 -0
- package/lib/components/YantraMark.js +13 -0
- package/lib/components/YantraMark.js.map +1 -0
- package/lib/components/drawerHeader.js +38 -0
- package/lib/components/drawerHeader.js.map +1 -0
- package/lib/components/lottieInstalled.js +6 -0
- package/lib/components/lottieInstalled.js.map +1 -0
- package/lib/components/ui.js +550 -0
- package/lib/components/ui.js.map +1 -0
- package/lib/components/useSignOut.js +7 -0
- package/lib/components/useSignOut.js.map +1 -0
- package/lib/components/viewport.js +121 -0
- package/lib/components/viewport.js.map +1 -0
- package/lib/components/voiceDial.js +10 -0
- package/lib/components/voiceDial.js.map +1 -0
- package/lib/compute.js +157 -0
- package/lib/compute.js.map +1 -0
- package/lib/config/env-config.js +27 -0
- package/lib/config/env-config.js.map +1 -0
- package/lib/config/routes.js +15 -0
- package/lib/config/routes.js.map +1 -0
- package/lib/content.js +25 -0
- package/lib/content.js.map +1 -0
- package/lib/hooks/keyboardCover.js +39 -0
- package/lib/hooks/keyboardCover.js.map +1 -0
- package/lib/hooks/useKeyboard.js +121 -0
- package/lib/hooks/useKeyboard.js.map +1 -0
- package/lib/hooks/useReducedMotion.js +13 -0
- package/lib/hooks/useReducedMotion.js.map +1 -0
- package/lib/imessage/openMessages.js +25 -0
- package/lib/imessage/openMessages.js.map +1 -0
- package/lib/imessage/platform.js +12 -0
- package/lib/imessage/platform.js.map +1 -0
- package/lib/imessage/textLink.js +262 -0
- package/lib/imessage/textLink.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/live/card.js +28 -0
- package/lib/live/card.js.map +1 -0
- package/lib/live/liveActivity.js +144 -0
- package/lib/live/liveActivity.js.map +1 -0
- package/lib/module.js +3 -0
- package/lib/module.js.map +1 -0
- package/lib/offer/BlackFridayOffer.js +378 -0
- package/lib/offer/BlackFridayOffer.js.map +1 -0
- package/lib/offer/blackFriday.js +78 -0
- package/lib/offer/blackFriday.js.map +1 -0
- package/lib/offer/parts.js +624 -0
- package/lib/offer/parts.js.map +1 -0
- package/lib/offer/state.js +63 -0
- package/lib/offer/state.js.map +1 -0
- package/lib/push/push.js +142 -0
- package/lib/push/push.js.map +1 -0
- package/lib/push/usePushNotifications.js +39 -0
- package/lib/push/usePushNotifications.js.map +1 -0
- package/lib/routes.json +175 -0
- package/lib/screens/Account/index.js +209 -0
- package/lib/screens/Account/index.js.map +1 -0
- package/lib/screens/Chat/index.js +710 -0
- package/lib/screens/Chat/index.js.map +1 -0
- package/lib/screens/Chores/index.js +18 -0
- package/lib/screens/Chores/index.js.map +1 -0
- package/lib/screens/Connectors/index.js +17 -0
- package/lib/screens/Connectors/index.js.map +1 -0
- package/lib/screens/History/index.js +380 -0
- package/lib/screens/History/index.js.map +1 -0
- package/lib/screens/Home/index.js +2715 -0
- package/lib/screens/Home/index.js.map +1 -0
- package/lib/screens/Home/media.js +25 -0
- package/lib/screens/Home/media.js.map +1 -0
- package/lib/screens/Welcome/index.js +1066 -0
- package/lib/screens/Welcome/index.js.map +1 -0
- package/lib/talk/talkToLucy.js +139 -0
- package/lib/talk/talkToLucy.js.map +1 -0
- package/lib/theme/colors.js +29 -0
- package/lib/theme/colors.js.map +1 -0
- package/lib/theme/fonts.js +17 -0
- package/lib/theme/fonts.js.map +1 -0
- package/lib/theme/muse.js +134 -0
- package/lib/theme/muse.js.map +1 -0
- package/lib/utils/links.js +54 -0
- package/lib/utils/links.js.map +1 -0
- package/lib/utils/yantraLinks.js +68 -0
- package/lib/utils/yantraLinks.js.map +1 -0
- package/lib/welcome/flow.js +375 -0
- package/lib/welcome/flow.js.map +1 -0
- package/lib/welcome/haptics.js +125 -0
- package/lib/welcome/haptics.js.map +1 -0
- package/lib/welcome/parts.js +1996 -0
- package/lib/welcome/parts.js.map +1 -0
- package/lib/welcome/powerOn.js +29 -0
- package/lib/welcome/powerOn.js.map +1 -0
- package/lib/welcome/seen.js +41 -0
- package/lib/welcome/seen.js.map +1 -0
- package/lib/welcome/sound.js +110 -0
- package/lib/welcome/sound.js.map +1 -0
- package/package.json +66 -5
- package/rollup.config.mjs +42 -0
- package/src/.claude-flow/data/pending-insights.jsonl +19 -0
- package/src/.claude-flow/sessions/session-1795013028422.json +14 -0
- package/src/__tests__/auth.test.ts +94 -0
- package/src/__tests__/blackFriday.test.ts +75 -0
- package/src/__tests__/cardTokens.test.ts +77 -0
- package/src/__tests__/chores.test.ts +188 -0
- package/src/__tests__/choresList.test.ts +100 -0
- package/src/__tests__/connectLink.test.ts +21 -0
- package/src/__tests__/content.test.ts +54 -0
- package/src/__tests__/dictation.test.ts +186 -0
- package/src/__tests__/envConfig.test.ts +14 -0
- package/src/__tests__/haptics.test.ts +202 -0
- package/src/__tests__/jobs.test.ts +130 -0
- package/src/__tests__/keyboardCover.test.ts +84 -0
- package/src/__tests__/liveCard.test.ts +39 -0
- package/src/__tests__/lockedPhone.test.ts +355 -0
- package/src/__tests__/lucyMotion.test.ts +34 -0
- package/src/__tests__/platform.test.ts +32 -0
- package/src/__tests__/powerOn.test.ts +62 -0
- package/src/__tests__/protocol.test.ts +125 -0
- package/src/__tests__/push.test.ts +111 -0
- package/src/__tests__/results.test.ts +256 -0
- package/src/__tests__/sound.test.ts +248 -0
- package/src/__tests__/talkToLucy.test.ts +205 -0
- package/src/__tests__/textLink.test.ts +91 -0
- package/src/__tests__/voiceDial.test.ts +53 -0
- package/src/__tests__/welcomeFlow.test.ts +157 -0
- package/src/__tests__/whereLucyWorks.test.ts +81 -0
- package/src/__tests__/yantraLinks.test.ts +96 -0
- package/src/assets/home/loop-day.jpg +0 -0
- package/src/assets/home/loop-day.mp4 +0 -0
- package/src/assets/home/loop-time-back.jpg +0 -0
- package/src/assets/home/loop-time-back.mp4 +0 -0
- package/src/assets/home/loop-where.jpg +0 -0
- package/src/assets/home/loop-where.mp4 +0 -0
- package/src/assets/home/reel-gym.jpg +0 -0
- package/src/assets/home/reel-gym.mp4 +0 -0
- package/src/assets/home/reel-internet.jpg +0 -0
- package/src/assets/home/reel-internet.mp4 +0 -0
- package/src/assets/icon.png +0 -0
- package/src/assets/lottie/.claude-flow/data/pending-insights.jsonl +1 -0
- package/src/assets/lottie/lucy-mark-calendar.json +1827 -0
- package/src/assets/lottie/lucy-mark-call.json +1470 -0
- package/src/assets/lottie/lucy-mark-connect.json +2552 -0
- package/src/assets/lottie/lucy-mark-details.json +1735 -0
- package/src/assets/lottie/lucy-mark-email.json +1363 -0
- package/src/assets/lottie/lucy-mark-message.json +1154 -0
- package/src/assets/lottie/lucy-mark-search.json +1067 -0
- package/src/assets/lottie/lucy-mark-think.json +1253 -0
- package/src/assets/lottie/lucy-mark-write.json +1532 -0
- package/src/assets/lottie/time-back.json +16458 -0
- package/src/assets/lottie/where-lucy-works-chat.json +6170 -0
- package/src/assets/lottie/where-lucy-works-cloud.json +10066 -0
- package/src/assets/lottie/where-lucy-works-mine-none.json +2478 -0
- package/src/assets/lottie/where-lucy-works-mine-offline.json +2373 -0
- package/src/assets/lottie/where-lucy-works-mine-online.json +7881 -0
- package/src/assets/sounds/hours-back.m4a +0 -0
- package/src/assets/sounds/meet-lucy.m4a +0 -0
- package/src/assets/sounds/power-on.m4a +0 -0
- package/src/assets/sounds/wind-back.m4a +0 -0
- package/src/assets/sounds/youre-in.m4a +0 -0
- package/src/chat/.claude-flow/data/pending-insights.jsonl +1 -0
- package/src/chat/agent.ts +376 -0
- package/src/chat/appFront.ts +39 -0
- package/src/chat/auth.ts +433 -0
- package/src/chat/chores.ts +394 -0
- package/src/chat/connectors.ts +75 -0
- package/src/chat/jobs.ts +228 -0
- package/src/chat/lucyMotion.ts +33 -0
- package/src/chat/protocol.ts +192 -0
- package/src/chat/results.ts +224 -0
- package/src/chat/store.ts +87 -0
- package/src/chat/useDictation.ts +201 -0
- package/src/chat/useLucyChat.ts +458 -0
- package/src/chat/useMyComputer.ts +41 -0
- package/src/chat/whereLucyWorks.ts +97 -0
- package/src/chat/workspace.ts +127 -0
- package/src/components/.claude-flow/data/pending-insights.jsonl +3 -0
- package/src/components/AreaShot.tsx +239 -0
- package/src/components/Backdrops.tsx +323 -0
- package/src/components/BottomSheet.tsx +96 -0
- package/src/components/ChatSheets.tsx +565 -0
- package/src/components/ConnectorLogo.tsx +116 -0
- package/src/components/CustomDrawer.tsx +526 -0
- package/src/components/IdeasPane.tsx +318 -0
- package/src/components/ImessageSheet.tsx +280 -0
- package/src/components/KeyboardAvoider.tsx +45 -0
- package/src/components/Logo.tsx +97 -0
- package/src/components/LucyWorking.tsx +122 -0
- package/src/components/Markdown.tsx +219 -0
- package/src/components/Media.tsx +173 -0
- package/src/components/MessagesAppIcon.tsx +51 -0
- package/src/components/MicButton.tsx +92 -0
- package/src/components/ResultCards.tsx +1067 -0
- package/src/components/SignInPrompt.tsx +182 -0
- package/src/components/SignedOut.tsx +47 -0
- package/src/components/TalkToLucyHero.tsx +540 -0
- package/src/components/TalkToLucySheet.tsx +208 -0
- package/src/components/VoiceOrb.tsx +364 -0
- package/src/components/WhereLucyWorks.tsx +261 -0
- package/src/components/WorkspaceSection.tsx +307 -0
- package/src/components/YantraMark.tsx +30 -0
- package/src/components/drawerHeader.tsx +46 -0
- package/src/components/kit.tsx +309 -0
- package/src/components/lottieInstalled.ts +7 -0
- package/src/components/ui.tsx +700 -0
- package/src/components/useSignOut.ts +21 -0
- package/src/components/viewport.tsx +166 -0
- package/src/components/voiceDial.ts +45 -0
- package/src/compute.ts +168 -0
- package/src/config/env-config.ts +50 -0
- package/src/config/routes.ts +28 -0
- package/src/content.ts +217 -0
- package/src/hooks/keyboardCover.ts +70 -0
- package/src/hooks/useKeyboard.ts +135 -0
- package/src/hooks/useReducedMotion.ts +19 -0
- package/src/imessage/openMessages.ts +53 -0
- package/src/imessage/platform.ts +32 -0
- package/src/imessage/textLink.ts +307 -0
- package/src/index.ts +24 -0
- package/src/live/card.ts +62 -0
- package/src/live/liveActivity.ts +192 -0
- package/src/module.ts +8 -0
- package/src/offer/BlackFridayOffer.tsx +394 -0
- package/src/offer/blackFriday.ts +109 -0
- package/src/offer/parts.tsx +650 -0
- package/src/offer/state.ts +78 -0
- package/src/push/push.ts +171 -0
- package/src/push/usePushNotifications.ts +47 -0
- package/src/screens/Account/index.tsx +310 -0
- package/src/screens/Chat/.claude-flow/data/pending-insights.jsonl +4 -0
- package/src/screens/Chat/index.tsx +891 -0
- package/src/screens/Chores/index.tsx +35 -0
- package/src/screens/Connectors/index.tsx +35 -0
- package/src/screens/History/index.tsx +346 -0
- package/src/screens/Home/index.tsx +2776 -0
- package/src/screens/Home/media.ts +31 -0
- package/src/screens/Welcome/index.tsx +1182 -0
- package/src/talk/talkToLucy.ts +187 -0
- package/src/theme/colors.ts +38 -0
- package/src/theme/fonts.ts +30 -0
- package/src/theme/muse.ts +86 -0
- package/src/utils/links.ts +84 -0
- package/src/utils/yantraLinks.ts +94 -0
- package/src/welcome/flow.ts +418 -0
- package/src/welcome/haptics.ts +179 -0
- package/src/welcome/parts.tsx +2160 -0
- package/src/welcome/powerOn.ts +84 -0
- package/src/welcome/seen.ts +68 -0
- package/src/welcome/sound.ts +173 -0
- package/tools/lottie/chat.motion +0 -0
- package/tools/lottie/cloud.motion +0 -0
- package/tools/lottie/generate.mjs +1209 -0
- package/tools/lottie/inter-glyphs.json +4416 -0
- package/tools/lottie/lucy-mark-calendar.motion +0 -0
- package/tools/lottie/lucy-mark-call.motion +0 -0
- package/tools/lottie/lucy-mark-connect.motion +0 -0
- package/tools/lottie/lucy-mark-details.motion +0 -0
- package/tools/lottie/lucy-mark-email.motion +0 -0
- package/tools/lottie/lucy-mark-message.motion +0 -0
- package/tools/lottie/lucy-mark-search.motion +0 -0
- package/tools/lottie/lucy-mark-think.motion +0 -0
- package/tools/lottie/lucy-mark-write.motion +0 -0
- package/tools/lottie/mark.json +1 -0
- package/tools/lottie/mine-none.motion +0 -0
- package/tools/lottie/mine-offline.motion +0 -0
- package/tools/lottie/mine-online.motion +0 -0
- package/tools/lottie/time-back.mjs +604 -0
- package/tools/sounds/render.mjs +730 -0
- package/tsconfig.json +17 -0
- package/README.md +0 -3
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Black Friday, after sign-in: the page goes black from Home's own clock, the clock strikes midnight (a thud) and the
|
|
3
|
+
* offer writes itself in word by word (a tick each), counting down to Cyber Monday. Claim shows the celebration; Not
|
|
4
|
+
* now folds the black back into the chip Home keeps in its hero. OfferSheet is the same offer, smaller, when that chip
|
|
5
|
+
* is tapped. The pieces are offer/parts.tsx, the words and numbers offer/blackFriday.ts; the design is the Black Friday
|
|
6
|
+
* section of the Clockbook mobile canvas. Under Reduce Motion it fades in and out and nothing travels.
|
|
7
|
+
*/
|
|
8
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
9
|
+
import {
|
|
10
|
+
Animated,
|
|
11
|
+
Easing,
|
|
12
|
+
Modal,
|
|
13
|
+
Pressable,
|
|
14
|
+
StatusBar,
|
|
15
|
+
StyleSheet,
|
|
16
|
+
Text,
|
|
17
|
+
useWindowDimensions,
|
|
18
|
+
View,
|
|
19
|
+
} from 'react-native';
|
|
20
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
21
|
+
import { Ionicons } from '@expo/vector-icons';
|
|
22
|
+
import { BottomSheet } from '../components/BottomSheet';
|
|
23
|
+
import { useReducedMotion } from '../hooks/useReducedMotion';
|
|
24
|
+
import { fonts } from '../theme/fonts';
|
|
25
|
+
import { longDate, WORD_MS, words } from '../welcome/flow';
|
|
26
|
+
import { tap, thud } from '../welcome/haptics';
|
|
27
|
+
import { Burst, GlowButton, Reveal, Words } from '../welcome/parts';
|
|
28
|
+
import { endsAt, offerWords, timeLeft, type Offer } from './blackFriday';
|
|
29
|
+
import { Countdown, CreamButton, Ember, InkLink, ink, MidnightMark, Sparks, useNow } from './parts';
|
|
30
|
+
|
|
31
|
+
export interface Point {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const FLOOD_MS = 950;
|
|
37
|
+
const FOLD_MS = 560;
|
|
38
|
+
|
|
39
|
+
export function BlackFridayOffer({
|
|
40
|
+
visible,
|
|
41
|
+
mode,
|
|
42
|
+
offer,
|
|
43
|
+
origin,
|
|
44
|
+
target,
|
|
45
|
+
onClaim,
|
|
46
|
+
onClose,
|
|
47
|
+
}: {
|
|
48
|
+
visible: boolean;
|
|
49
|
+
/** 'offer' after sign-in; 'claimed' when it was claimed from Home's sheet. */
|
|
50
|
+
mode: 'offer' | 'claimed';
|
|
51
|
+
offer: Offer;
|
|
52
|
+
/** Where the black spreads from (Home's clock), and where Not now folds it back into (the chip's place). */
|
|
53
|
+
origin: Point | null;
|
|
54
|
+
target: Point | null;
|
|
55
|
+
onClaim: () => void;
|
|
56
|
+
onClose: () => void;
|
|
57
|
+
}) {
|
|
58
|
+
const { width, height } = useWindowDimensions();
|
|
59
|
+
const insets = useSafeAreaInsets();
|
|
60
|
+
const reduced = useReducedMotion();
|
|
61
|
+
const [mounted, setMounted] = useState(false);
|
|
62
|
+
const [screen, setScreen] = useState<'offer' | 'claimed'>(mode);
|
|
63
|
+
// A new run each time it opens, so its words and reveals play again.
|
|
64
|
+
const [run, setRun] = useState(0);
|
|
65
|
+
const flood = useRef(new Animated.Value(0)).current;
|
|
66
|
+
const fold = useRef(new Animated.Value(0)).current;
|
|
67
|
+
const fade = useRef(new Animated.Value(1)).current;
|
|
68
|
+
const leaving = useRef(false);
|
|
69
|
+
const now = useNow(1000, mounted && screen === 'offer');
|
|
70
|
+
const w = offerWords(offer.discount);
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!visible) {
|
|
74
|
+
setMounted(false);
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
leaving.current = false;
|
|
78
|
+
setScreen(mode);
|
|
79
|
+
setRun((r) => r + 1);
|
|
80
|
+
setMounted(true);
|
|
81
|
+
fold.setValue(0);
|
|
82
|
+
const opening = reduced
|
|
83
|
+
? Animated.timing(fade, { toValue: 1, duration: 260, useNativeDriver: true })
|
|
84
|
+
: Animated.timing(flood, {
|
|
85
|
+
toValue: 1,
|
|
86
|
+
duration: FLOOD_MS,
|
|
87
|
+
easing: Easing.bezier(0.7, 0, 0.2, 1),
|
|
88
|
+
useNativeDriver: true,
|
|
89
|
+
});
|
|
90
|
+
flood.setValue(reduced ? 1 : 0);
|
|
91
|
+
fade.setValue(reduced ? 0 : 1);
|
|
92
|
+
opening.start();
|
|
93
|
+
return () => opening.stop();
|
|
94
|
+
}, [visible, mode, reduced, flood, fold, fade]);
|
|
95
|
+
|
|
96
|
+
const o = origin ?? { x: width / 2, y: insets.top + 150 };
|
|
97
|
+
const t = target ?? o;
|
|
98
|
+
// Not now folds into the chip; after claiming, the black goes back into the clock.
|
|
99
|
+
const to = screen === 'claimed' ? o : t;
|
|
100
|
+
const R = Math.hypot(Math.max(o.x, width - o.x), Math.max(o.y, height - o.y)) + 24;
|
|
101
|
+
|
|
102
|
+
const leave = () => {
|
|
103
|
+
if (leaving.current) return;
|
|
104
|
+
leaving.current = true;
|
|
105
|
+
const out = Animated.timing(fade, { toValue: 0, duration: reduced ? 220 : 200, useNativeDriver: true });
|
|
106
|
+
if (reduced) {
|
|
107
|
+
out.start(() => onClose());
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const ease = Easing.bezier(0.55, 0, 0.35, 1);
|
|
111
|
+
Animated.sequence([
|
|
112
|
+
out,
|
|
113
|
+
Animated.parallel([
|
|
114
|
+
Animated.timing(flood, { toValue: 0, duration: FOLD_MS, easing: ease, useNativeDriver: true }),
|
|
115
|
+
Animated.timing(fold, { toValue: 1, duration: FOLD_MS, easing: ease, useNativeDriver: true }),
|
|
116
|
+
]),
|
|
117
|
+
]).start(() => onClose());
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const claim = () => {
|
|
121
|
+
onClaim();
|
|
122
|
+
setScreen('claimed');
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const compact = height < 760;
|
|
126
|
+
const markSize = compact ? 84 : 104;
|
|
127
|
+
const top = insets.top + (compact ? 30 : 52);
|
|
128
|
+
// When the black has reached the words; the rest follows the headline.
|
|
129
|
+
const base = reduced ? 0 : FLOOD_MS * 0.55;
|
|
130
|
+
const lineA = base + 560;
|
|
131
|
+
const lineB = lineA + 2 * WORD_MS + 60;
|
|
132
|
+
const after = lineB + 4 * WORD_MS + 200;
|
|
133
|
+
|
|
134
|
+
const offerScreen = (
|
|
135
|
+
<View style={StyleSheet.absoluteFill}>
|
|
136
|
+
<Ember width={width} top={height * 0.5} delay={base + 120} still={reduced} />
|
|
137
|
+
{reduced ? null : <Sparks width={width} height={height} delay={base + 500} />}
|
|
138
|
+
<Reveal delay={base + 420} still={reduced} style={[st.close, { top: insets.top + 6 }]}>
|
|
139
|
+
<Pressable
|
|
140
|
+
onPress={() => {
|
|
141
|
+
tap();
|
|
142
|
+
leave();
|
|
143
|
+
}}
|
|
144
|
+
hitSlop={8}
|
|
145
|
+
accessibilityRole="button"
|
|
146
|
+
accessibilityLabel="Close"
|
|
147
|
+
style={st.closeBtn}
|
|
148
|
+
>
|
|
149
|
+
<Ionicons name="close" size={20} color={ink.text} />
|
|
150
|
+
</Pressable>
|
|
151
|
+
</Reveal>
|
|
152
|
+
<View style={[st.body, { paddingTop: top }]}>
|
|
153
|
+
<MidnightMark size={markSize} delay={base} still={reduced} onStrike={thud} />
|
|
154
|
+
<Reveal delay={base + 380} still={reduced}>
|
|
155
|
+
<Text style={[st.eyebrow, compact && st.eyebrowCompact]}>Black Friday</Text>
|
|
156
|
+
</Reveal>
|
|
157
|
+
<View style={st.title} accessible accessibilityRole="header" accessibilityLabel={w.title.join(' ')}>
|
|
158
|
+
<Words
|
|
159
|
+
words={words(`*${w.title[0]}*`)}
|
|
160
|
+
label={w.title[0]}
|
|
161
|
+
start={lineA}
|
|
162
|
+
still={reduced}
|
|
163
|
+
style={[st.titleText, compact && st.titleCompact]}
|
|
164
|
+
accent={st.titleAccent}
|
|
165
|
+
center
|
|
166
|
+
/>
|
|
167
|
+
<Words
|
|
168
|
+
words={words(w.title[1])}
|
|
169
|
+
label={w.title[1]}
|
|
170
|
+
start={lineB}
|
|
171
|
+
still={reduced}
|
|
172
|
+
style={[st.titleText, compact && st.titleCompact]}
|
|
173
|
+
center
|
|
174
|
+
/>
|
|
175
|
+
</View>
|
|
176
|
+
<Reveal delay={after} still={reduced}>
|
|
177
|
+
<Text style={st.lead}>{w.lead}</Text>
|
|
178
|
+
</Reveal>
|
|
179
|
+
<Reveal delay={after + 180} still={reduced} style={[st.clockWrap, compact && st.clockCompact]}>
|
|
180
|
+
<Text style={st.caption}>Offer ends in</Text>
|
|
181
|
+
<Countdown left={timeLeft(now, offer.ends)} still={reduced} />
|
|
182
|
+
</Reveal>
|
|
183
|
+
</View>
|
|
184
|
+
<View style={[st.actions, { paddingBottom: insets.bottom + 12 }]}>
|
|
185
|
+
<Reveal delay={after + 360} still={reduced}>
|
|
186
|
+
<GlowButton variant="orange" label={w.claim} onPress={claim} />
|
|
187
|
+
</Reveal>
|
|
188
|
+
<Reveal delay={after + 460} still={reduced}>
|
|
189
|
+
<InkLink label="Not now" onPress={leave} />
|
|
190
|
+
</Reveal>
|
|
191
|
+
<Reveal delay={after + 540} still={reduced}>
|
|
192
|
+
<Text style={st.small}>{`${w.small} Ends ${endsAt(offer.ends)}.`}</Text>
|
|
193
|
+
</Reveal>
|
|
194
|
+
</View>
|
|
195
|
+
</View>
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const centre = top + 120;
|
|
199
|
+
const claimedScreen = (
|
|
200
|
+
<View style={StyleSheet.absoluteFill}>
|
|
201
|
+
<Ember width={width} top={centre - width * 0.82} still={reduced} />
|
|
202
|
+
<Burst centerY={centre} still={reduced} />
|
|
203
|
+
<View style={[st.claimedMark, { top: centre - 64, left: width / 2 - 64 }]}>
|
|
204
|
+
<MidnightMark size={128} struck still={reduced} />
|
|
205
|
+
</View>
|
|
206
|
+
<Reveal delay={650} still={reduced} style={[st.doneWrap, { top: centre + 150 }]}>
|
|
207
|
+
<Text style={st.doneTitle} accessibilityRole="header">
|
|
208
|
+
{w.claimed}
|
|
209
|
+
</Text>
|
|
210
|
+
</Reveal>
|
|
211
|
+
<Reveal delay={900} still={reduced} style={[st.doneWrap, { top: centre + 206 }]}>
|
|
212
|
+
<Text style={st.doneSub}>{w.claimedSub}</Text>
|
|
213
|
+
</Reveal>
|
|
214
|
+
<View style={[st.actions, { paddingBottom: insets.bottom + 18 }]}>
|
|
215
|
+
<Reveal delay={1150} still={reduced}>
|
|
216
|
+
<CreamButton label="Hand Lucy a chore" onPress={leave} />
|
|
217
|
+
</Reveal>
|
|
218
|
+
</View>
|
|
219
|
+
</View>
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<Modal visible={mounted} transparent animationType="none" statusBarTranslucent onRequestClose={leave}>
|
|
224
|
+
<StatusBar barStyle="light-content" />
|
|
225
|
+
<View style={StyleSheet.absoluteFill} accessibilityViewIsModal>
|
|
226
|
+
<Animated.View
|
|
227
|
+
pointerEvents="none"
|
|
228
|
+
style={[
|
|
229
|
+
st.flood,
|
|
230
|
+
{
|
|
231
|
+
left: o.x - R,
|
|
232
|
+
top: o.y - R,
|
|
233
|
+
width: R * 2,
|
|
234
|
+
height: R * 2,
|
|
235
|
+
borderRadius: R,
|
|
236
|
+
opacity: reduced ? fade : 1,
|
|
237
|
+
transform: [
|
|
238
|
+
{ translateX: fold.interpolate({ inputRange: [0, 1], outputRange: [0, to.x - o.x] }) },
|
|
239
|
+
{ translateY: fold.interpolate({ inputRange: [0, 1], outputRange: [0, to.y - o.y] }) },
|
|
240
|
+
{ scale: flood.interpolate({ inputRange: [0, 1], outputRange: [0.002, 1] }) },
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
]}
|
|
244
|
+
/>
|
|
245
|
+
<Animated.View key={run} style={[StyleSheet.absoluteFill, { opacity: fade }]}>
|
|
246
|
+
{screen === 'offer' ? offerScreen : claimedScreen}
|
|
247
|
+
</Animated.View>
|
|
248
|
+
</View>
|
|
249
|
+
</Modal>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** The offer again, smaller, from Home's chip: the same Ink, over the page. */
|
|
254
|
+
export function OfferSheet({
|
|
255
|
+
visible,
|
|
256
|
+
offer,
|
|
257
|
+
onClaim,
|
|
258
|
+
onClose,
|
|
259
|
+
}: {
|
|
260
|
+
visible: boolean;
|
|
261
|
+
offer: Offer;
|
|
262
|
+
onClaim: () => void;
|
|
263
|
+
onClose: () => void;
|
|
264
|
+
}) {
|
|
265
|
+
const insets = useSafeAreaInsets();
|
|
266
|
+
const reduced = useReducedMotion();
|
|
267
|
+
const now = useNow(1000, visible);
|
|
268
|
+
const w = offerWords(offer.discount);
|
|
269
|
+
return (
|
|
270
|
+
<BottomSheet
|
|
271
|
+
visible={visible}
|
|
272
|
+
onClose={onClose}
|
|
273
|
+
style={[st.sheet, { marginBottom: Math.max(insets.bottom, 8) }]}
|
|
274
|
+
>
|
|
275
|
+
<View style={st.grab} />
|
|
276
|
+
<View style={st.sheetHead}>
|
|
277
|
+
<MidnightMark size={44} struck still={reduced} />
|
|
278
|
+
<View style={st.sheetHeadText}>
|
|
279
|
+
<Text style={st.sheetKicker}>Black Friday</Text>
|
|
280
|
+
<Text style={st.sheetWhen}>{`Ends ${longDate(offer.ends)}`}</Text>
|
|
281
|
+
</View>
|
|
282
|
+
<Pressable
|
|
283
|
+
onPress={() => {
|
|
284
|
+
tap();
|
|
285
|
+
onClose();
|
|
286
|
+
}}
|
|
287
|
+
hitSlop={8}
|
|
288
|
+
accessibilityRole="button"
|
|
289
|
+
accessibilityLabel="Close"
|
|
290
|
+
style={st.closeBtn}
|
|
291
|
+
>
|
|
292
|
+
<Ionicons name="close" size={18} color={ink.text} />
|
|
293
|
+
</Pressable>
|
|
294
|
+
</View>
|
|
295
|
+
<Text style={st.sheetTitle} accessibilityRole="header">
|
|
296
|
+
<Text style={st.titleAccent}>{w.title[0]}</Text>
|
|
297
|
+
{`\n${w.title[1]}`}
|
|
298
|
+
</Text>
|
|
299
|
+
<View style={st.sheetClock}>
|
|
300
|
+
<Countdown left={timeLeft(now, offer.ends)} small still={reduced} />
|
|
301
|
+
</View>
|
|
302
|
+
<GlowButton variant="orange" label={w.claim} onPress={onClaim} />
|
|
303
|
+
<InkLink label="Not now" onPress={onClose} />
|
|
304
|
+
<Text style={st.small}>{w.small}</Text>
|
|
305
|
+
</BottomSheet>
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const st = StyleSheet.create({
|
|
310
|
+
flood: { position: 'absolute', backgroundColor: ink.bg },
|
|
311
|
+
close: { position: 'absolute', right: 16, zIndex: 2 },
|
|
312
|
+
closeBtn: {
|
|
313
|
+
width: 40,
|
|
314
|
+
height: 40,
|
|
315
|
+
borderRadius: 20,
|
|
316
|
+
backgroundColor: 'rgba(255,255,255,0.1)',
|
|
317
|
+
alignItems: 'center',
|
|
318
|
+
justifyContent: 'center',
|
|
319
|
+
},
|
|
320
|
+
body: { alignItems: 'center', paddingHorizontal: 28 },
|
|
321
|
+
eyebrow: {
|
|
322
|
+
marginTop: 26,
|
|
323
|
+
fontFamily: fonts.sansSemi,
|
|
324
|
+
fontSize: 12.5,
|
|
325
|
+
letterSpacing: 3,
|
|
326
|
+
color: ink.accent,
|
|
327
|
+
textTransform: 'uppercase',
|
|
328
|
+
},
|
|
329
|
+
eyebrowCompact: { marginTop: 18 },
|
|
330
|
+
title: { marginTop: 12, alignItems: 'center' },
|
|
331
|
+
titleText: { fontFamily: fonts.serif, fontSize: 50, lineHeight: 53, letterSpacing: -0.8, color: ink.text },
|
|
332
|
+
titleCompact: { fontSize: 42, lineHeight: 45 },
|
|
333
|
+
titleAccent: { color: ink.accent },
|
|
334
|
+
lead: {
|
|
335
|
+
marginTop: 16,
|
|
336
|
+
maxWidth: 320,
|
|
337
|
+
fontFamily: fonts.sans,
|
|
338
|
+
fontSize: 16,
|
|
339
|
+
lineHeight: 23,
|
|
340
|
+
color: ink.text2,
|
|
341
|
+
textAlign: 'center',
|
|
342
|
+
},
|
|
343
|
+
clockWrap: { marginTop: 26, alignItems: 'center', rowGap: 12 },
|
|
344
|
+
clockCompact: { marginTop: 18 },
|
|
345
|
+
caption: { fontFamily: fonts.sansMedium, fontSize: 12.5, letterSpacing: 0.5, color: ink.muted },
|
|
346
|
+
actions: { position: 'absolute', left: 24, right: 24, bottom: 0, rowGap: 4 },
|
|
347
|
+
small: {
|
|
348
|
+
marginTop: 2,
|
|
349
|
+
fontFamily: fonts.sans,
|
|
350
|
+
fontSize: 12,
|
|
351
|
+
lineHeight: 18,
|
|
352
|
+
color: ink.text2,
|
|
353
|
+
textAlign: 'center',
|
|
354
|
+
},
|
|
355
|
+
claimedMark: { position: 'absolute', width: 128, height: 128 },
|
|
356
|
+
doneWrap: { position: 'absolute', left: 32, right: 32 },
|
|
357
|
+
doneTitle: {
|
|
358
|
+
fontFamily: fonts.serif,
|
|
359
|
+
fontSize: 42,
|
|
360
|
+
lineHeight: 46,
|
|
361
|
+
letterSpacing: -0.6,
|
|
362
|
+
color: ink.text,
|
|
363
|
+
textAlign: 'center',
|
|
364
|
+
},
|
|
365
|
+
doneSub: { fontFamily: fonts.sans, fontSize: 16, lineHeight: 23, color: ink.text2, textAlign: 'center' },
|
|
366
|
+
sheet: {
|
|
367
|
+
marginHorizontal: 8,
|
|
368
|
+
borderRadius: 36,
|
|
369
|
+
backgroundColor: ink.surface,
|
|
370
|
+
paddingHorizontal: 20,
|
|
371
|
+
paddingTop: 10,
|
|
372
|
+
paddingBottom: 16,
|
|
373
|
+
},
|
|
374
|
+
grab: { alignSelf: 'center', width: 38, height: 5, borderRadius: 3, backgroundColor: ink.line2, marginBottom: 14 },
|
|
375
|
+
sheetHead: { flexDirection: 'row', alignItems: 'center', columnGap: 12 },
|
|
376
|
+
sheetHeadText: { flex: 1 },
|
|
377
|
+
sheetKicker: {
|
|
378
|
+
fontFamily: fonts.sansSemi,
|
|
379
|
+
fontSize: 12,
|
|
380
|
+
letterSpacing: 2.6,
|
|
381
|
+
color: ink.accent,
|
|
382
|
+
textTransform: 'uppercase',
|
|
383
|
+
},
|
|
384
|
+
sheetWhen: { marginTop: 5, fontFamily: fonts.sansMedium, fontSize: 13.5, color: ink.text2 },
|
|
385
|
+
sheetTitle: {
|
|
386
|
+
marginTop: 18,
|
|
387
|
+
fontFamily: fonts.serif,
|
|
388
|
+
fontSize: 38,
|
|
389
|
+
lineHeight: 41,
|
|
390
|
+
letterSpacing: -0.6,
|
|
391
|
+
color: ink.text,
|
|
392
|
+
},
|
|
393
|
+
sheetClock: { marginTop: 18, marginBottom: 20 },
|
|
394
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clockbook's Black Friday offer as data and arithmetic: what it is, when it runs, and the words and numbers its screens
|
|
3
|
+
* show. offer/BlackFridayOffer.tsx draws it, offer/state.ts remembers it, and Home shows it once to a signed-in person,
|
|
4
|
+
* then keeps a chip in its hero until it ends or is claimed. The design is the Black Friday section of the Clockbook
|
|
5
|
+
* mobile canvas.
|
|
6
|
+
*/
|
|
7
|
+
import { longDate } from '../welcome/flow';
|
|
8
|
+
|
|
9
|
+
export interface Offer {
|
|
10
|
+
/** Names what the phone remembers about it (offer/state.ts). */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Percent off the first year. */
|
|
13
|
+
discount: number;
|
|
14
|
+
/** It runs from the first second of `starts` to the last of `ends`, in the phone's own time zone. */
|
|
15
|
+
starts: Date;
|
|
16
|
+
ends: Date;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Black Friday, Friday 27 November, through Cyber Monday, Monday 30 November 2026. */
|
|
20
|
+
export const BLACK_FRIDAY: Offer = {
|
|
21
|
+
id: 'black-friday-2026',
|
|
22
|
+
discount: 50,
|
|
23
|
+
starts: new Date(2026, 10, 27, 0, 0, 0),
|
|
24
|
+
ends: new Date(2026, 10, 30, 23, 59, 59),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether the offer shows at `now`: in a build that shows offers (`on`), not past its last second, and begun, unless
|
|
29
|
+
* `early` (a development or test build checking it before it starts).
|
|
30
|
+
*/
|
|
31
|
+
export function offerShows(now: Date, offer: Offer, { on, early }: { on: boolean; early: boolean }): boolean {
|
|
32
|
+
if (!on) return false;
|
|
33
|
+
const t = now.getTime();
|
|
34
|
+
if (t > offer.ends.getTime()) return false;
|
|
35
|
+
return early || t >= offer.starts.getTime();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Left {
|
|
39
|
+
ms: number;
|
|
40
|
+
days: number;
|
|
41
|
+
hours: number;
|
|
42
|
+
minutes: number;
|
|
43
|
+
seconds: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** What is left until `ends`, never less than nothing. */
|
|
47
|
+
export function timeLeft(now: Date, ends: Date): Left {
|
|
48
|
+
const ms = Math.max(0, ends.getTime() - now.getTime());
|
|
49
|
+
return {
|
|
50
|
+
ms,
|
|
51
|
+
days: Math.floor(ms / 86_400_000),
|
|
52
|
+
hours: Math.floor(ms / 3_600_000) % 24,
|
|
53
|
+
minutes: Math.floor(ms / 60_000) % 60,
|
|
54
|
+
seconds: Math.floor(ms / 1_000) % 60,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const two = (n: number) => String(n).padStart(2, '0');
|
|
59
|
+
|
|
60
|
+
/** The countdown's four tiles. */
|
|
61
|
+
export function countdownTiles(left: Left): { value: string; unit: string }[] {
|
|
62
|
+
return [
|
|
63
|
+
{ value: two(left.days), unit: 'Days' },
|
|
64
|
+
{ value: two(left.hours), unit: 'Hrs' },
|
|
65
|
+
{ value: two(left.minutes), unit: 'Min' },
|
|
66
|
+
{ value: two(left.seconds), unit: 'Sec' },
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** What is left, briefly, for Home's chip: "11d 13h left", in the last day "3h 20m left", in the last hour "20m left". */
|
|
71
|
+
export function leftShort(left: Left): string {
|
|
72
|
+
if (left.days > 0) return `${left.days}d ${left.hours}h left`;
|
|
73
|
+
if (left.hours > 0) return `${left.hours}h ${left.minutes}m left`;
|
|
74
|
+
return `${Math.max(1, left.minutes)}m left`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const count = (n: number, one: string) => `${n} ${one}${n === 1 ? '' : 's'}`;
|
|
78
|
+
|
|
79
|
+
/** What is left, in words, for a screen reader: "Ends in 11 days, 13 hours and 20 minutes." */
|
|
80
|
+
export function leftSentence(left: Left): string {
|
|
81
|
+
const parts: string[] = [];
|
|
82
|
+
if (left.days > 0) parts.push(count(left.days, 'day'));
|
|
83
|
+
if (left.days > 0 || left.hours > 0) parts.push(count(left.hours, 'hour'));
|
|
84
|
+
parts.push(count(left.minutes, 'minute'));
|
|
85
|
+
const said = parts.length > 1 ? `${parts.slice(0, -1).join(', ')} and ${parts[parts.length - 1]}` : parts[0];
|
|
86
|
+
return `Ends in ${said}.`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** When it ends, for the small print: "Monday, November 30 at 11:59 PM". */
|
|
90
|
+
export function endsAt(ends: Date): string {
|
|
91
|
+
const h = ends.getHours();
|
|
92
|
+
return `${longDate(ends)} at ${((h + 11) % 12) + 1}:${two(ends.getMinutes())} ${h < 12 ? 'AM' : 'PM'}`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The offer's words for its discount: "Half off" reads better than "50% off" in the headline. */
|
|
96
|
+
export function offerWords(discount: number) {
|
|
97
|
+
const off = `${discount}% off`;
|
|
98
|
+
const half = discount === 50;
|
|
99
|
+
return {
|
|
100
|
+
off,
|
|
101
|
+
/** The headline's two lines, the first in orange. */
|
|
102
|
+
title: [half ? 'Half off' : off, 'a year of Lucy.'] as [string, string],
|
|
103
|
+
lead: `Hand Lucy the calls, the bills and the bookings for a whole year, at ${half ? 'half the price' : off}.`,
|
|
104
|
+
claim: `Claim ${off}`,
|
|
105
|
+
claimed: `${half ? 'Half price' : off}, locked in.`,
|
|
106
|
+
claimedSub: `Your first year of Lucy is ${off}. She’s ready when you are.`,
|
|
107
|
+
small: `${off} your first year. Cancel anytime.`,
|
|
108
|
+
};
|
|
109
|
+
}
|