mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-04 22:19:13 +01:00
Tailwind 3.4 -> 4.3:
- tailwind.config.js DELETED; tokens now live in an @theme inline block in
app/globals.css (semantic names unchanged: action, paper, edge, ink...)
- postcss.config.js -> @tailwindcss/postcss; autoprefixer dropped (built in)
- @tailwind directives -> @import 'tailwindcss'; forms/typography via @plugin
- daisyui removed (no daisyui class used anywhere)
- next/font vars renamed --font-inter/--font-fraunces to break the circular
var() the old --font-sans binding would create inside @theme
- v4 deleted *-opacity-* utilities: every bg/text/ring-opacity-N rewritten to
slash syntax (bg-action/90, ring-black/5, ...); dynamic accent tint gets a
literal class map in lib/config/colors.ts so the scanner sees each class
- dead v3-era aspect-w/h custom utilities removed (unused; v4 has aspect-*)
Zod 3.24 -> 4.5:
- .errors -> .issues everywhere
- z.string().uuid( -> .guid( (v4 uuid() is RFC-variant-strict; DB ids aren't)
- z.record(z.unknown()) -> z.record(z.string(), z.unknown())
- object .default({}) -> .prefault({}) (v4 default takes the full output value)
ESLint 9 -> 10: eslint-plugin-react's version:'detect' calls the removed
context.getFilename; pin settings.react.version='19' AFTER the next configs.
Verify (format+lint+typecheck+selfhost+test+build) green: 272 tests pass.
Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn
Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
138 lines
4.9 KiB
TypeScript
138 lines
4.9 KiB
TypeScript
'use client';
|
|
|
|
import { Fragment, useRef } from 'react';
|
|
import { Popover, Transition, Portal } from '@headlessui/react';
|
|
import Link from 'next/link';
|
|
import bots from '@/data/bots';
|
|
import { getBotPath } from '@/lib/routes';
|
|
import { BRAND_SWITCHER } from '@/lib/config/colors';
|
|
|
|
interface BotSwitcherProps {
|
|
currentBotSlug: string;
|
|
currentBotTitle: string;
|
|
currentBotEmoji: string;
|
|
}
|
|
|
|
export function BotSwitcher({
|
|
currentBotSlug,
|
|
currentBotTitle,
|
|
currentBotEmoji,
|
|
}: BotSwitcherProps) {
|
|
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
// Filter out current bot and bots without nav config
|
|
const otherBots = bots.filter((bot) => bot.slug !== currentBotSlug && bot.nav);
|
|
const colors = BRAND_SWITCHER;
|
|
|
|
// Get button position for portal positioning
|
|
const getDropdownStyle = () => {
|
|
if (!buttonRef.current) return {};
|
|
const rect = buttonRef.current.getBoundingClientRect();
|
|
return {
|
|
position: 'fixed' as const,
|
|
top: rect.bottom + 8,
|
|
left: rect.left,
|
|
zIndex: 9999,
|
|
};
|
|
};
|
|
|
|
return (
|
|
<Popover>
|
|
{({ open, close }) => (
|
|
<>
|
|
<Popover.Button
|
|
ref={buttonRef}
|
|
className={`group inline-flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus:outline-none ${
|
|
open ? colors.active : `text-gray-700 ${colors.button}`
|
|
}`}
|
|
>
|
|
<span className="text-lg">{currentBotEmoji}</span>
|
|
<span className="font-semibold">{currentBotTitle}</span>
|
|
<svg
|
|
className={`h-4 w-4 text-gray-400 transition-transform ${open ? 'rotate-180' : ''}`}
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
strokeWidth={2}
|
|
d="M19 9l-7 7-7-7"
|
|
/>
|
|
</svg>
|
|
</Popover.Button>
|
|
|
|
<Portal>
|
|
<Transition
|
|
as={Fragment}
|
|
enter="transition ease-out duration-200"
|
|
enterFrom="opacity-0 translate-y-1"
|
|
enterTo="opacity-100 translate-y-0"
|
|
leave="transition ease-in duration-150"
|
|
leaveFrom="opacity-100 translate-y-0"
|
|
leaveTo="opacity-0 translate-y-1"
|
|
>
|
|
<Popover.Panel static style={getDropdownStyle()} className="w-64">
|
|
<div className="overflow-hidden rounded-xl bg-white shadow-xl ring-1 ring-black/5 border border-gray-100">
|
|
{/* Header */}
|
|
<div className="border-b border-gray-100 bg-gray-50 px-4 py-3">
|
|
<p className="text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
Switch Bot
|
|
</p>
|
|
</div>
|
|
|
|
{/* Bot List */}
|
|
<div className="py-2">
|
|
{otherBots.map((bot) => (
|
|
<Link
|
|
key={bot.slug}
|
|
href={getBotPath(bot.slug)}
|
|
onClick={() => close()}
|
|
className="flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 transition-colors"
|
|
>
|
|
<span className="text-lg">{bot.nav?.emoji}</span>
|
|
<div className="flex-1 min-w-0">
|
|
<p className="text-sm font-medium text-gray-900">{bot.nav?.navTitle}</p>
|
|
{bot.nav?.navDescription && (
|
|
<p className="text-xs text-gray-500 truncate">
|
|
{bot.nav.navDescription}
|
|
</p>
|
|
)}
|
|
</div>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
|
|
{/* Footer - All Bots link */}
|
|
<div className="border-t border-gray-100 bg-gray-50 px-4 py-3">
|
|
<Link
|
|
href="/bots"
|
|
onClick={() => close()}
|
|
className="flex items-center gap-2 text-sm text-gray-600 hover:text-gray-900 transition-colors"
|
|
>
|
|
<svg
|
|
className="w-4 h-4"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
viewBox="0 0 24 24"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
strokeWidth={2}
|
|
d="M4 6h16M4 10h16M4 14h16M4 18h16"
|
|
/>
|
|
</svg>
|
|
View All Bots
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
</Popover.Panel>
|
|
</Transition>
|
|
</Portal>
|
|
</>
|
|
)}
|
|
</Popover>
|
|
);
|
|
}
|