您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

template-sidebar.tsx 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { Button } from '@/components/ui/button';
  2. import { useSecondPathName } from '@/hooks/route-hook';
  3. import { cn } from '@/lib/utils';
  4. import { Banknote, LayoutGrid, User } from 'lucide-react';
  5. const menuItems = [
  6. {
  7. section: 'All Templates',
  8. items: [
  9. { icon: User, label: 'Assistant', key: 'Assistant' },
  10. { icon: LayoutGrid, label: 'chatbot', key: 'chatbot' },
  11. { icon: Banknote, label: 'generator', key: 'generator' },
  12. { icon: Banknote, label: 'Intel', key: 'Intel' },
  13. ],
  14. },
  15. ];
  16. export function SideBar({ change }: { change: (keyword: string) => void }) {
  17. const pathName = useSecondPathName();
  18. const handleMenuClick = (key: string) => {
  19. change(key);
  20. };
  21. return (
  22. <aside className="w-[303px] bg-background border-r flex flex-col">
  23. <div className="flex-1 overflow-auto">
  24. {menuItems.map((section, idx) => (
  25. <div key={idx}>
  26. <h2
  27. className="p-6 text-sm font-semibold hover:bg-muted/50 cursor-pointer"
  28. onClick={() => handleMenuClick('')}
  29. >
  30. {section.section}
  31. </h2>
  32. {section.items.map((item, itemIdx) => {
  33. const active = pathName === item.key;
  34. return (
  35. <Button
  36. key={itemIdx}
  37. variant={active ? 'secondary' : 'ghost'}
  38. className={cn('w-full justify-start gap-2.5 p-6 relative')}
  39. onClick={() => handleMenuClick(item.key)}
  40. >
  41. <item.icon className="w-6 h-6" />
  42. <span>{item.label}</span>
  43. {active && (
  44. <div className="absolute right-0 w-[5px] h-[66px] bg-primary rounded-l-xl shadow-[0_0_5.94px_#7561ff,0_0_11.88px_#7561ff,0_0_41.58px_#7561ff,0_0_83.16px_#7561ff,0_0_142.56px_#7561ff,0_0_249.48px_#7561ff]" />
  45. )}
  46. </Button>
  47. );
  48. })}
  49. </div>
  50. ))}
  51. </div>
  52. </aside>
  53. );
  54. }