/* global React */
const { useState, useEffect, useRef } = React;
// Animated demo: pricebook (back) + takeoff (back) → quote (front)
// Cycles every 6s. The two back cards "feed" the quote card via streamed lines.
function HeroDemo() {
const [phase, setPhase] = useState(0); // 0 idle, 1 streaming, 2 quote built
useEffect(() => {
const seq = [
{ p: 0, t: 600 },
{ p: 1, t: 2200 },
{ p: 2, t: 3200 },
];
let i = 0;
let timer;
const run = () => {
const step = seq[i % seq.length];
setPhase(step.p);
timer = setTimeout(() => { i++; run(); }, step.t);
};
run();
return () => clearTimeout(timer);
}, []);
// Pricebook items
const pbItems = [
["Colorsteel Endura roof", "m²", "$78.50"],
["Decramastic tile", "m²", "$112.00"],
["Marley spouting 125", "lm", "$24.30"],
["Dimond fascia 150", "lm", "$18.90"],
["Roofing screws 65mm", "box", "$42.60"],
["Butynol membrane", "m²", "$96.20"],
["Underlay synthetic", "roll", "$185.00"],
];
// Takeoff measurements
const toItems = [
["Main roof area", "248 m²"],
["Spouting linear", "62 lm"],
["Fascia run", "62 lm"],
["Ridge cap", "18 lm"],
["Valley flashing", "12 lm"],
["Penetrations", "4 ea"],
];
return (
{/* Back-left: Pricebook */}
= 2 ? 0.35 : 1,
transition: "opacity 0.6s var(--ease-out-quint), transform 0.6s var(--ease-out-quint)",
transform: phase >= 2 ? "rotate(-5deg) translateX(-8px)" : "rotate(-3deg)",
}}>
Pricebook · Roofing.csv
{pbItems.map((r, i) => (
{r[0]}
{r[1]}
{r[2]}
))}
{/* Back-right: Takeoff */}
= 2 ? 0.35 : 1,
transition: "opacity 0.6s var(--ease-out-quint), transform 0.6s var(--ease-out-quint)",
transform: phase >= 2 ? "rotate(4.5deg) translateX(8px)" : "rotate(2.5deg)",
}}>
Takeoff · 14 Beach Rd
{toItems.map((r, i) => (
{r[0]}
{r[1]}
))}
{/* Stream lines (visualize data flowing into quote) */}
{/* Front: Quote card */}
= 2 ? 1 : 0.0,
transform: phase >= 2 ? "translateY(0) scale(1)" : "translateY(40px) scale(0.96)",
transition: "opacity 0.6s var(--ease-out-quint), transform 0.6s var(--ease-out-quint)",
animation: phase >= 2 ? "floatY 4s ease-in-out 0.8s infinite" : "none",
}}>
Quote · QT-2049
Customer
David & Sarah Brown
14 Beach Rd, Mt Maunganui · Re-roof
= 2} />
= 2} />
= 2} />
= 2} />
= 2 ? 1 : 0,
transform: phase >= 2 ? "translateY(0)" : "translateY(8px)",
transition: "opacity 0.4s ease 0.6s, transform 0.4s var(--ease-out-quint) 0.6s",
}}>
Total ex GST
NZ$31,757
);
}
function QLine({ label, val, delay, show }) {
return (
{label}
{val}
);
}
function CheckBadge() {
return (
);
}
window.HeroDemo = HeroDemo;