Uses page: - Merge "For work"/"For fun" into one Hardware list; drop the MS-01. - Gaming rig becomes the Arch "Daily driver" (9950X, Looking Glass VM); custom workstation is now the Proxmox box (5900X, 128GB, RTX 3090). - Swap MetaMCP -> ContextForge and Open WebUI -> Paseo; add Codex, OpenCode, and OpenRouter. Testimonials: - Add Douglas Wilhelm; trim all quotes to ~55-60 words of verbatim sentences so cards stay the same size. - Move above projects and restyle as a card with gold-bordered initials, inline gold quote marks, and a countdown line under the divider. - Fix carousel bugs: hooks after an early return, timer not resetting on manual navigation, layout shift between quotes of different lengths. The countdown animation now drives rotation, and hover/keyboard focus pause it. Theme: - Centralize colors and fonts as CSS variables in globals.css; the neutral-* scale reads from them, and the header's hardcoded bg is gone. - New defaults: Manrope (body), EB Garamond (display), zinc greys, gold. - Add a dev-only theme switcher for A/B-ing fonts and palettes; it is compiled out of production builds. - Remove dead runtime-built hover classes on the about page that never generated CSS. Copy: replace em dashes with plain hyphens site-wide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
157 lines
6.0 KiB
TypeScript
157 lines
6.0 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import Image from "next/image";
|
|
import { IconPlayerPauseFilled, IconPlayerPlayFilled, IconPoint, IconPointFilled } from '@tabler/icons-react';
|
|
import type { Testimonial } from "@/shared/types";
|
|
import { colors } from "@/constants/colors";
|
|
|
|
const ROTATE_MS = 10000;
|
|
|
|
function getInitials(name: string) {
|
|
return name
|
|
.split(/\s+/)
|
|
.map((part) => part[0]?.toUpperCase() ?? "")
|
|
.slice(0, 2)
|
|
.join("");
|
|
}
|
|
|
|
type TestimonialsProps = {
|
|
items: Testimonial[];
|
|
};
|
|
|
|
export default function Testimonials({ items }: TestimonialsProps) {
|
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
const [isPlaying, setIsPlaying] = useState(true);
|
|
// Hovering or focusing the card pauses rotation so nobody loses their place mid-read.
|
|
const [isHovered, setIsHovered] = useState(false);
|
|
const [isFocused, setIsFocused] = useState(false);
|
|
|
|
const shouldRotate = items.length > 1 && isPlaying && !isHovered && !isFocused;
|
|
|
|
if (items.length === 0) return null;
|
|
|
|
// Clamp in case items shrinks underneath us.
|
|
const current = Math.min(activeIndex, items.length - 1);
|
|
|
|
return (
|
|
<section
|
|
className="w-full"
|
|
aria-roledescription="carousel"
|
|
aria-label="Testimonials"
|
|
onMouseEnter={() => setIsHovered(true)}
|
|
onMouseLeave={() => setIsHovered(false)}
|
|
// Only keyboard focus pauses. A mouse click also focuses the dot, and that
|
|
// focus would otherwise keep rotation paused after the pointer leaves.
|
|
onFocus={(e) => setIsFocused(e.target.matches(":focus-visible"))}
|
|
onBlur={(e) => {
|
|
if (!e.currentTarget.contains(e.relatedTarget)) setIsFocused(false);
|
|
}}
|
|
>
|
|
<div
|
|
className="relative overflow-hidden rounded-2xl border border-neutral-800 bg-elevated/40 px-6 pb-5 pt-6 sm:px-8">
|
|
{/* Every slide sits in the same grid cell, so the card is always as tall
|
|
as the longest testimonial and nothing below it jumps on rotation. */}
|
|
<div className="grid">
|
|
{items.map((item, i) => (
|
|
<figure
|
|
key={item.name}
|
|
aria-hidden={i !== current}
|
|
className={`col-start-1 row-start-1 flex flex-col justify-between gap-6 transition-opacity duration-300 ${
|
|
i === current ? "opacity-100" : "invisible opacity-0"
|
|
}`}
|
|
>
|
|
<blockquote className="text-[19px] leading-[1.65] text-neutral-200">
|
|
<span
|
|
className="mr-0.5 font-serif text-[26px] leading-none"
|
|
style={{ color: colors.accent }}
|
|
>
|
|
“
|
|
</span>
|
|
{item.quote}
|
|
<span
|
|
className="ml-0.5 font-serif text-[26px] leading-none"
|
|
style={{ color: colors.accent }}
|
|
>
|
|
”
|
|
</span>
|
|
</blockquote>
|
|
|
|
<figcaption className="flex items-center gap-3">
|
|
{item.avatar ? (
|
|
<Image
|
|
src={item.avatar}
|
|
alt=""
|
|
width={80}
|
|
height={80}
|
|
className="size-10 shrink-0 rounded-full border object-cover"
|
|
style={{ borderColor: colors.accent }}
|
|
/>
|
|
) : (
|
|
<div
|
|
aria-hidden
|
|
className="flex size-10 shrink-0 items-center justify-center rounded-full border bg-neutral-900 text-[12px] font-medium tracking-wide text-neutral-400"
|
|
style={{ borderColor: colors.accent }}
|
|
>
|
|
{getInitials(item.name)}
|
|
</div>
|
|
)}
|
|
<div className="space-y-0.5">
|
|
<div className="text-base font-semibold text-neutral-100">{item.name}</div>
|
|
<div className="text-sm text-neutral-400">{item.title}</div>
|
|
</div>
|
|
</figcaption>
|
|
</figure>
|
|
))}
|
|
</div>
|
|
|
|
{items.length > 1 && (
|
|
<footer className="relative mt-5 flex items-center justify-between border-t border-neutral-800 pt-3">
|
|
{/* Countdown line, and also the rotation timer: when the shrink animation
|
|
ends, the next testimonial shows. Re-keying on the slide restarts it
|
|
from full, and pausing freezes it in place, so the line always
|
|
matches the time actually left. */}
|
|
<div
|
|
key={current}
|
|
aria-hidden
|
|
className="animate-testimonial-countdown absolute inset-x-0 top-0 h-px origin-left"
|
|
style={
|
|
{
|
|
"--countdown-ms": `${ROTATE_MS}ms`,
|
|
backgroundColor: colors.accent,
|
|
animationPlayState: shouldRotate ? "running" : "paused",
|
|
} as React.CSSProperties
|
|
}
|
|
onAnimationEnd={() => setActiveIndex((i) => (i + 1) % items.length)}
|
|
/>
|
|
|
|
<div className="flex">
|
|
{items.map((item, i) => (
|
|
<button
|
|
key={item.name}
|
|
type="button"
|
|
onClick={() => setActiveIndex(i)}
|
|
aria-label={`Show testimonial from ${item.name}`}
|
|
aria-current={i === current}
|
|
className={i === current ? "text-accent" : "text-neutral-600 transition-colors hover:text-neutral-400"}
|
|
>
|
|
{i === current ? <IconPointFilled /> : <IconPoint />}
|
|
</button>
|
|
))}
|
|
</div>
|
|
|
|
<button
|
|
type="button"
|
|
onClick={() => setIsPlaying((p) => !p)}
|
|
aria-label={isPlaying ? "Pause rotation" : "Resume rotation"}
|
|
className="text-neutral-500 transition-colors hover:text-neutral-300"
|
|
>
|
|
{isPlaying ? <IconPlayerPauseFilled size={18} /> : <IconPlayerPlayFilled size={18} />}
|
|
</button>
|
|
</footer>
|
|
)}
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|