Default to light theme with Anthropic palette; hide future days in push tracker; warp cursor

This commit is contained in:
bobbert committed 2026-09-17 17:53:55 +01:00
1 parent bc3b415d89
commit a861447d59
5 files changed
+107 -93

No files matched your search

+1 -3
View File
@@ -5,9 +5,7 @@
(function () {
try {
var saved = localStorage.getItem("theme");
var dark = saved
? saved === "dark"
: window.matchMedia("(prefers-color-scheme: dark)").matches;
var dark = saved === "dark";
if (dark) document.documentElement.dataset.theme = "dark";
} catch (e) {}
})();
+68 -34
View File
@@ -1,21 +1,10 @@
import { useEffect, useState } from "react";
import {
motion,
useMotionValue,
useSpring,
useReducedMotion,
} from "motion/react";
import { useEffect, useRef, useState } from "react";
import { useReducedMotion } from "motion/react";
export default function Cursor() {
const reduced = useReducedMotion();
const [active, setActive] = useState(false);
const [overInteractive, setOverInteractive] = useState(false);
const [pressed, setPressed] = useState(false);
const x = useMotionValue(-100);
const y = useMotionValue(-100);
const ringX = useSpring(x, { stiffness: 240, damping: 26, mass: 0.7 });
const ringY = useSpring(y, { stiffness: 240, damping: 26, mass: 0.7 });
const dotRef = useRef(null);
useEffect(() => {
if (reduced) return;
@@ -24,42 +13,87 @@ export default function Cursor() {
setActive(true);
document.documentElement.classList.add("has-custom-cursor");
let tx = -100, ty = -100; // pointer position
let cx = -100, cy = -100; // rendered head (lerped)
let vx = 0, vy = 0; // smoothed velocity px/frame
let avx = 0, avy = 0; // raw delta since last frame
let stretch = 0; // 0..1 warp amount
let angle = 0; // travel direction rad
let scale = 1; // smoothed press/hover scale
let over = false, pressed = false;
let raf = 0;
const move = (e) => {
x.set(e.clientX);
y.set(e.clientY);
avx += e.clientX - tx;
avy += e.clientY - ty;
tx = e.clientX;
ty = e.clientY;
};
const over = (e) =>
setOverInteractive(!!e.target.closest("a, button, [role='button']"));
const down = () => setPressed(true);
const up = () => setPressed(false);
const overEl = (e) => {
over = !!e.target.closest("a, button, [role='button']");
};
const down = () => {
pressed = true;
};
const up = () => {
pressed = false;
};
const tick = () => {
// lazy lookup: the span only mounts after the setActive re-render
const el = dotRef.current;
if (el) {
cx += (tx - cx) * 0.55;
cy += (ty - cy) * 0.55;
vx += (avx - vx) * 0.35;
vy += (avy - vy) * 0.35;
avx = 0;
avy = 0;
const speed = Math.hypot(vx, vy);
stretch += (Math.min(1, speed / 12) - stretch) * 0.25;
if (speed > 0.4) {
const target = Math.atan2(vy, vx);
let d = target - angle;
while (d > Math.PI) d -= Math.PI * 2;
while (d < -Math.PI) d += Math.PI * 2;
angle += d * 0.35;
}
const targetScale = pressed ? 0.7 : over ? 1.4 : 1;
scale += (targetScale - scale) * 0.2;
// shift the head slightly backwards so the stretched tail trails behind
const ox = -Math.cos(angle) * stretch * 3;
const oy = -Math.sin(angle) * stretch * 3;
el.style.transform =
`translate3d(${cx + ox}px, ${cy + oy}px, 0) rotate(${angle}rad) ` +
`scale(${(scale * (1 + stretch * 0.8)).toFixed(3)}, ${(scale * (1 - stretch * 0.25)).toFixed(3)})`;
}
raf = requestAnimationFrame(tick);
};
raf = requestAnimationFrame(tick);
window.addEventListener("mousemove", move, { passive: true });
document.addEventListener("mouseover", over);
document.addEventListener("mouseover", overEl);
window.addEventListener("mousedown", down);
window.addEventListener("mouseup", up);
return () => {
cancelAnimationFrame(raf);
document.documentElement.classList.remove("has-custom-cursor");
window.removeEventListener("mousemove", move);
document.removeEventListener("mouseover", over);
document.removeEventListener("mouseover", overEl);
window.removeEventListener("mousedown", down);
window.removeEventListener("mouseup", up);
};
}, [reduced, x, y]);
}, [reduced]);
if (!active) return null;
const dotClass = `cursor-dot${pressed ? " cursor-dot--pressed" : ""}`;
const ringClass = `cursor-ring${overInteractive ? " cursor-ring--active" : ""}`;
return (
<>
<motion.div className={dotClass} style={{ x, y }} aria-hidden="true">
<span />
</motion.div>
<motion.div className={ringClass} style={{ x: ringX, y: ringY }} aria-hidden="true">
<span />
</motion.div>
</>
<div className="cursor-dot" aria-hidden="true">
<span ref={dotRef} />
</div>
);
}
+1 -3
View File
@@ -13,9 +13,7 @@ function initialTheme() {
if (typeof window === "undefined") return "light";
const saved = localStorage.getItem("theme");
if (saved === "light" || saved === "dark") return saved;
return window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
return "light";
}
function MoonIcon() {
+2 -1
View File
@@ -142,12 +142,13 @@ export default function PushTracker() {
const cells = [];
for (let dow = 0; dow < 7; dow++) {
const day = addDays(gridStart, w * 7 + dow);
if (day > today) break; // future days don't render
const key = dayKey(day);
const count = data.counts.get(key) || 0;
cells.push(
<span
key={key}
className={`pt-cell l${levels.get(key) || 0}${day > today ? " is-future" : ""}`}
className={`pt-cell l${levels.get(key) || 0}`}
title={count ? `${count} contribution${count === 1 ? "" : "s"} on ${fmtDay(key)}` : fmtDay(key)}
/>
);
+35 -52
View File
@@ -20,25 +20,29 @@
}
:root {
/* light theme (default) */
--bg: #f7f6f9;
--bg-alt: #efedf4;
--surface: #ffffff;
--ink: #17151f;
--ink-soft: #54505e;
--muted: #8b8798;
--hairline: #e4e2ec;
--hairline-strong: #cfcbe0;
--accent: #6c4fd8;
--accent-dark: #5a3fb8;
--accent-tint: #ece7fa;
/* light theme (default) — Anthropic cream / orange */
--bg: #f5f2ea;
--bg-alt: #ece7da;
--surface: #fbfaf6;
--ink: #1c1a16;
--ink-soft: #56524a;
--muted: #8b8474;
--hairline: #e1dccd;
--hairline-strong: #cbc4b0;
--accent: #d97757;
--accent-dark: #c25f3f;
--accent-tint: #f4e4d8;
--accent-contrast: #ffffff;
/* always-dark panel (contact section) */
--panel: #17151f;
--panel-ink: #f4f2fa;
--panel-muted: #a39fb8;
/* empty contribution cell */
--pt-empty: #e8e6f0;
--panel: #211e19;
--panel-ink: #f4f1ea;
--panel-muted: #a39b8a;
/* contribution cells (light) */
--pt-empty: #eae4d5;
--pt-l1: #ecd9c4;
--pt-l2: #dfb28f;
--pt-l3: #d97757;
--pt-l4: #a84e31;
--font-display: "Helvetica Now Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
--font-text: "Helvetica Now Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
@@ -64,6 +68,10 @@
--panel-ink: #eceaf4;
--panel-muted: #8f8aa5;
--pt-empty: #211d30;
--pt-l1: #e0d6f2;
--pt-l2: #c6b2e8;
--pt-l3: #a184d6;
--pt-l4: #7050bd;
}
* {
@@ -804,24 +812,19 @@ a {
}
.pt-cell.l1 {
background: #e0d6f2;
background: var(--pt-l1);
}
.pt-cell.l2 {
background: #c6b2e8;
background: var(--pt-l2);
}
.pt-cell.l3 {
background: #a184d6;
background: var(--pt-l3);
}
.pt-cell.l4 {
background: #7050bd;
}
.pt-cell.is-future {
opacity: 0;
pointer-events: none;
background: var(--pt-l4);
}
.pt-note {
@@ -1198,8 +1201,7 @@ a {
/* ---------- custom cursor ---------- */
.cursor-dot,
.cursor-ring {
.cursor-dot {
position: fixed;
top: 0;
left: 0;
@@ -1209,32 +1211,13 @@ a {
.cursor-dot span {
display: block;
width: 7px;
height: 7px;
margin: -3.5px 0 0 -3.5px;
width: 8px;
height: 8px;
margin: -4px 0 0 -4px;
border-radius: 50%;
background: var(--accent);
transition: transform 0.18s ease;
}
.cursor-dot--pressed span {
transform: scale(0.7);
}
.cursor-ring span {
display: block;
width: 30px;
height: 30px;
margin: -15px 0 0 -15px;
border-radius: 50%;
border: 1.5px solid color-mix(in srgb, var(--accent) 45%, transparent);
transition: transform 0.22s ease, border-color 0.22s ease, background-color 0.22s ease;
}
.cursor-ring--active span {
transform: scale(1.35);
border-color: color-mix(in srgb, var(--accent) 70%, transparent);
background: color-mix(in srgb, var(--accent) 8%, transparent);
transform: translate3d(-100px, -100px, 0);
will-change: transform;
}
html.has-custom-cursor,