|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { motion } from 'framer-motion'; |
| 3 | +import { PaletteIcon, SwatchesIcon, EyeIcon, GameControllerIcon, ArrowLeftIcon, BookOpenIcon } from '@phosphor-icons/react'; |
| 4 | +import { Link } from 'react-router-dom'; |
| 5 | + |
| 6 | +import ColorWheel from './components/ColorWheel'; |
| 7 | +import HarmonyExplorer from './components/HarmonyExplorer'; |
| 8 | +import PerceptionPlayground from './components/PerceptionPlayground'; |
| 9 | +import ColorGames from './components/ColorGames'; |
| 10 | +import LearnSection from './components/LearnSection'; |
| 11 | + |
| 12 | +const sections = [ |
| 13 | + { id: 'learn', label: 'Learn', icon: BookOpenIcon, component: LearnSection, color: '#FF5C5C' }, // Red |
| 14 | + { id: 'wheel', label: 'The Wheel', icon: PaletteIcon, component: ColorWheel, color: '#FFBD4A' }, // Yellow |
| 15 | + { id: 'harmony', label: 'Harmonies', icon: SwatchesIcon, component: HarmonyExplorer, color: '#5271FF' }, // Blue |
| 16 | + { id: 'perception', label: 'Perception', icon: EyeIcon, component: PerceptionPlayground, color: '#00C896' }, // Green |
| 17 | + { id: 'games', label: 'Games', icon: GameControllerIcon, component: ColorGames, color: '#9D4EDD' }, // Purple |
| 18 | +]; |
| 19 | + |
| 20 | +const ColorTheoryApp = () => { |
| 21 | + const [activeSection, setActiveSection] = useState('learn'); |
| 22 | + |
| 23 | + return ( |
| 24 | + <div className="flex h-screen bg-[#f4f4f0] text-[#1a1a1a] font-nunito overflow-hidden selection:bg-[#1a1a1a] selection:text-[#f4f4f0]"> |
| 25 | + |
| 26 | + {/* Sidebar - Swiss Style */} |
| 27 | + <aside className="w-20 lg:w-72 flex flex-col border-r-4 border-[#1a1a1a] bg-white shrink-0 z-20"> |
| 28 | + |
| 29 | + {/* Brand Header */} |
| 30 | + <div className="p-6 border-b-4 border-[#1a1a1a] flex items-center justify-between bg-[#1a1a1a] text-[#f4f4f0]"> |
| 31 | + <h1 className="hidden lg:block text-3xl font-normal uppercase tracking-tighter font-instr-serif"> |
| 32 | + Chromatology |
| 33 | + </h1> |
| 34 | + <Link to="/apps" className="p-2 hover:bg-white/20 rounded-full transition-colors" title="Exit"> |
| 35 | + <ArrowLeftIcon size={24} weight="bold" /> |
| 36 | + </Link> |
| 37 | + </div> |
| 38 | + |
| 39 | + {/* Navigation */} |
| 40 | + <nav className="flex-1 overflow-y-auto py-6 flex flex-col gap-2 px-3"> |
| 41 | + {sections.map((section) => { |
| 42 | + const isActive = activeSection === section.id; |
| 43 | + const Icon = section.icon; |
| 44 | + |
| 45 | + return ( |
| 46 | + <button |
| 47 | + key={section.id} |
| 48 | + onClick={() => setActiveSection(section.id)} |
| 49 | + className={` |
| 50 | + relative group flex items-center gap-4 p-4 rounded-xl transition-all duration-200 border-2 |
| 51 | + ${isActive |
| 52 | + ? 'bg-[#f4f4f0] border-[#1a1a1a] shadow-[4px_4px_0px_0px_#1a1a1a] translate-x-[-2px] translate-y-[-2px]' |
| 53 | + : 'bg-transparent border-transparent hover:bg-black/5' |
| 54 | + } |
| 55 | + `} |
| 56 | + > |
| 57 | + <div |
| 58 | + className="w-10 h-10 rounded-lg flex items-center justify-center border-2 border-[#1a1a1a] shadow-sm transition-transform group-hover:scale-110" |
| 59 | + style={{ backgroundColor: section.color }} |
| 60 | + > |
| 61 | + <Icon size={20} weight="fill" className="text-white mix-blend-multiply" /> |
| 62 | + </div> |
| 63 | + <span className={`hidden lg:block font-bold text-lg tracking-tight ${isActive ? 'text-[#1a1a1a]' : 'text-[#666]'}`}> |
| 64 | + {section.label} |
| 65 | + </span> |
| 66 | + </button> |
| 67 | + ) |
| 68 | + })} |
| 69 | + </nav> |
| 70 | + |
| 71 | + {/* Footer info */} |
| 72 | + <div className="p-6 border-t-4 border-[#1a1a1a] hidden lg:block"> |
| 73 | + <p className="text-xs font-mono text-gray-500"> |
| 74 | + DESIGN: SWISS / BAUHAUS<br/> |
| 75 | + VER: 2.0.0 |
| 76 | + </p> |
| 77 | + </div> |
| 78 | + </aside> |
| 79 | + |
| 80 | + {/* Main Content Area */} |
| 81 | + <main className="flex-1 relative overflow-hidden bg-[#f4f4f0]"> |
| 82 | + |
| 83 | + {/* Decorative Grid Background */} |
| 84 | + <div className="absolute inset-0 opacity-[0.03] pointer-events-none" |
| 85 | + style={{ |
| 86 | + backgroundImage: 'radial-gradient(#000 1px, transparent 1px)', |
| 87 | + backgroundSize: '20px 20px' |
| 88 | + }} |
| 89 | + /> |
| 90 | + |
| 91 | + {/* Content Render */} |
| 92 | + <div className="h-full w-full relative z-10"> |
| 93 | + {/* Note: Removed AnimatePresence for tab switching stability based on user feedback. |
| 94 | + Instant switching is often preferred in tool-like apps. |
| 95 | + */} |
| 96 | + <div className="h-full w-full"> |
| 97 | + {(() => { |
| 98 | + const Component = sections.find(s => s.id === activeSection)?.component; |
| 99 | + if (!Component) return null; |
| 100 | + return ( |
| 101 | + <motion.div |
| 102 | + key={activeSection} |
| 103 | + initial={{ opacity: 0, x: 20 }} |
| 104 | + animate={{ opacity: 1, x: 0 }} |
| 105 | + transition={{ duration: 0.3, ease: 'easeOut' }} |
| 106 | + className="h-full w-full" |
| 107 | + > |
| 108 | + <Component /> |
| 109 | + </motion.div> |
| 110 | + ); |
| 111 | + })()} |
| 112 | + </div> |
| 113 | + </div> |
| 114 | + |
| 115 | + </main> |
| 116 | + |
| 117 | + </div> |
| 118 | + ); |
| 119 | +}; |
| 120 | + |
| 121 | +export default ColorTheoryApp; |
0 commit comments