feat: improve bot page navigation with switcher and site menu

- Add BotSwitcher dropdown component for switching between bots
- Add SiteMenuDropdown hamburger menu for main site navigation
- Update BotNavigation layout with Botsmann logo, bot switcher, and site menu
- Add botSlug prop to all 6 bot page files
- Export new navigation components from index.ts

Navigation now provides:
- Botsmann 'B' logo always visible, links to home
- Bot switcher dropdown showing all other bots
- Site menu dropdown with Solutions, Bots, Projects, Blog, About links
- Mobile slide-out menu with both site nav and bot sections

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
g-butandClaude Opus 4.5 committed 2026-01-11 23:41:40 +01:00
1 parent 1e382d6974
commit 35d34c1706
10 files changed
+346 -83

No files matched your search

+108 -83
View File
@@ -5,6 +5,8 @@ import Link from 'next/link';
import type { Route } from 'next';
import { usePathname } from 'next/navigation';
import { Dialog, Transition } from '@headlessui/react';
import { BotSwitcher, SiteMenuDropdown } from '@/components/navigation';
import { menuItems } from '@/data/menuItems';
interface MenuItem {
id: string;
@@ -14,6 +16,7 @@ interface MenuItem {
}
interface BotNavigationProps {
botSlug: string;
botTitle: string;
botEmoji: string;
botDescription?: string;
@@ -27,11 +30,12 @@ interface BotNavigationProps {
* Reusable navigation component for bot detail pages
*/
const BotNavigation: React.FC<BotNavigationProps> = ({
botSlug,
botTitle,
botEmoji,
botDescription = '',
botDescription: _botDescription = '',
accentColor = 'blue',
menuItems,
menuItems: sectionMenuItems,
chatLink,
sections = true,
}) => {
@@ -40,22 +44,25 @@ const BotNavigation: React.FC<BotNavigationProps> = ({
const [lastScrollY, setLastScrollY] = useState(0);
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
// Filter site nav items (exclude button items like "Contact Us")
const siteNavItems = menuItems.filter(item => !item.isButton);
// Handle scroll events to highlight active section
useEffect(() => {
const handleScroll = () => {
const currentScrollY = window.scrollY;
// Determine active section when sections are enabled
if (sections) {
const sectionIds = menuItems
const sectionIds = sectionMenuItems
.filter(item => item.section)
.map(item => item.section as string);
// Find which section is currently in view
const sectionElements = sectionIds
.map(id => document.getElementById(id))
.filter(Boolean);
for (let i = sectionElements.length - 1; i >= 0; i--) {
const section = sectionElements[i];
if (section && section.getBoundingClientRect().top <= 300) {
@@ -64,24 +71,24 @@ const BotNavigation: React.FC<BotNavigationProps> = ({
}
}
}
setLastScrollY(currentScrollY);
};
window.addEventListener('scroll', handleScroll, { passive: true });
handleScroll(); // Initial check
return () => window.removeEventListener('scroll', handleScroll);
}, [lastScrollY, menuItems, sections]);
}, [lastScrollY, sectionMenuItems, sections]);
// Handle smooth scrolling when clicking a menu item
const scrollToSection = (sectionId: string | undefined) => {
if (!sectionId) return;
const element = document.getElementById(sectionId);
if (element) {
window.scrollTo({
top: element.offsetTop - 100,
top: element.offsetTop - 100,
behavior: 'smooth',
});
setActiveSection(sectionId);
@@ -90,15 +97,6 @@ const BotNavigation: React.FC<BotNavigationProps> = ({
}
};
// Scroll to top function for logo click
const scrollToTop = () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
setIsMobileMenuOpen(false);
};
const colorClasses = {
blue: {
logo: 'bg-blue-100',
@@ -145,61 +143,42 @@ const BotNavigation: React.FC<BotNavigationProps> = ({
// Get the appropriate color classes or default to blue
const colors = colorClasses[accentColor as keyof typeof colorClasses] || colorClasses.blue;
const navClasses = lastScrollY > 100
? 'bg-white shadow-md border-b border-gray-200'
const navClasses = lastScrollY > 100
? 'bg-white shadow-md border-b border-gray-200'
: 'bg-white border-b border-gray-200';
return (
<nav
<nav
className={`transition-all duration-300 w-full py-3 fixed top-0 left-0 right-0 z-50 ${navClasses}`}
>
<div className="max-w-screen-xl mx-auto px-4 sm:px-6">
<div className="flex justify-between items-center">
{/* Clickable logo that scrolls to top */}
<button
onClick={scrollToTop}
className="flex items-center focus:outline-none hover:opacity-90 transition-opacity"
aria-label="Back to top"
>
<div className={`w-10 h-10 ${colors.logo} rounded-full flex items-center justify-center mr-3`}>
<span className="text-xl">{botEmoji}</span>
</div>
<h2 className={`text-xl font-bold ${colors.title}`}>{botTitle}</h2>
{botDescription && (
<span className="text-sm text-gray-500 ml-2 hidden sm:inline-block">{botDescription}</span>
)}
</button>
{/* Mobile menu button */}
<div className="flex items-center gap-2">
{/* Left side: Botsmann logo + divider + Bot Switcher */}
<div className="flex items-center">
{/* Botsmann 'B' logo - links to home */}
<Link
href="/bots"
className="text-sm text-gray-500 hidden md:inline-flex items-center hover:text-gray-700 mr-2"
href="/"
className="flex items-center justify-center w-9 h-9 bg-gradient-to-r from-blue-600 to-purple-600 text-white font-bold text-sm rounded-lg hover:opacity-90 transition-opacity"
aria-label="Go to Botsmann home"
>
<svg className="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M15 19l-7-7 7-7"></path>
</svg>
All Bots
B
</Link>
<button
className="md:hidden p-2 rounded-md text-gray-600 hover:text-gray-800 hover:bg-gray-100 focus:outline-none"
onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
aria-label={isMobileMenuOpen ? "Close menu" : "Open menu"}
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" className="h-6 w-6">
{isMobileMenuOpen ? (
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
) : (
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
)}
</svg>
</button>
{/* Vertical divider */}
<div className="h-6 w-px bg-gray-300 mx-3" />
{/* Bot Switcher dropdown */}
<BotSwitcher
currentBotSlug={botSlug}
currentBotTitle={botTitle}
currentBotEmoji={botEmoji}
accentColor={accentColor}
/>
</div>
{/* Desktop navigation */}
{/* Center: Desktop section navigation */}
<div className="hidden md:flex md:space-x-1 items-center overflow-x-auto no-scrollbar">
{menuItems.map(item => (
{sectionMenuItems.map(item => (
<button
key={item.id}
onClick={() => scrollToSection(item.section)}
@@ -214,18 +193,39 @@ const BotNavigation: React.FC<BotNavigationProps> = ({
</button>
))}
</div>
{/* Call-to-action button */}
{chatLink && (
<Link
href={chatLink as Route}
className={`px-4 py-2 ${colors.accent} text-white text-sm font-medium rounded-md transition-colors shadow-sm whitespace-nowrap ml-2`}
{/* Right side: Site menu + Chat button */}
<div className="flex items-center gap-2">
{/* Mobile menu button */}
<button
className="md:hidden p-2 rounded-md text-gray-600 hover:text-gray-800 hover:bg-gray-100 focus:outline-none"
onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
aria-label={isMobileMenuOpen ? "Close menu" : "Open menu"}
>
Open Chat
</Link>
)}
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" className="h-6 w-6">
{isMobileMenuOpen ? (
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
) : (
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
)}
</svg>
</button>
{/* Desktop: Site menu dropdown */}
<SiteMenuDropdown className="hidden md:block" />
{/* Call-to-action button */}
{chatLink && (
<Link
href={chatLink as Route}
className={`px-4 py-2 ${colors.accent} text-white text-sm font-medium rounded-md transition-colors shadow-sm whitespace-nowrap`}
>
Open Chat
</Link>
)}
</div>
</div>
</div>
{/* Mobile menu slide-in overlay */}
@@ -258,14 +258,19 @@ const BotNavigation: React.FC<BotNavigationProps> = ({
>
<Dialog.Panel className="pointer-events-auto w-screen max-w-md">
<div className="flex h-full flex-col overflow-y-scroll bg-white shadow-xl">
{/* Header */}
<div className="flex items-center justify-between px-4 py-6 border-b border-gray-200">
<Dialog.Title className="text-lg font-semibold text-gray-900">
Navigation
</Dialog.Title>
{/* Header with Botsmann branding */}
<div className="flex items-center justify-between px-4 py-6 border-b border-gray-200 bg-gradient-to-r from-blue-50 to-purple-50">
<div className="flex items-center gap-3">
<div className="flex items-center justify-center w-9 h-9 bg-gradient-to-r from-blue-600 to-purple-600 text-white font-bold text-sm rounded-lg">
B
</div>
<Dialog.Title className="text-lg font-semibold text-gray-900">
Botsmann
</Dialog.Title>
</div>
<button
type="button"
className="rounded-md p-2 text-gray-400 hover:bg-gray-100"
className="rounded-md p-2 text-gray-400 hover:bg-white/50"
onClick={() => setIsMobileMenuOpen(false)}
>
<span className="sr-only">Close menu</span>
@@ -297,15 +302,35 @@ const BotNavigation: React.FC<BotNavigationProps> = ({
onClick={() => setIsMobileMenuOpen(false)}
>
<svg className="w-5 h-5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
</svg>
All Bots
</Link>
<hr className="my-4 border-gray-200" />
{/* Section links */}
{menuItems.map(item => (
{/* Site Navigation */}
<p className="px-3 text-xs font-medium text-gray-500 uppercase tracking-wider mb-2">
Botsmann
</p>
{siteNavItems.map(item => (
<Link
key={item.label}
href={item.path}
className="flex items-center px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:bg-gray-100"
onClick={() => setIsMobileMenuOpen(false)}
>
<span>{item.label}</span>
</Link>
))}
<hr className="my-4 border-gray-200" />
{/* Bot Section links */}
<p className="px-3 text-xs font-medium text-gray-500 uppercase tracking-wider mb-2">
{botTitle} Sections
</p>
{sectionMenuItems.map(item => (
<button
key={item.id}
onClick={() => scrollToSection(item.section)}
@@ -346,4 +371,4 @@ const BotNavigation: React.FC<BotNavigationProps> = ({
);
};
export default BotNavigation;
export default BotNavigation;
+1
View File
@@ -18,6 +18,7 @@ export default function ArtisticAdvisor() {
return (
<div className="min-h-screen bg-white">
<BotNavigation
botSlug={bot.slug}
botTitle={nav.navTitle}
botEmoji={nav.emoji}
botDescription={nav.navDescription}
+1
View File
@@ -28,6 +28,7 @@ export default function LegalExpert() {
return (
<div className="min-h-screen bg-white">
<BotNavigation
botSlug={bot.slug}
botTitle={nav.navTitle}
botEmoji={nav.emoji}
botDescription={nav.navDescription}
+1
View File
@@ -27,6 +27,7 @@ export default function MedicalExpert() {
return (
<div className="min-h-screen bg-white">
<BotNavigation
botSlug={bot.slug}
botTitle={nav.navTitle}
botEmoji={nav.emoji}
botDescription={nav.navDescription}
+1
View File
@@ -34,6 +34,7 @@ export default function ProductManager() {
return (
<div className="min-h-screen bg-white">
<BotNavigation
botSlug={bot.slug}
botTitle={nav.navTitle}
botEmoji={nav.emoji}
botDescription={nav.navDescription}
+1
View File
@@ -30,6 +30,7 @@ export default function ResearchAssistant() {
return (
<div className="min-h-screen bg-white">
<BotNavigation
botSlug={bot.slug}
botTitle={nav.navTitle}
botEmoji={nav.emoji}
botDescription={nav.navDescription}
+1
View File
@@ -49,6 +49,7 @@ export default function SwissGermanTeacher() {
return (
<div className="min-h-screen bg-white">
<BotNavigation
botSlug={bot.slug}
botTitle={nav.navTitle}
botEmoji={nav.emoji}
botDescription={nav.navDescription}
+125
View File
@@ -0,0 +1,125 @@
'use client';
import { Fragment } from 'react';
import { Popover, Transition } from '@headlessui/react';
import Link from 'next/link';
import bots from '@/data/bots';
interface BotSwitcherProps {
currentBotSlug: string;
currentBotTitle: string;
currentBotEmoji: string;
accentColor?: string;
}
const colorClasses = {
blue: {
button: 'hover:bg-blue-50',
active: 'bg-blue-50 text-blue-700',
},
green: {
button: 'hover:bg-green-50',
active: 'bg-green-50 text-green-700',
},
indigo: {
button: 'hover:bg-indigo-50',
active: 'bg-indigo-50 text-indigo-700',
},
red: {
button: 'hover:bg-red-50',
active: 'bg-red-50 text-red-700',
},
amber: {
button: 'hover:bg-amber-50',
active: 'bg-amber-50 text-amber-700',
},
};
export function BotSwitcher({
currentBotSlug,
currentBotTitle,
currentBotEmoji,
accentColor = 'blue',
}: BotSwitcherProps) {
// Filter out current bot and bots without nav config
const otherBots = bots.filter(bot => bot.slug !== currentBotSlug && bot.nav);
const colors = colorClasses[accentColor as keyof typeof colorClasses] || colorClasses.blue;
return (
<Popover className="relative">
{({ open, close }) => (
<>
<Popover.Button
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>
<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 className="absolute left-0 top-full z-50 mt-2 w-64 transform">
<div className="overflow-hidden rounded-xl bg-white shadow-xl ring-1 ring-black ring-opacity-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={`/bots/${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>
</>
)}
</Popover>
);
}
+104
View File
@@ -0,0 +1,104 @@
'use client';
import { Fragment } from 'react';
import { Popover, Transition } from '@headlessui/react';
import Link from 'next/link';
import { menuItems } from '@/data/menuItems';
interface SiteMenuDropdownProps {
className?: string;
}
export function SiteMenuDropdown({ className = '' }: SiteMenuDropdownProps) {
// Filter out button items (like "Contact Us" which is styled as CTA)
const navItems = menuItems.filter(item => !item.isButton);
return (
<Popover className={`relative ${className}`}>
{({ open, close }) => (
<>
<Popover.Button
className={`inline-flex items-center justify-center rounded-lg p-2 transition-colors focus:outline-none ${
open ? 'bg-gray-100 text-gray-900' : 'text-gray-600 hover:bg-gray-100 hover:text-gray-900'
}`}
aria-label="Site navigation menu"
>
{/* Hamburger icon */}
<svg
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
{open ? (
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
) : (
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16M4 18h16" />
)}
</svg>
</Popover.Button>
<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 className="absolute right-0 top-full z-50 mt-2 w-56 transform">
<div className="overflow-hidden rounded-xl bg-white shadow-xl ring-1 ring-black ring-opacity-5 border border-gray-100">
{/* Header */}
<div className="border-b border-gray-100 bg-gradient-to-r from-blue-50 to-purple-50 px-4 py-3">
<Link
href="/"
onClick={() => close()}
className="flex items-center gap-2"
>
<div className="bg-gradient-to-r from-blue-600 to-purple-600 text-white font-bold text-sm px-2 py-1 rounded">
B
</div>
<span className="text-sm font-semibold text-gray-900">Botsmann</span>
</Link>
</div>
{/* Menu Items */}
<div className="py-2">
{navItems.map((item) => (
<Link
key={item.label}
href={item.path}
onClick={() => close()}
className="flex items-center gap-3 px-4 py-2.5 hover:bg-gray-50 transition-colors"
>
<span className="text-sm font-medium text-gray-700 hover:text-gray-900">
{item.label}
</span>
{item.children && (
<svg className="w-3 h-3 text-gray-400 ml-auto" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
</svg>
)}
</Link>
))}
</div>
{/* Footer - Contact */}
<div className="border-t border-gray-100 bg-gray-50 px-4 py-3">
<Link
href="/contact"
onClick={() => close()}
className="flex items-center justify-center gap-2 rounded-lg bg-gradient-to-r from-blue-600 to-purple-600 px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity"
>
Contact Us
</Link>
</div>
</div>
</Popover.Panel>
</Transition>
</>
)}
</Popover>
);
}
+3
View File
@@ -0,0 +1,3 @@
export { NextSection } from './NextSection';
export { BotSwitcher } from './BotSwitcher';
export { SiteMenuDropdown } from './SiteMenuDropdown';