Skip to content

Commit bc3f583

Browse files
committed
Playground structure improvements.
1 parent 3e67771 commit bc3f583

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

browser-extension/tests/playground/playground.tsx

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
import { createRoot } from 'react-dom/client'
21
import { useState } from 'react'
2+
import { createRoot } from 'react-dom/client'
33
import '@/entrypoints/popup/style.css'
44
import './style.css'
5+
import { ClaudePrototype } from './claude'
56
import { 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

1015
const 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>

browser-extension/tests/playground/replica.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { SpotTable } from '@/components/SpotTable'
22
import type { CommentState } from '@/entrypoints/background'
3-
import { EnhancerRegistry } from '@/lib/registries'
4-
53
import type { CommentSpot } from '@/lib/enhancer'
64
import type { GitHubIssueAddCommentSpot } from '@/lib/enhancers/github/githubIssueAddComment'
75
import type { GitHubPRAddCommentSpot } from '@/lib/enhancers/github/githubPRAddComment'
6+
import { EnhancerRegistry } from '@/lib/registries'
87

98
const gh_pr: GitHubPRAddCommentSpot = {
109
domain: 'github.com',
@@ -41,7 +40,6 @@ const sampleSpots: CommentState[] = spots.map((spot) => {
4140
return state
4241
})
4342

44-
4543
export function Replica() {
4644
const handleSpotClick = (spot: CommentState) => {
4745
alert(`Clicked: ${spot.spot.type}\nTab: ${spot.tab.tabId}`)

0 commit comments

Comments
 (0)