Aashir Zayd

Commit Bonsai

Component

About

Contribution graph grown into a seasonal pixel bonsai. Same name, same tree.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Commit Bonsai to your project and fits it to your theme.

Code

How Commit Bonsai is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import * as React from "react";
import { CommitBonsai, type Contribution, type Season } from "@/components/ui/commit-bonsai";

const FONTS = `
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&family=Silkscreen&display=swap');
.bonsai-demo{font-family:'Geist',ui-sans-serif,system-ui,sans-serif}
.bonsai-demo .font-mono{font-family:'Geist Mono',ui-monospace,SFMono-Regular,Menlo,monospace}
.bonsai-demo .font-pixel{font-family:'Silkscreen',ui-monospace,monospace;font-weight:400}
`;

/** A believable year: weekday-heavy, a few vacations, a couple of perfect weeks. */
function fakeYear(seed: string, energy: number): Contribution[] {
  let h = 2166136261;
  for (let i = 0; i < seed.length; i++) { h ^= seed.charCodeAt(i); h = Math.imul(h, 16777619); }
  let s = h >>> 0;
  const rnd = () => ((s = (s * 1664525 + 1013904223) >>> 0) / 4294967296);
  const out: Contribution[] = [];
  const today = new Date();
  const vacations = [Math.floor(rnd() * 300), Math.floor(rnd() * 300)];
  for (let d = 364; d >= 0; d--) {
    const day = new Date(today.getFullYear(), today.getMonth(), today.getDate() - d);
    const dow = day.getDay();
    const onVacation = vacations.some((v) => d >= v && d < v + 9);
    const grind = Math.floor(d / 7) % 11 === 3; // perfect-week bursts
    let c = 0;
    if (!onVacation) {
      const base = dow === 0 || dow === 6 ? 0.25 : 1;
      const p = grind ? 1 : base * energy * (0.55 + 0.45 * Math.sin(d / 40) ** 2);
      if (rnd() < p) c = Math.max(1, Math.round((rnd() * 9 + (grind ? 4 : 0)) * energy));
    }
    const k = `${day.getFullYear()}-${String(day.getMonth() + 1).padStart(2, "0")}-${String(day.getDate()).padStart(2, "0")}`;
    out.push({ date: k, count: c });
  }
  return out;
}

const SEASONS: (Season | "auto")[] = ["auto", "spring", "summer", "autumn", "winter"];

export default function CommitBonsaiDemo() {
  const [name, setName] = React.useState("aashirzayd");
  const [energy, setEnergy] = React.useState(0.8);
  const [season, setSeason] = React.useState("auto" as Season | "auto");
  const data = React.useMemo(() => fakeYear(name, energy), [name, energy]);

  return (
    <div className="bonsai-demo relative flex min-h-[860px] w-full items-center justify-center overflow-hidden bg-background px-5 py-14">
      <style>{FONTS}</style>
      <div aria-hidden className="pointer-events-none absolute inset-0 [background-image:radial-gradient(rgb(128_128_128/0.18)_1px,transparent_1px)] [background-size:18px_18px] [mask-image:radial-gradient(ellipse_at_center,black_15%,transparent_72%)]" />
      <div aria-hidden className="pointer-events-none absolute left-1/2 top-[40%] h-80 w-[36rem] -translate-x-1/2 rounded-full bg-emerald-400/[0.07] blur-3xl" />

      <div className="relative w-full max-w-[560px]">
        <p className="font-mono text-[10.5px] uppercase tracking-[0.24em] text-muted-foreground">Contribution graph · grown, not plotted</p>
        <h2 className="font-pixel mt-2 text-[28px] leading-[1.1] text-foreground">Your year, as a bonsai.</h2>
        <p className="mt-2 max-w-md text-[14px] leading-relaxed text-muted-foreground">
          Every week is a branch. Commits grow leaves, perfect weeks blossom, empty weeks stay bare. Same name, same tree.
        </p>

        <CommitBonsai className="mt-6" contributions={data} seed={name} season={season} />

        <div className="mt-4 grid gap-4 rounded-2xl border bg-background/70 p-4 backdrop-blur sm:grid-cols-[1fr_1fr]">
          <label className="block">
            <span className="text-[12px] text-muted-foreground">Username (seeds the shape)</span>
            <input
              value={name}
              onChange={(e) => setName(e.target.value.slice(0, 24))}
              className="mt-1.5 h-9 w-full rounded-lg border bg-background px-3 font-mono text-[13px] text-foreground outline-none focus:ring-2 focus:ring-ring"
            />
          </label>
          <label className="block">
            <span className="flex items-baseline justify-between text-[12px] text-muted-foreground">
              Activity <span className="font-mono text-foreground">{energy < 0.4 ? "chill" : energy < 0.9 ? "steady" : "grindset"}</span>
            </span>
            <input type="range" min={0.1} max={1.3} step={0.05} value={energy} onChange={(e) => setEnergy(Number(e.target.value))} className="mt-3 w-full accent-emerald-600" />
          </label>
          <div className="flex flex-wrap gap-1 sm:col-span-2">
            {SEASONS.map((s) => (
              <button
                key={s}
                type="button"
                onClick={() => setSeason(s)}
                className={"rounded-md px-2.5 py-1 font-mono text-[10.5px] uppercase tracking-[0.12em] transition-colors " + (season === s ? "bg-foreground text-background" : "text-muted-foreground hover:bg-muted hover:text-foreground")}
              >
                {s}
              </button>
            ))}
          </div>
        </div>
      </div>
    </div>
  );
}

More by Aashir Zayd

View all
  • Uptime Pet

    Uptime Pet

    24
  • Punch Card Input

    Punch Card Input

    14
  • Contribution Heatmap

    Contribution Heatmap

    11
  • Dot Matrix Toaster

    Dot Matrix Toaster

    3
  • Quota Candle

    Quota Candle

    1
  • AI Code Editor

    AI Code Editor

  • Desktop OS

    Desktop OS

  • Pipeline Aquarium

    Pipeline Aquarium