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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 <Router> — 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
|
||||
<div style={{ flexShrink: 0, height: 60, display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '0 20px', borderBottom: '1px solid rgba(255,255,255,.06)', background: 'rgba(1,14,20,.7)', backdropFilter: 'blur(10px)', zIndex: 80 }}>
|
||||
<BackToSiteButton />
|
||||
<div style={{ textAlign: 'center', color: '#e8f4f3', minWidth: 0 }}>
|
||||
<div style={{ fontSize: 14, fontWeight: 600, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{scenario.title}</div>
|
||||
<div style={{ fontSize: 10.5, color: '#8aa5ab' }}>{idx + 1} / {n} · {scenario.product}</div>
|
||||
<div style={{ fontSize: 14, fontWeight: 600, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{slideTitle(slide)}</div>
|
||||
<div style={{ fontSize: 10.5, color: '#8aa5ab' }}>{idx + 1} / {n} · {slideProduct(slide)}</div>
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, background: 'rgba(0,0,0,.4)', border: '1px solid rgba(255,255,255,.1)', borderRadius: 100, padding: '5px 11px', flexShrink: 0 }}>
|
||||
<motion.span animate={{ opacity: [1, 0, 1] }} transition={{ duration: 1.2, repeat: Infinity }} style={{ width: 7, height: 7, borderRadius: '50%', background: '#ef4444', display: 'inline-block' }} />
|
||||
@@ -49,14 +71,16 @@ export default function ThreatDemosSlider({ embedded = false }: { embedded?: boo
|
||||
<div style={{ position: 'relative', flex: 1, minHeight: 0, overflow: 'hidden' }}>
|
||||
<AnimatePresence initial={false} custom={dir} mode="popLayout">
|
||||
<motion.div
|
||||
key={scenario.id}
|
||||
key={slideId(slide)}
|
||||
custom={dir}
|
||||
initial={{ x: dir > 0 ? '100%' : '-100%' }}
|
||||
animate={{ x: 0 }}
|
||||
exit={{ x: dir > 0 ? '-100%' : '100%' }}
|
||||
transition={{ type: 'spring', stiffness: 260, damping: 30 }}
|
||||
style={{ position: 'absolute', inset: 0 }}>
|
||||
<ThreatCinematic scenario={scenario} autoPlay={!embedded} chrome={false} />
|
||||
{slide.kind === 'threat'
|
||||
? <ThreatCinematic scenario={slide.scenario} autoPlay={!embedded} chrome={false} />
|
||||
: <LocationCinematic autoPlay={!embedded} chrome={false} />}
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
|
||||
@@ -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 ── */}
|
||||
<div className="bd-demo-tabs" style={{ flexShrink: 0, minHeight: 56, display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8, flexWrap: 'wrap', padding: '10px 16px', borderTop: '1px solid rgba(255,255,255,.06)', background: 'rgba(1,14,20,.7)', backdropFilter: 'blur(10px)', zIndex: 80 }}>
|
||||
{THREAT_SCENARIOS.map((s, i) => (
|
||||
<button key={s.id} onClick={() => go(i)}
|
||||
{DEMO_SLIDES.map((s, i) => (
|
||||
<button key={slideId(s)} onClick={() => go(i)}
|
||||
style={{
|
||||
fontFamily: 'inherit', fontSize: 11, fontWeight: 500, cursor: 'pointer',
|
||||
padding: '6px 12px', borderRadius: 100,
|
||||
@@ -76,7 +100,7 @@ export default function ThreatDemosSlider({ embedded = false }: { embedded?: boo
|
||||
background: i === idx ? 'rgba(59,181,134,0.18)' : 'rgba(255,255,255,.03)',
|
||||
color: i === idx ? ACCENT : 'rgba(255,255,255,.6)', whiteSpace: 'nowrap',
|
||||
}}>
|
||||
{s.title}
|
||||
{slideTitle(s)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user