From 7024269bf6ca3eb65c1a30e6a1dad1aa3fb7b233 Mon Sep 17 00:00:00 2001 From: Mehboob Khan Date: Wed, 2 Sep 2026 19:06:53 +0500 Subject: [PATCH] Add family safe-zone location demo, wire into Mobile SDK demo slider Cinematic 30s player showing safe-zone creation and leave-zone alerts, matching the existing threat-demo pattern. Added as a 6th rotating slide in ThreatDemosSlider (live on /mobile-sdk and /threat-demos), plus a standalone /location-demo route for recording. Co-Authored-By: Claude Sonnet 5 --- src/demo/location/LocationDemo.tsx | 562 +++++++++++++++++++++++++ src/demo/threats/ThreatDemosSlider.tsx | 44 +- src/main.tsx | 3 + 3 files changed, 599 insertions(+), 10 deletions(-) create mode 100644 src/demo/location/LocationDemo.tsx diff --git a/src/demo/location/LocationDemo.tsx b/src/demo/location/LocationDemo.tsx new file mode 100644 index 0000000..bb45855 --- /dev/null +++ b/src/demo/location/LocationDemo.tsx @@ -0,0 +1,562 @@ +import { useEffect, useRef, useState } from 'react' +import { useNavigate } from 'react-router-dom' +import { AnimatePresence, motion } from 'framer-motion' +import { + IconHome, IconUsers, IconApps, IconSliders, IconBell, + IconPin, IconSchool, IconChild, IconCheck, IconAlert, IconPlus, IconMap, +} from '../components/Icons' +import '../demo.css' + +const EASE_OUT = [0.23, 1, 0.32, 1] as const +const SPRING = { type: 'spring', stiffness: 340, damping: 28 } as const +const PHONE_SCALE = 0.88 + +const T = { + bg: '#013B49', + bgGrad: 'radial-gradient(140% 90% at 50% 0%, #075466 0%, #013B49 55%, #01303b 100%)', + surface2: 'rgba(255,255,255,0.07)', + surface3: 'rgba(255,255,255,0.10)', + surfaceStr: '#0a4856', + border: 'rgba(255,255,255,0.09)', + text: '#e8f4f3', + text2: '#b9cdd1', + muted: '#8aa5ab', + dim: '#5a7a82', + accent: '#3BB586', + accentSoft: 'rgba(59,181,134,0.16)', + accentGlow: 'rgba(59,181,134,0.30)', + danger: '#ff6b6b', + dangerSoft: 'rgba(255,107,107,0.16)', + warn: '#ffb56b', + warnSoft: 'rgba(255,181,107,0.16)', + success: '#4ec99a', + successSoft: 'rgba(78,201,154,0.16)', +} + +// ── Timeline (30s total) ───────────────────────────────────────────────────── +// P1 Live map (calm) → P2 Draw a safe zone → P3 Zone saved → P4 Jack leaves the +// zone → P5 Alert detail → P6 Resolution → P7 Book-a-demo end card +const PHASES = { + p1: 3500, + p2: 8500, + p3: 11500, + p4: 18500, + p5: 23500, + p6: 27000, + total: 30000, +} + +function phaseOf(elapsed: number): number { + if (elapsed < PHASES.p1) return 1 + if (elapsed < PHASES.p2) return 2 + if (elapsed < PHASES.p3) return 3 + if (elapsed < PHASES.p4) return 4 + if (elapsed < PHASES.p5) return 5 + if (elapsed < PHASES.p6) return 6 + return 7 +} + +const PHASE_LABEL = ['', 'Live Map', 'Safe Zone', 'Zone Saved', 'Leaving Zone', 'Alert', 'Resolved', 'Book a Demo'] + +const VO_CUES = [ + { at: 300, text: 'Parents can see exactly where their family is, right from the app.' }, + { at: 3800, text: 'Creating a safe zone takes seconds — drop a pin, and draw the boundary.' }, + { at: 8800, text: 'Once it’s saved, we keep watch over that boundary, day and night.' }, + { at: 11800, text: 'The moment Jack leaves the Park zone, we notify the parent immediately.' }, + { at: 23800, text: 'One tap shows exactly where he is — peace of mind, one message away. Book a demo today.' }, +] + +const TABS = [ + { Icon: IconHome, label: 'Home' }, + { Icon: IconUsers, label: 'Family' }, + { Icon: IconMap, label: 'Map' }, + { Icon: IconSliders, label: 'Controls' }, + { Icon: IconBell, label: 'Alerts' }, +] as const + +function HexLogo({ size = 52 }: { size?: number }) { + return ( + + + + + + + + + + ) +} + +function EndCard() { + return ( + + + +
+
+
+
BlackDice
+
Powered by BlackDice
+
+ + Book a Demo + + blackdice.com +
+ ) +} + +// ── Map scene (phases 1–4) ─────────────────────────────────────────────────── +function MapScene({ elapsed, phase }: { elapsed: number; phase: number }) { + const drawing = phase === 2 + const pinDropped = elapsed >= 4100 + const circleOut = elapsed >= 4900 + const labelTyped = elapsed >= 6300 + const saveShown = elapsed >= 7500 + const saveTapped = elapsed >= 8000 + const zoneSaved = elapsed >= PHASES.p2 + const walking = elapsed >= 11800 + const breached = elapsed >= 14800 + const alerted = elapsed >= 15200 + + const dotLeft = walking ? '61%' : '60%' + const dotTop = walking ? '75%' : '57%' + + const zoneName = 'Park' + + return ( +
+ {/* stylised map base */} + + + + + + + + + + + + + + + + + + {/* safe-zone boundary */} + + + + {/* Home pin */} + +
+ +
+ Home +
+ + {/* School pin */} + +
+ +
+ School +
+ + {/* drop-pin during drawing */} + + {drawing && pinDropped && ( + + + + )} + + + {/* Jack (family member) dot */} + {(phase >= 3) && ( + + + + + + )} + + {/* Header chip */} +
+ + {drawing ? 'Add a safe zone' : 'Family · Live map'} + +
+ + {/* Zone label input while drawing */} + + {drawing && circleOut && ( + + + + {labelTyped + ? zoneName.split('').map((c, i) => ( + {c} + )) + : Zone name…} + + + )} + + + {/* Save button while drawing */} + + {drawing && saveShown && ( + + + Save safe zone + + + )} + + + {/* Saved confirmation card (phase 3) */} + + {phase === 3 && ( + +
+
+ +
+ Park · 200m radius +
+
Monitoring on · Arrive & leave alerts
+
+ )} +
+ + {/* Time chip during the leaving-zone phase */} + + {phase === 4 && ( + + Later · 2:47 PM + + )} + + + {/* Notification banner */} + + {alerted && phase === 4 && ( + + + + +
+ Jack left Park + 202 Meadow Rd · 2:47 PM +
+
+ )} +
+
+ ) +} + +function DetailContent({ tapped }: { tapped: boolean }) { + return ( + +
+ ‹ + Alert details +
+ +
+
+ +
+
Jack left Park
+
2:47 PM · 0.4 mi from zone centre
+
+ +
+ {[ + 'Left the Park safe-zone boundary', + 'Live location updating every 30 seconds', + 'You’ll be notified again if he returns', + ].map((line, i) => ( + + {line} + + ))} +
+ +
+ + 💬 Message Jack + +
+ 📍 View live location +
+
+
+ ) +} + +function ResolutionContent() { + return ( + + + + + +
Message sent
+
Jack confirmed he’s walking home
+
+ + + ›Jack · 🟢 will re-enter Home zone in 8 min + +
+ ) +} + +function LocationPhone({ elapsed, phase }: { elapsed: number; phase: number }) { + const tapped = elapsed >= PHASES.p4 + 2600 + return ( +
+
+ {phase <= 4 && } + {phase === 5 &&
} + {phase >= 6 && phase < 7 &&
} + + {/* status bar */} +
+ 9:415G  ▲ 100% +
+ {/* dynamic island */} +
+ + {phase <= 4 && ( +
+ {TABS.map((t, i) => ( +
+ {t.label} +
+ ))} + {phase === 1 && ( + + + + )} +
+ )} + + {phase >= 7 && } + +
+
+
+ ) +} + +// ── Cinematic player ───────────────────────────────────────────────────────── +export function LocationCinematic({ autoPlay = false, chrome = true, bare = false }: { + autoPlay?: boolean; chrome?: boolean; bare?: boolean +}) { + const [elapsed, setElapsed] = useState(0) + const [started, setStarted] = useState(false) + const [muted, setMuted] = useState(false) + const rafRef = useRef(0) + const t0Ref = useRef(0) + const spokenIdx = useRef(0) + + const phase = phaseOf(elapsed) + const cancelSpeech = () => { try { window.speechSynthesis && window.speechSynthesis.cancel() } catch { /* noop */ } } + + function start() { + setStarted(true) + t0Ref.current = performance.now() - elapsed + const tick = () => { + const now = performance.now() - t0Ref.current + setElapsed(now) + if (now < PHASES.total) rafRef.current = requestAnimationFrame(tick) + else setStarted(false) + } + rafRef.current = requestAnimationFrame(tick) + } + function pause() { setStarted(false); cancelAnimationFrame(rafRef.current); cancelSpeech() } + + useEffect(() => { + if (!autoPlay) return + const id = setTimeout(() => start(), 450) + return () => clearTimeout(id) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) + + useEffect(() => () => { cancelAnimationFrame(rafRef.current); cancelSpeech() }, []) + + useEffect(() => { + if (muted) cancelSpeech() + }, [muted]) + + // Voiceover — fires each cue once elapsed crosses its `at` threshold + useEffect(() => { + if (!started || muted) return + if (spokenIdx.current >= VO_CUES.length) return + const cue = VO_CUES[spokenIdx.current] + if (elapsed < cue.at) return + spokenIdx.current += 1 + const synth = window.speechSynthesis + if (!synth) return + + const speakNow = () => { + synth.cancel() + const u = new SpeechSynthesisUtterance(cue.text) + u.lang = 'en-GB'; u.rate = 0.82; u.pitch = 0.84; u.volume = 0.75 + u.onerror = () => {} + const vs = synth.getVoices() + const v = vs.find((x) => /en-GB/i.test(x.lang) && /natural|neural|online/i.test(x.name) && /libby|sonia|hazel|serena/i.test(x.name)) + || vs.find((x) => /en-GB/i.test(x.lang) && /natural|neural|online/i.test(x.name)) + || vs.find((x) => /en-GB/i.test(x.lang) && /libby|sonia|hazel|serena/i.test(x.name)) + || vs.find((x) => /en-GB/i.test(x.lang) && /female|google uk english female|samantha/i.test(x.name)) + || vs.find((x) => /en-GB/i.test(x.lang)) + || vs.find((x) => /^en/i.test(x.lang)) + if (v) u.voice = v + synth.speak(u) + } + + if (synth.getVoices().length === 0) { + const onReady = () => { synth.removeEventListener('voiceschanged', onReady); speakNow() } + synth.addEventListener('voiceschanged', onReady) + } else { + speakNow() + } + }, [elapsed, started, muted]) + + const curVo = VO_CUES.slice().reverse().find((c) => elapsed >= c.at) + + return ( +
+ {!bare && ( +
+ )} + + {chrome && ( +
+ SDK · LOCATION + + {PHASE_LABEL[phase]} +
+ )} + + {started && chrome && ( +
+ + REC +
+ )} + +
+
+ + + (started ? pause() : start())} + style={{ position: 'relative', width: 275 * PHONE_SCALE, height: 600 * PHONE_SCALE, cursor: 'pointer' }}> +
+
+ +
+ { e.stopPropagation(); setMuted((m) => !m) }} + title={muted ? 'Unmute' : 'Mute'} + style={{ + position: 'absolute', top: 16, right: 16, zIndex: 55, + width: 32, height: 32, borderRadius: '50%', + background: 'rgba(0,0,0,.45)', backdropFilter: 'blur(10px)', + border: `1px solid ${muted ? 'rgba(255,255,255,.16)' : T.accentGlow}`, + color: muted ? 'rgba(255,255,255,.7)' : T.accent, fontSize: 13, + cursor: 'pointer', fontFamily: 'inherit', + display: 'flex', alignItems: 'center', justifyContent: 'center', + }}> + {muted ? '🔇' : '🔊'} + + + + + +
+ + + {curVo?.text} + + +
+
+
+
+ ) +} + +// Default export: full-screen single player (mirrors /threat-demo/:id) +export default function LocationDemo() { + const navigate = useNavigate() + return ( +
+ + +
+ ) +} diff --git a/src/demo/threats/ThreatDemosSlider.tsx b/src/demo/threats/ThreatDemosSlider.tsx index 37db1da..b5d9a2a 100644 --- a/src/demo/threats/ThreatDemosSlider.tsx +++ b/src/demo/threats/ThreatDemosSlider.tsx @@ -1,12 +1,34 @@ import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { AnimatePresence, motion } from 'framer-motion' -import { THREAT_SCENARIOS } from './scenarios' +import { THREAT_SCENARIOS, type ThreatScenario } from './scenarios' import { ThreatCinematic } from './ThreatDemo' +import { LocationCinematic } from '../location/LocationDemo' import '../demo.css' const ACCENT = '#3BB586' +// The slider mixes the threat-detection scenarios with the location/geofencing +// demo, which has its own timeline and player rather than a ThreatScenario shape. +type DemoSlide = + | { kind: 'threat'; scenario: ThreatScenario } + | { kind: 'location' } + +const DEMO_SLIDES: DemoSlide[] = [ + ...THREAT_SCENARIOS.map((scenario) => ({ kind: 'threat' as const, scenario })), + { kind: 'location' }, +] + +function slideId(s: DemoSlide): string { + return s.kind === 'threat' ? s.scenario.id : 'location' +} +function slideTitle(s: DemoSlide): string { + return s.kind === 'threat' ? s.scenario.title : 'Family Safe Zones' +} +function slideProduct(s: DemoSlide): string { + return s.kind === 'threat' ? s.scenario.product : 'Mobile SDK' +} + // Isolated so useNavigate() is only ever invoked when this is actually mounted // under a — the embedded (no-router) instance never renders it. function BackToSiteButton() { @@ -19,8 +41,8 @@ function BackToSiteButton() { export default function ThreatDemosSlider({ embedded = false }: { embedded?: boolean } = {}) { const [idx, setIdx] = useState(0) const [dir, setDir] = useState(1) - const scenario = THREAT_SCENARIOS[idx] - const n = THREAT_SCENARIOS.length + const slide = DEMO_SLIDES[idx] + const n = DEMO_SLIDES.length const go = (next: number) => { setDir(next > idx ? 1 : -1) @@ -35,8 +57,8 @@ export default function ThreatDemosSlider({ embedded = false }: { embedded?: boo
-
{scenario.title}
-
{idx + 1} / {n} · {scenario.product}
+
{slideTitle(slide)}
+
{idx + 1} / {n} · {slideProduct(slide)}
@@ -49,14 +71,16 @@ export default function ThreatDemosSlider({ embedded = false }: { embedded?: boo
0 ? '100%' : '-100%' }} animate={{ x: 0 }} exit={{ x: dir > 0 ? '-100%' : '100%' }} transition={{ type: 'spring', stiffness: 260, damping: 30 }} style={{ position: 'absolute', inset: 0 }}> - + {slide.kind === 'threat' + ? + : } @@ -67,8 +91,8 @@ export default function ThreatDemosSlider({ embedded = false }: { embedded?: boo {/* ── Bottom: scenario tabs (reserved) — moves above the stage on mobile via .bd-demo-tabs media query ── */}
- {THREAT_SCENARIOS.map((s, i) => ( - ))}
diff --git a/src/main.tsx b/src/main.tsx index ed4cfc0..d37856e 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -11,6 +11,7 @@ const DemoScreen = React.lazy(() => import('./demo/DemoScreen')) const DemoVideoPage = React.lazy(() => import('./demo/DemoVideoPage')) const ThreatDemosSlider = React.lazy(() => import('./demo/threats/ThreatDemosSlider')) const ThreatDemoPlayerPage = React.lazy(() => import('./demo/threats/ThreatDemoPlayerPage')) +const LocationDemo = React.lazy(() => import('./demo/location/LocationDemo')) const AdminApp = React.lazy(() => import('./cms/admin/AdminApp')) function ArticleRoute() { @@ -26,6 +27,8 @@ ReactDOM.createRoot(document.getElementById('root')!).render( {/* Threat-detection demo slider + per-scenario players */} } /> } /> + {/* Location / geofencing demo — safe-zone creation + leave-zone alert */} + } /> {/* Cinematic product video — its own page */} } /> {/* Full interactive demo player (Flows A–D, ?mode=video) */}