Files
f04d13bf39 refactor(design): finish the colour sweep, and make it enforceable (#148)
#144 put the bot pages on the brand. This does the other 60 files, so the
whole product reads as one thing, and adds the guard that keeps it that way.

~410 raw palette classes became semantic tokens across the public marketing
surface (/try, /enterprise, /about, /knowledge, /personal, /professionals,
/bots, blog, navigation) and the app internals (dashboard, documents, chat,
conversations, onboarding, auth, settings, profile).

Gradient text is gone. Fifteen headings were
`bg-gradient-to-r from-X to-Y bg-clip-text text-transparent`; they are now
solid text-ink or text-action. globals.css says the identity is carried by
typography, and a serif display does not need a gradient to do that.

The 'B' mark was still a blue/purple gradient in BotNavigation's MOBILE menu.
#144 only fixed the desktop header. Both now render the shared <Logo>.

Three defects introduced mid-sweep and corrected, all caught by reading the
diff rather than trusting the regex:
  - degenerate gradients (`from-action-tint to-action-tint`) collapsed to solid
  - dead hovers (tint on tint) rebased to bg-surface + hover:bg-action-tint
  - `to-action\b` matched the prefix of `to-action-hover`, so a collapse left a
    stray `bg-action-hover` as a BASE background in 11 places -- those are the
    primary, not the hover shade

Deliberately NOT changed:
  - components/knowledge/Callout.tsx -- its blue is the `info` half of an
    info/warning/error triad. Semantic status colour is a separate scale from
    the brand accent, and warning is amber, so ochre-ing info would make the
    two nearly indistinguishable.
  - the custom-bot surfaces -- custom_bots.accent_color is a real column with
    a CHECK constraint and the owner picks it. User data, not a design token.

Never-twice: tests/__tests__/lib/design-tokens.test.ts refuses any raw
brand-palette class, and any bg-clip-text, outside those two documented
exceptions. Mutation-verified -- swap one token back to bg-blue-600 and it
fails and names the file. No allowlist debt: every other file was swept rather
than excused.

verify: format, lint, typecheck, 256 tests, build -- all green. Twelve pages
smoke-tested and checked visually against a local production build.


Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG

Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 09:53:41 +00:00

140 lines
4.7 KiB
TypeScript

'use client';
import { type FC, useState } from 'react';
import {
templatesByCategory,
categoryLabels,
type TemplateCategory,
type BotTemplate,
} from '@/lib/bot-templates';
interface TemplatePickerProps {
onSelect: (templateId: string) => void;
}
interface TemplateCategoryOrder {
category: TemplateCategory;
order: number;
}
const categoryOrder: TemplateCategoryOrder[] = [
{ category: 'memorial', order: 1 },
{ category: 'legends', order: 2 },
{ category: 'gods', order: 3 },
{ category: 'magical', order: 4 },
{ category: 'helpers', order: 5 },
];
import { ACCENT_TEMPLATE_HOVER_CLASSES } from '@/lib/config/colors';
interface TemplateCardProps {
template: BotTemplate;
onClick: () => void;
}
const TemplateCard: FC<TemplateCardProps> = ({ template, onClick }) => {
const hoverClass =
ACCENT_TEMPLATE_HOVER_CLASSES[template.accentColor] || ACCENT_TEMPLATE_HOVER_CLASSES.blue;
return (
<button
onClick={onClick}
className={`group relative bg-white rounded-xl p-4 border-2 border-gray-100 transition-all duration-200 ${hoverClass} hover:shadow-lg hover:scale-105`}
>
<div className="flex flex-col items-center text-center">
<span className="text-4xl mb-2 group-hover:scale-110 transition-transform">
{template.emoji}
</span>
<span className="font-medium text-gray-900 text-sm">{template.shortName}</span>
</div>
</button>
);
};
export const TemplatePicker: FC<TemplatePickerProps> = ({ onSelect }) => {
const [expandedCategory, setExpandedCategory] = useState<TemplateCategory | null>(null);
const toggleCategory = (category: TemplateCategory) => {
setExpandedCategory(expandedCategory === category ? null : category);
};
return (
<div className="space-y-12">
{/* Title */}
<div className="text-center">
<h1 className="text-4xl md:text-5xl font-bold mb-4">
<span className="text-action">Who Do You Want to Create?</span>
</h1>
<p className="text-lg text-gray-600 max-w-2xl mx-auto">
Pick a template and start chatting in under 60 seconds
</p>
</div>
{/* Categories */}
<div className="space-y-10">
{categoryOrder.map(({ category }) => {
const templates = templatesByCategory[category];
const label = categoryLabels[category];
const isExpanded = expandedCategory === category;
const displayTemplates = isExpanded ? templates : templates.slice(0, 8);
return (
<div key={category} className="space-y-4">
{/* Category Header */}
<div className="flex items-center justify-between">
<div>
<h2 className="text-xl font-semibold text-gray-900">{label.title}</h2>
<p className="text-sm text-gray-500">{label.description}</p>
</div>
{templates.length > 8 && (
<button
onClick={() => toggleCategory(category)}
className="text-sm text-purple-600 hover:text-purple-700 font-medium flex items-center gap-1"
>
{isExpanded ? 'Show Less' : `Show All (${templates.length})`}
<svg
className={`w-4 h-4 transition-transform ${isExpanded ? 'rotate-180' : ''}`}
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M19 9l-7 7-7-7"
/>
</svg>
</button>
)}
</div>
{/* Template Grid */}
<div className="grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 lg:grid-cols-10 gap-3">
{displayTemplates.map((template) => (
<TemplateCard
key={template.id}
template={template}
onClick={() => onSelect(template.id)}
/>
))}
</div>
</div>
);
})}
</div>
{/* Start from Scratch */}
<div className="text-center pt-8 border-t border-gray-200">
<button
onClick={() => onSelect('custom')}
className="inline-flex items-center gap-3 bg-gray-900 text-white px-8 py-4 rounded-xl font-semibold hover:bg-gray-800 transition-colors"
>
<span className="text-2xl">🎭</span>
<span>Start From Scratch - Build Something Unique</span>
</button>
</div>
</div>
);
};