Skip to content

Commit 5ac6dcb

Browse files
authored
Merge pull request #8 from All-Hands-AI/add-settings-modal
Add settings modal to React example
2 parents fd6cf78 + 9218e2a commit 5ac6dcb

File tree

12 files changed

+1244
-3
lines changed

12 files changed

+1244
-3
lines changed

example/src/App.css

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
:root {
2+
/* Color variables for light mode */
3+
--card-bg: #ffffff;
4+
--border-color: #e0e0e0;
5+
--border-light: #f0f0f0;
6+
--text-primary: #333333;
7+
--text-secondary: #666666;
8+
--primary-color: #646cff;
9+
--hover-bg: #f5f5f5;
10+
--code-bg: #f8f9fa;
11+
--error-color: #d32f2f;
12+
--warning-color: #f57c00;
13+
--info-bg: #e3f2fd;
14+
--info-border: #2196f3;
15+
--info-text: #1976d2;
16+
17+
/* Dark mode variables */
18+
--card-bg-dark: #2a2a2a;
19+
--border-color-dark: #404040;
20+
--border-light-dark: #353535;
21+
--text-primary-dark: #ffffff;
22+
--text-secondary-dark: #cccccc;
23+
--hover-bg-dark: #3a3a3a;
24+
--code-bg-dark: #1e1e1e;
25+
--info-bg-dark: #1a237e;
26+
--info-border-dark: #3f51b5;
27+
--info-text-dark: #90caf9;
28+
}
29+
130
#root {
231
max-width: 1280px;
332
margin: 0 auto;
@@ -9,6 +38,49 @@
938
padding: 2rem;
1039
}
1140

41+
.app-header {
42+
display: flex;
43+
justify-content: space-between;
44+
align-items: center;
45+
margin-bottom: 2rem;
46+
}
47+
48+
.app-header h1 {
49+
margin: 0;
50+
}
51+
52+
.settings-button {
53+
background-color: #646cff;
54+
color: white;
55+
border: none;
56+
padding: 0.75rem 1rem;
57+
border-radius: 4px;
58+
cursor: pointer;
59+
font-size: 1rem;
60+
transition: background-color 0.2s;
61+
}
62+
63+
.settings-button:hover {
64+
background-color: #535bf2;
65+
}
66+
67+
.welcome-message {
68+
background-color: #e3f2fd;
69+
border: 1px solid #2196f3;
70+
border-radius: 4px;
71+
padding: 1rem;
72+
margin-bottom: 1rem;
73+
text-align: center;
74+
}
75+
76+
.welcome-message p {
77+
margin: 0;
78+
color: #1976d2;
79+
font-weight: 500;
80+
}
81+
82+
83+
1284
.card {
1385
padding: 2em;
1486
margin: 1em 0;
@@ -73,4 +145,21 @@
73145
border-top-color: #333;
74146
color: #ccc;
75147
}
148+
149+
.welcome-message {
150+
background-color: #1a237e;
151+
border-color: #3f51b5;
152+
}
153+
154+
.welcome-message p {
155+
color: #90caf9;
156+
}
157+
158+
.settings-info {
159+
background-color: #2a2a2a;
160+
}
161+
162+
.settings-info h3 {
163+
color: #fff;
164+
}
76165
}

example/src/App.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ import {
1010
EventSortOrder
1111
} from '@openhands/agent-server-typescript-client'
1212

13+
// Import settings components
14+
import { SettingsModal } from './components/SettingsModal'
15+
import { useSettings } from './contexts/SettingsContext'
16+
1317
function App() {
1418
const [sdkStatus, setSdkStatus] = useState<string>('Loading...')
1519
const [sdkInfo, setSdkInfo] = useState<any>(null)
20+
21+
// Use settings context
22+
const { settings, updateSettings, isModalOpen, openModal, closeModal, isFirstVisit } = useSettings()
1623

1724
useEffect(() => {
1825
// Test that the SDK imports work correctly
@@ -48,7 +55,19 @@ function App() {
4855
return (
4956
<div className="App">
5057
<div>
51-
<h1>OpenHands SDK Example</h1>
58+
<div className="app-header">
59+
<h1>OpenHands SDK Example</h1>
60+
<button className="settings-button" onClick={openModal}>
61+
⚙️ Settings
62+
</button>
63+
</div>
64+
65+
{isFirstVisit && (
66+
<div className="welcome-message">
67+
<p>👋 Welcome! Please configure your settings to get started.</p>
68+
</div>
69+
)}
70+
5271
<div className="card">
5372
<h2>SDK Import Status</h2>
5473
<p className="status">{sdkStatus}</p>
@@ -102,6 +121,13 @@ function App() {
102121
that the build process works correctly.
103122
</p>
104123
</div>
124+
125+
<SettingsModal
126+
isOpen={isModalOpen}
127+
onClose={closeModal}
128+
onSave={updateSettings}
129+
initialSettings={settings}
130+
/>
105131
</div>
106132
</div>
107133
)

0 commit comments

Comments
 (0)