1- import { createRoot } from 'react-dom/client'
21import { useState } from 'react'
2+ import { createRoot } from 'react-dom/client'
33import '@/entrypoints/popup/style.css'
44import './style.css'
5+ import { ClaudePrototype } from './claude'
56import { Replica } from './replica'
6- import { ClaudePrototype } from "./claude"
77
8- type Mode = 'Replica' | 'ClaudePrototype'
8+ const MODES = {
9+ claude : { component : ClaudePrototype , label : 'claude' } ,
10+ replica : { component : Replica , label : 'replica' } ,
11+ } as const
12+
13+ type Mode = keyof typeof MODES
914
1015const App = ( ) => {
11- const [ activeComponent , setActiveComponent ] = useState < Mode > ( 'Replica ' )
16+ const [ activeComponent , setActiveComponent ] = useState < Mode > ( 'replica ' )
1217
1318 return (
1419 < div className = 'min-h-screen bg-slate-100' >
@@ -20,30 +25,27 @@ const App = () => {
2025 < li > Hot reload is active for instant updates</ li >
2126 </ ul >
2227 < div className = 'flex gap-2 mt-4' >
23- < button
24- onClick = { ( ) => setActiveComponent ( 'Replica' ) }
25- className = { `px-3 py-2 rounded text-sm font-medium transition-colors ${ activeComponent === 'Replica'
26- ? 'bg-blue-600 text-white'
27- : 'bg-gray-100 text-gray-700 hover:bg-gray-200'
28- } `}
29- >
30- Replica
31- </ button >
32- < button
33- onClick = { ( ) => setActiveComponent ( 'ClaudePrototype' ) }
34- className = { `px-3 py-2 rounded text-sm font-medium transition-colors ${ activeComponent === 'ClaudePrototype'
35- ? 'bg-blue-600 text-white'
36- : 'bg-gray-100 text-gray-700 hover:bg-gray-200'
28+ { Object . entries ( MODES ) . map ( ( [ mode , config ] ) => (
29+ < button
30+ key = { mode }
31+ onClick = { ( ) => setActiveComponent ( mode as Mode ) }
32+ className = { `px-3 py-2 rounded text-sm font-medium transition-colors ${
33+ activeComponent === mode
34+ ? 'bg-blue-600 text-white'
35+ : 'bg-gray-100 text-gray-700 hover:bg-gray-200'
3736 } `}
38- >
39- ClaudePrototype
40- </ button >
37+ >
38+ { config . label }
39+ </ button >
40+ ) ) }
4141 </ div >
4242 </ div >
4343
4444 < div className = 'popup-frame' >
45- { activeComponent === 'Replica' && < Replica /> }
46- { activeComponent === 'ClaudePrototype' && < ClaudePrototype /> }
45+ { ( ( ) => {
46+ const Component = MODES [ activeComponent ] . component
47+ return < Component />
48+ } ) ( ) }
4749 </ div >
4850 </ div >
4951 </ div >
0 commit comments