Files
site/components/Open.jsx
zeekay 1b1f7c4b29 Refine Buying Specialist takeover, MCP layout, Journey labels, tilt gloss, and footer
- Add data-tilt light movement gloss to the Pareto frontier plot (.x-plot),
  Open Source repository cards ([data-slot='repo']), and heatmap (.x-cal).
- Attach Company menu hover listeners to the full Hanzo AI brand pill in
  Nav.jsx so hovering anywhere on 'Hanzo AI' switches to the Company menu.
- Fix dark-mode contrast on Buying Specialist user chat bubbles and submit
  arrow button, respond immediately for pricing intents, and transition into
  a focused full-screen takeover (.xbs-takeover) with an exit button once a
  message is submitted.
- Remove numeric prefixes on Journey app cards, render lowercase addresses
  (e.g. hanzo.bot ↗), and link both the kicker and 3D slab badge out.
- Remove the focus-within white underline on the SetupMenu agent filter input
  and expand Hanzo.MCP into a symmetrical two-column setup guide.
- Remove the large footer wordmark signature and place the white Hanzo mark
  at the bottom right of the footer bar.

Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk
2026-11-09 16:02:25 -08:00

189 lines
10 KiB
React
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
import { useEffect, useRef, useState } from 'react';
import { motion, AnimatePresence, useInView, useReducedMotion } from 'motion/react';
import { DAYS, FROM, TO, FIRST_WEEKDAY, LAST7, WEEKS, level } from '../lib/commits';
import O from '../content/live/_oss.json';
import repoCard from './home/repoCard';
import spark from './home/spark';
import { EASE, Head, Arrow, Count } from './ui';
// the figures hanzo.ai's home shows, from the same snapshot (content/live/_oss.json, refreshed by scripts/live.mjs)
const G = Object.values(O.groups);
const sum = (k) => G.reduce((a, g) => a + g[k], 0);
const TILES = [
['Commits', O.estate.commits, 'In the past year', 'https://git.hanzo.ai/explore/repos', spark(WEEKS, 'Commits a week over the past year', 28)],
['Merges', O.estate.merges, 'In the past year', 'https://git.hanzo.ai/explore/repos', spark(O.estate.mergeMonths, 'Merges a month over the past year', 28)],
['Commits', O.calendar.week, 'In the past 7 days', 'https://git.hanzo.ai/explore/repos', spark(LAST7, 'Commits a day over the past 7 days', 28)],
[`${O.estate.orgs} organizations`, sum('repos'), 'Original repositories', 'https://github.com/hanzoai'],
['GitHub stars', sum('stars'), 'as GitHub counts them', 'https://github.com/hanzoai'],
['GitHub forks', sum('forks'), 'as GitHub counts them', 'https://github.com/hanzoai'],
];
const CARDS = O.groups.hanzo.top.slice(0, 12).map(repoCard);
const WAYS = [
['Read the docs', 'Complete SDK documentation, client libraries, API references, guides, and architectural blueprints.', 'Read the docs', 'https://docs.hanzo.ai/docs/sdks/app', 'book'],
['Build your own apps', 'Create native desktop, web, and CLI experiences using the Hanzo platform and starter templates.', 'Build your own apps', 'https://docs.hanzo.ai/docs/dev/web', 'app'],
['Mod Hanzo', 'Every layer of the stack is open, hackable, and modifiable. Fork repositories and build your own stack.', 'Fork on GitHub', 'https://github.com/hanzoai', 'fork'],
];
const WAY_ICON = {
book: <><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" /><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" /></>,
app: <><rect x="3" y="3" width="18" height="18" rx="3" /><path d="M3 9h18" /><path d="m10 13-2 2 2 2" /><path d="m14 13 2 2-2 2" /></>,
fork: <><circle cx="12" cy="18" r="3" /><circle cx="6" cy="6" r="3" /><circle cx="18" cy="6" r="3" /><path d="M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9" /><path d="M12 12v3" /></>,
};
/* Hanzo's commit calendar, rebuilt from its own numbers. Point at any day (or move with the arrow keys) for Hanzo's
readout; the days around it swell like a lens. While nobody is pointing, a light sweeps the year week by week. */
const LEAD = FIRST_WEEKDAY; // Hanzo's grid opens with blank days so the weeks line up (Sunday first)
const MONTHS = (() => { const out = []; DAYS.forEach((x, i) => { if (x.d === 1 || i === 0) out.push([x.label.slice(0, 3), Math.floor((i + LEAD) / 7)]); }); return out; })();
function Calendar() {
const ref = useRef(null);
const seen = useInView(ref, { once: true, amount: 0.4 });
const live = useInView(ref, { amount: 0.2 });
// read after mount, so the server's HTML and the first client render agree (reduced motion hydrated with a mismatch)
const rm = useReducedMotion();
const [calm, setCalm] = useState(false);
useEffect(() => setCalm(!!rm), [rm]);
const [hot, setHot] = useState(null);
const [sweep, setSweep] = useState(-1);
useEffect(() => {
if (!seen || calm || hot !== null || !live) return;
let w = sweep;
const t = setInterval(() => { w = w >= 56 ? -4 : w + 1; setSweep(w); }, 90);
return () => clearInterval(t);
}, [seen, calm, hot, live]); // eslint-disable-line react-hooks/exhaustive-deps
const pick = (e) => {
const g = e.currentTarget.getBoundingClientRect();
const col = Math.floor(((e.clientX - g.left) / g.width) * 53), row = Math.floor(((e.clientY - g.top) / g.height) * 7);
const i = col * 7 + row - LEAD;
setHot(i >= 0 && i < DAYS.length ? i : null);
};
const key = (e) => {
const d = { ArrowRight: 7, ArrowLeft: -7, ArrowDown: 1, ArrowUp: -1 }[e.key];
if (!d) return;
e.preventDefault();
setHot((h) => Math.max(0, Math.min(DAYS.length - 1, (h ?? DAYS.length - 1) + d)));
};
const h = hot !== null ? DAYS[hot] : null;
const hc = hot !== null ? Math.floor((hot + LEAD) / 7) : 0, hr = hot !== null ? (hot + LEAD) % 7 : 0;
return (
<div className="x-cal" data-tilt="">
<p className="x-race-k">Commits a day</p>
<div className="x-cal-months" aria-hidden="true">{MONTHS.map(([m, c]) => <span key={m + c} style={{ gridColumn: c + 1 }}>{m}</span>)}</div>
<div
ref={ref}
className={'x-cal-grid2' + (seen || calm ? ' on' : '')}
role="img"
tabIndex={0}
aria-label={`Commits a day over the past year across every repository, private ones counted: ${O.estate.commits.toLocaleString('en-US')} in all. Use the arrow keys to read each day.`}
onPointerMove={pick}
onPointerLeave={() => setHot(null)}
onKeyDown={key}
onBlur={() => setHot(null)}
>
{Array.from({ length: LEAD }).map((_, i) => <i key={'b' + i} className="blank" />)}
{DAYS.map((x, i) => {
const col = Math.floor((i + LEAD) / 7), row = (i + LEAD) % 7;
const dist = hot !== null ? Math.hypot(col - hc, (row - hr) * 1.1) : 9;
const s = hot !== null ? (dist < 0.5 ? 1.55 : dist < 2.6 ? 1 + (2.6 - dist) * 0.12 : 1) : Math.abs(col - sweep) < 1 ? 1.22 : 1;
return <i key={x.label} className={'l' + level(x.c) + (i === hot ? ' hot' : '') + (hot === null && Math.abs(col - sweep) < 1 ? ' sw' : '')} style={{ '--i': i, '--s': s }} />;
})}
<AnimatePresence>
{h && (
<motion.span
className="x-cal-tip"
initial={{ opacity: 0, y: 6, scale: 0.96 }}
animate={{ opacity: 1, y: 0, scale: 1, left: `${((hc + 0.5) / 53) * 100}%`, top: `${(hr / 7) * 100}%` }}
exit={{ opacity: 0, y: 6 }}
transition={{ type: 'spring', stiffness: 500, damping: 38 }}
>
<b>{h.c.toLocaleString('en-US')} commits</b> {h.label}
</motion.span>
)}
</AnimatePresence>
</div>
<div className="x-cal-f">
<span aria-live="polite">{h ? `${h.label} · ${h.c.toLocaleString('en-US')} commits across ${h.r.toLocaleString('en-US')} repositories` : `Commits a day, from ${FROM} to ${TO}`}</span>
<span className="x-cal-key">Less <i className="l0" /><i className="l1" /><i className="l2" /><i className="l3" /><i className="l4" /> More</span>
</div>
</div>
);
}
function Tile({ t, i }) {
const [label, n, sub, href, bars] = t;
return (
<a href={href} className="x-tile" data-tilt="">
<span className="x-tile-k">{label}</span>
<Count className="x-tile-n" to={n} duration={2} delay={i * 0.06} />
<span className="x-tile-s">{sub}</span>
{bars && <span className="x-tile-spark" dangerouslySetInnerHTML={{ __html: bars }} />}
</a>
);
}
/* The repositories on a rail you can throw: drag it, swipe it, or scroll it sideways. */
function Rail() {
const ref = useRef(null);
const st = useRef(null);
useEffect(() => {
const el = ref.current;
const down = (e) => { if (e.pointerType !== 'mouse') return; st.current = { x: e.clientX, l: el.scrollLeft, moved: false }; el.classList.add('grab'); };
const move = (e) => { const s = st.current; if (!s) return; const dx = e.clientX - s.x; if (Math.abs(dx) > 4) s.moved = true; el.scrollLeft = s.l - dx; };
const up = () => { if (!st.current) return; el.classList.remove('grab'); setTimeout(() => { st.current = null; }, 0); };
const click = (e) => { if (st.current?.moved) { e.preventDefault(); e.stopPropagation(); } };
el.addEventListener('pointerdown', down); addEventListener('pointermove', move); addEventListener('pointerup', up); el.addEventListener('click', click, true);
return () => { el.removeEventListener('pointerdown', down); removeEventListener('pointermove', move); removeEventListener('pointerup', up); el.removeEventListener('click', click, true); };
}, []);
const by = (d) => ref.current.scrollBy({ left: d * ref.current.clientWidth * 0.8, behavior: 'smooth' });
return (
<div className="x-rail-wrap">
<div className="x-rail" ref={ref} tabIndex={0} aria-label="Hanzo repositories" data-lenis-prevent-wheel="">
{CARDS.map((h, i) => (
<motion.div key={i} className="x-repo" initial={{ opacity: 0, x: 60 }} whileInView={{ opacity: 1, x: 0 }} viewport={{ once: true, amount: 0.2 }} transition={{ duration: 0.8, ease: EASE, delay: Math.min(i, 4) * 0.07 }} whileHover={{ y: -4 }} dangerouslySetInnerHTML={{ __html: h }} />
))}
</div>
<div className="x-rail-nav">
<motion.button type="button" className="x-round" aria-label="Previous repositories" onClick={() => by(-1)} whileTap={{ scale: 0.9 }}>‹</motion.button>
<motion.button type="button" className="x-round" aria-label="Next repositories" onClick={() => by(1)} whileTap={{ scale: 0.9 }}>›</motion.button>
</div>
</div>
);
}
function Way({ w }) {
return (
<a href={w[3]} className="x-way" data-tilt="">
<i className="x-way-i" aria-hidden="true"><svg viewBox="0 0 24 24">{WAY_ICON[w[4]]}</svg></i>
<b><span>{w[0]}</span></b>
<span>{w[1]}</span>
<em><span>{w[2]} →</span></em>
</a>
);
}
export default function Open() {
return (
<>
<section className="x-sec x-oss" id="open-source" data-hz-view="open-source" aria-labelledby="open-source-h">
<div className="x-wrap">
<Head title="We ship every day. Fork anything. Build your own." lede="Every layer of the stack is open, hackable and modifiable — recursively self-upgrading AI from the ground up. Fork, remix, and build the apps only you can imagine." />
<div className="x-tiles">{TILES.map((t, i) => <Tile key={i} t={t} i={i} />)}</div>
<Calendar />
</div>
<Rail />
<div className="x-wrap">
<div className="x-row-links"><Arrow href="/open-source">Explore every repository</Arrow></div>
</div>
</section>
<section className="xw-ways">
<div className="x-ways">{WAYS.map((w) => <Way key={w[0]} w={w} />)}</div>
<div className="x-row-links">
<Arrow href="https://git.hanzo.ai/explore/repos">Explore the forge</Arrow>
<Arrow href="/grants">OSS &amp; research credit grants</Arrow>
</div>
</section>
</>
);
}