PageSwitcher.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import * as React from 'react';
  2. import { GreenPage } from '../types';
  3. import { Icon } from './ui/Icon';
  4. interface PageSwitcherProps {
  5. pages: GreenPage[];
  6. activePageId: string;
  7. onSelectPage: (id: string) => void;
  8. onCreatePage: () => void;
  9. }
  10. const PageSwitcher: React.FC<PageSwitcherProps> = ({ pages, activePageId, onSelectPage, onCreatePage }) => {
  11. const activePage = pages.find(p => p.id === activePageId);
  12. return (
  13. <div>
  14. <div className="flex items-center space-x-3 mb-4">
  15. <div className="bg-gradient-to-r from-green-400 to-blue-500 p-2 rounded-lg">
  16. <Icon className="h-8 w-8 text-white">
  17. <path strokeLinecap="round" strokeLinejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" />
  18. </Icon>
  19. </div>
  20. <h1 className="text-xl font-bold text-white">GreenPage AI</h1>
  21. </div>
  22. <div className="relative">
  23. <select
  24. value={activePageId}
  25. onChange={(e) => onSelectPage(e.target.value)}
  26. className="w-full bg-gray-700 border border-gray-600 text-white text-sm font-semibold rounded-lg focus:ring-brand-primary focus:border-brand-primary block p-2.5 appearance-none"
  27. >
  28. {pages.map(page => (
  29. <option key={page.id} value={page.id}>{page.name}</option>
  30. ))}
  31. </select>
  32. <div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-400">
  33. <Icon className="w-4 h-4"><path d="M8 9l4-4 4 4m0 6l-4 4-4-4" /></Icon>
  34. </div>
  35. </div>
  36. <button
  37. onClick={onCreatePage}
  38. className="mt-3 w-full flex items-center justify-center gap-2 text-sm text-gray-300 bg-gray-700/50 hover:bg-gray-700 py-2 rounded-lg transition-colors"
  39. >
  40. <Icon className="w-4 h-4"><path d="M12 4v16m8-8H4" /></Icon>
  41. Create New Page
  42. </button>
  43. </div>
  44. );
  45. };
  46. export default PageSwitcher;