mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-04 06:08:38 +01:00
Botsmann had no identity of its own: a generic 2021-era AI-SaaS skin with the brand fragmented across three disagreeing sources (config OpenAI-green, globals.css black/white, page blue/purple/cyan gradients). Derive Botsmann's OWN voice — serious, credible counsel: warm editorial ink + a single authoritative ochre accent, carried by a serif display face, not gradient tricks. - globals.css is now the single SSOT for design tokens (semantic colors for brand/action/surface/text + radii + shadows, two-tier primitive→semantic). - tailwind.config wired to the CSS vars; literal colors removed. Ripped out the OpenAI-borrowed tokens (openai-green #10a37f / openai-gray) and migrated every consumer to the semantic `action` / `brand` tokens. - Killed the generic "AI gradient" skin: removed the blue→purple→cyan gradient wordmark, the blurred gradient hero blobs, gradient buttons, and glassmorphism. Replaced with one confident ochre accent + ink, hairline editorial surfaces. - Real typeface via next/font: Fraunces (serif display, headings + wordmark) + Inter (UI/body), bound to --font-serif / --font-sans. Retires system-ui. - Replaced emoji professional avatars (⚖️🩺🔬🇨🇭🎨♛) with a ProfessionalAvatar monogram badge built on the existing accentColor SSOT. - One headline value prop: tab title, hero H1 and footer now all agree on "Your Private AI Professionals" (was a split tagline vs H1). Design only — all content and functionality preserved. Lint clean; no new tsc errors (the pre-existing embeddings.test.ts error is unchanged from main); production CSS resolves the full token chain. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
107 lines
3.0 KiB
TypeScript
107 lines
3.0 KiB
TypeScript
'use client';
|
|
import { useState, useEffect } from 'react';
|
|
|
|
export interface TOCItem {
|
|
id: string;
|
|
label: string;
|
|
subItems?: TOCItem[];
|
|
}
|
|
|
|
interface TableOfContentsProps {
|
|
items: TOCItem[];
|
|
}
|
|
|
|
// Get all IDs from items and their subitems (pure function, no dependencies)
|
|
const getAllIds = (items: TOCItem[]): string[] => {
|
|
return items.reduce<string[]>((acc, item) => {
|
|
acc.push(item.id);
|
|
if (item.subItems && item.subItems.length > 0) {
|
|
acc = [...acc, ...getAllIds(item.subItems)];
|
|
}
|
|
return acc;
|
|
}, []);
|
|
};
|
|
|
|
export default function TableOfContents({ items }: TableOfContentsProps) {
|
|
const [activeId, setActiveId] = useState<string | null>(null);
|
|
|
|
// Update active section based on scroll position
|
|
useEffect(() => {
|
|
const observer = new IntersectionObserver(
|
|
(entries) => {
|
|
entries.forEach((entry) => {
|
|
if (entry.isIntersecting) {
|
|
setActiveId(entry.target.id);
|
|
}
|
|
});
|
|
},
|
|
{ rootMargin: '-10% 0% -80% 0%', threshold: 0 },
|
|
);
|
|
|
|
// Observe all section elements that correspond to TOC items
|
|
const itemIds = getAllIds(items);
|
|
itemIds.forEach((id) => {
|
|
const element = document.getElementById(id);
|
|
if (element) {
|
|
observer.observe(element);
|
|
}
|
|
});
|
|
|
|
return () => {
|
|
itemIds.forEach((id) => {
|
|
const element = document.getElementById(id);
|
|
if (element) {
|
|
observer.unobserve(element);
|
|
}
|
|
});
|
|
};
|
|
}, [items]);
|
|
|
|
// Handle smooth scrolling when clicking a TOC item
|
|
const scrollToSection = (id: string) => {
|
|
const element = document.getElementById(id);
|
|
if (element) {
|
|
setActiveId(id);
|
|
element.scrollIntoView({ behavior: 'smooth' });
|
|
}
|
|
};
|
|
|
|
// Recursive rendering of TOC items
|
|
const renderTOCItems = (items: TOCItem[], level = 0) => {
|
|
return (
|
|
<ul className={level === 0 ? 'space-y-3' : 'pl-4 mt-2 space-y-2'}>
|
|
{items.map((item) => (
|
|
<li key={item.id} className={level === 0 ? 'pb-1' : ''}>
|
|
<a
|
|
href={`#${item.id}`}
|
|
onClick={(e) => {
|
|
e.preventDefault();
|
|
scrollToSection(item.id);
|
|
}}
|
|
className={`text-sm ${
|
|
activeId === item.id
|
|
? 'font-semibold text-action'
|
|
: 'text-gray-600 hover:text-gray-900'
|
|
} ${level === 0 ? 'font-medium' : ''}`}
|
|
aria-label={`Navigate to ${item.label} section`}
|
|
>
|
|
{item.label}
|
|
</a>
|
|
{item.subItems && item.subItems.length > 0 && renderTOCItems(item.subItems, level + 1)}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<nav
|
|
className="hidden lg:block sticky top-24 self-start w-64 p-6 bg-white rounded-lg border border-gray-200 shadow-sm"
|
|
aria-label="Table of contents"
|
|
>
|
|
<h2 className="text-lg font-semibold text-gray-900 mb-4">Contents</h2>
|
|
{renderTOCItems(items)}
|
|
</nav>
|
|
);
|
|
}
|