THE CODE
import { useRef } from "react";
import InflatableTulip from "./InflatableTulip";
import sprite from "./assets/tulip-sprite.webp";
export default function App() {
const word = useRef<HTMLHeadingElement>(null);
const psi = useRef<HTMLSpanElement>(null);
const hint = useRef<HTMLParagraphElement>(null);
// p: 0 = fist (deflated) … 1 = open hand (inflated). Runs every frame,
// so we update styles directly instead of React state (keeps it smooth).
const onPressure = (p: number) => {
const w = word.current;
if (w) {
w.style.fontVariationSettings = `"wght" ${200 + p * 700}, "wdth" ${55 + p * 95}`;
w.style.letterSpacing = `${-0.07 + p * 0.03}em`;
w.style.transform = `scale(${0.92 + p * 0.08}, ${0.8 + p * 0.2})`;
}
if (psi.current) psi.current.textContent = (p * 2.5).toFixed(2);
if (hint.current) hint.current.textContent = p > 0.5 ? "Squeeze to deflate" : "Open to inflate";
};
return (
<main className="screen">
<h1 ref={word} className="word">INFLATE</h1>
<div className="tulip">
<InflatableTulip sprite={sprite} height="70vh" smoothTime={0.7} onPressureChange={onPressure} />
</div>
<p ref={hint} className="hint">Open to inflate</p>
<div className="gauge"><span ref={psi}>2.50</span> psi</div>
</main>
);
}
THE DESIGN
@import url('https://fonts.googleapis.com/css2?family=Anybody:wdth,wght@50..150,100..900&family=Figtree:wght@400;600&display=swap');
.screen { position: relative; height: 100vh; overflow: hidden;
display: grid; place-items: center; background: #dfe4ec; font-family: Figtree, sans-serif; }
.word { position: absolute; margin: 0; font-family: Anybody, sans-serif;
font-size: clamp(90px, 22vw, 360px); line-height: .8; color: #c87a34; opacity: .9;
transform-origin: 50% 60%; will-change: transform; user-select: none; }
.tulip { position: relative; z-index: 1; }
.hint { position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%);
margin: 0; font-size: 14px; letter-spacing: .12em; text-transform: uppercase; color: #5c6577; }
.gauge { position: absolute; top: 32px; right: 32px; font: 600 28px/1 Figtree; color: #1d2433; }