Skip to content

Commit 8ff08bc

Browse files
fix(website): mobile benchmark bars and tilt effect
1 parent 1fcacaa commit 8ff08bc

File tree

2 files changed

+47
-28
lines changed

2 files changed

+47
-28
lines changed

packages/website/src/components/Benchmarks.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function ColdStartChart() {
5656
</h4>
5757
<p className="text-[11px] text-zinc-600 italic mt-1">Lower is better</p>
5858
</div>
59-
<div className="flex gap-1 sm:ml-auto">
59+
<div className="flex flex-wrap gap-1 sm:ml-auto">
6060
{groups.map((t, i) => (
6161
<button
6262
key={t.label}
@@ -76,7 +76,7 @@ function ColdStartChart() {
7676
{/* Secure Exec bar */}
7777
<div className="flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-4">
7878
<span className="text-xs text-zinc-500 sm:w-48 shrink-0 font-mono">Secure Exec</span>
79-
<div className="flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
79+
<div className="w-full sm:flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
8080
<motion.div
8181
key={active}
8282
initial={{ width: 0 }}
@@ -99,7 +99,7 @@ function ColdStartChart() {
9999
{/* Sandbox bar */}
100100
<div className="flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-4">
101101
<span className="text-xs text-zinc-500 sm:w-48 shrink-0 font-mono">Fastest sandbox</span>
102-
<div className="flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
102+
<div className="w-full sm:flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
103103
<motion.div
104104
key={active}
105105
initial={{ width: 0 }}
@@ -145,7 +145,7 @@ function MetricBar({
145145
{/* Secure Exec bar */}
146146
<div className="flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-4">
147147
<span className="text-xs text-zinc-500 sm:w-48 shrink-0 font-mono">Secure Exec</span>
148-
<div className="flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
148+
<div className="w-full sm:flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
149149
<motion.div
150150
initial={{ width: 0 }}
151151
whileInView={{ width: `${barMin}%` }}
@@ -170,7 +170,7 @@ function MetricBar({
170170
{/* Sandbox bar */}
171171
<div className="flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-4">
172172
<span className="text-xs text-zinc-500 sm:w-48 shrink-0 font-mono">{sandbox.label}</span>
173-
<div className="flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
173+
<div className="w-full sm:flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
174174
<motion.div
175175
initial={{ width: 0 }}
176176
whileInView={{ width: `${sandbox.bar}%` }}
@@ -222,7 +222,7 @@ function CostChart() {
222222
</h4>
223223
<p className="text-[11px] text-zinc-600 italic mt-1">Lower is better</p>
224224
</div>
225-
<div className="flex gap-1 sm:ml-auto">
225+
<div className="flex flex-wrap gap-1 sm:ml-auto">
226226
{tiers.map((tier, i) => (
227227
<button
228228
key={tier.label}
@@ -242,7 +242,7 @@ function CostChart() {
242242
{/* Secure Exec bar */}
243243
<div className="flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-4">
244244
<span className="text-xs text-zinc-500 sm:w-48 shrink-0 font-mono">Secure Exec</span>
245-
<div className="flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
245+
<div className="w-full sm:flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
246246
<motion.div
247247
key={active}
248248
initial={{ width: 0 }}
@@ -265,7 +265,7 @@ function CostChart() {
265265
{/* Sandbox bar */}
266266
<div className="flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-4">
267267
<span className="text-xs text-zinc-500 sm:w-48 shrink-0 font-mono">Cheapest sandbox</span>
268-
<div className="flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
268+
<div className="w-full sm:flex-1 relative h-7 bg-white/5 rounded-sm overflow-hidden">
269269
<motion.div
270270
key={active}
271271
initial={{ width: 0 }}
@@ -285,7 +285,7 @@ function CostChart() {
285285

286286
export function Benchmarks() {
287287
return (
288-
<section id="benchmarks" className="border-t border-white/10 py-48">
288+
<section id="benchmarks" className="border-t border-white/10 py-48 overflow-x-hidden">
289289
<div className="mx-auto max-w-7xl px-6">
290290
<div className="mb-12">
291291
<motion.h2
@@ -324,7 +324,7 @@ export function Benchmarks() {
324324
whileInView={{ opacity: 1, y: 0 }}
325325
viewport={{ once: true }}
326326
transition={{ duration: 0.5 }}
327-
className="relative z-10 rounded-xl bg-[#0c0c0e] p-8 chrome-gradient-border"
327+
className="relative z-10 rounded-xl bg-[#0c0c0e] p-4 sm:p-8 overflow-hidden chrome-gradient-border"
328328
style={{ "--chrome-angle": "75deg" } as React.CSSProperties}
329329
>
330330
{/* Cold start charts */}

packages/website/src/layouts/Layout.astro

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,36 +79,55 @@ const structuredData = {
7979
<body class="min-h-screen bg-background text-foreground antialiased">
8080
<slot />
8181
<script>
82-
// Chrome border scroll effects:
83-
// 1. Rotate gradient clockwise on scroll-down (fast at edges, slow at center)
84-
// 2. Brighter/shinier near page center, darker near top/bottom
82+
// Chrome border scroll + tilt effects:
83+
// Scroll: rotate gradient clockwise, brighter near page center
84+
// Tilt (mobile): device orientation adds rotation and brightness shift
8585
{
8686
const K = 0.6;
8787
const TWO_PI = Math.PI * 2;
8888
const BRIGHT_MIN = 0.35;
8989
const BRIGHT_MAX = 1.2;
90+
91+
let scrollDeg = 0;
92+
let scrollBright = BRIGHT_MIN;
93+
let scrollDivider = 100;
94+
let tiltDeg = 0;
95+
let tiltBright = 0;
9096
let ticking = false;
91-
const update = () => {
97+
98+
const apply = () => {
99+
const root = document.documentElement.style;
100+
root.setProperty("--chrome-scroll-offset", `${scrollDeg + tiltDeg}deg`);
101+
root.setProperty("--chrome-brightness", `${scrollBright + tiltBright}`);
102+
root.setProperty("--chrome-divider-offset", `${scrollDivider}%`);
103+
ticking = false;
104+
};
105+
106+
const onScroll = () => {
92107
const scrollY = window.scrollY;
93108
const pageHeight = document.documentElement.scrollHeight - window.innerHeight;
94109
const t = pageHeight > 0 ? scrollY / pageHeight : 0;
95110
const eased = t + K * Math.sin(TWO_PI * t) / TWO_PI;
96-
const degrees = eased * 360;
97-
const brightness = BRIGHT_MIN + (BRIGHT_MAX - BRIGHT_MIN) * Math.sin(Math.PI * t);
98-
const root = document.documentElement.style;
99-
const dividerOffset = (1 - t) * 100;
100-
root.setProperty("--chrome-scroll-offset", `${degrees}deg`);
101-
root.setProperty("--chrome-brightness", `${brightness}`);
102-
root.setProperty("--chrome-divider-offset", `${dividerOffset}%`);
103-
ticking = false;
111+
scrollDeg = eased * 360;
112+
scrollBright = BRIGHT_MIN + (BRIGHT_MAX - BRIGHT_MIN) * Math.sin(Math.PI * t);
113+
scrollDivider = (1 - t) * 100;
114+
if (!ticking) { requestAnimationFrame(apply); ticking = true; }
104115
};
105-
window.addEventListener("scroll", () => {
106-
if (!ticking) {
107-
requestAnimationFrame(update);
108-
ticking = true;
109-
}
116+
117+
window.addEventListener("scroll", onScroll, { passive: true });
118+
onScroll();
119+
120+
// Device tilt: gamma (left/right) drives rotation, beta (front/back) drives brightness
121+
let hasTilt = false;
122+
window.addEventListener("deviceorientation", (e) => {
123+
if (e.gamma == null || e.beta == null) return;
124+
hasTilt = true;
125+
const gamma = Math.max(-45, Math.min(45, e.gamma));
126+
const beta = Math.max(-45, Math.min(45, e.beta));
127+
tiltDeg = (gamma / 45) * 60;
128+
tiltBright = (1 - Math.abs(beta) / 45) * 0.3;
129+
if (!ticking) { requestAnimationFrame(apply); ticking = true; }
110130
}, { passive: true });
111-
update();
112131
}
113132
</script>
114133
</body>

0 commit comments

Comments
 (0)