Commit 7bbf2bb
authored
feat(basic-host): Add theme toggle and MCP style variables (#336)
* feat(basic-host): add theme toggle and MCP style variables
Add theme support to basic-host example:
- theme.ts: Global theme manager with light/dark toggle
- host-styles.ts: Full set of MCP CSS variables using light-dark()
- ThemeToggle component with sun/moon icons
- Theme-aware CSS using CSS custom properties
- Pass theme + styles to apps via hostContext
- Notify apps when theme changes via sendHostContextChange
Apps now receive:
- hostContext.theme: 'light' | 'dark'
- hostContext.styles.variables: All 60+ MCP CSS variables
- onhostcontextchanged notifications when theme changes
* test: update e2e goldens for theme changes1 parent ee5d3f8 commit 7bbf2bbCopy full SHA for 7bbf2bb
10 files changed
+287-12Lines changed: 287 additions & 12 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- examples/basic-host
- src
- tests/e2e/servers.spec.ts-snapshots
Expand file treeCollapse file tree
Open diff view settings
Collapse file
examples/basic-host/sandbox.html
Copy file name to clipboardExpand all lines: examples/basic-host/sandbox.html+4Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
12 | 12 | |
13 | 13 | |
14 | 14 | |
| 15 | + |
| 16 | + |
15 | 17 | |
16 | 18 | |
17 | 19 | |
| ||
26 | 28 | |
27 | 29 | |
28 | 30 | |
| 31 | + |
| 32 | + |
29 | 33 | |
30 | 34 | |
31 | 35 | |
|
Collapse file
examples/basic-host/src/global.css
Copy file name to clipboardExpand all lines: examples/basic-host/src/global.css+28Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
1 | 24 | |
2 | 25 | |
3 | 26 | |
4 | 27 | |
5 | 28 | |
| 29 | + |
| 30 | + |
6 | 31 | |
7 | 32 | |
| 33 | + |
| 34 | + |
| 35 | + |
8 | 36 | |
9 | 37 | |
10 | 38 | |
|
Collapse file
examples/basic-host/src/host-styles.ts
Copy file name to clipboard+113Lines changed: 113 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + |
Collapse file
examples/basic-host/src/implementation.ts
Copy file name to clipboardExpand all lines: examples/basic-host/src/implementation.ts+14Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
3 | 3 | |
4 | 4 | |
5 | 5 | |
| 6 | + |
| 7 | + |
6 | 8 | |
7 | 9 | |
8 | 10 | |
| ||
270 | 272 | |
271 | 273 | |
272 | 274 | |
| 275 | + |
273 | 276 | |
| 277 | + |
| 278 | + |
| 279 | + |
| 280 | + |
| 281 | + |
274 | 282 | |
275 | 283 | |
276 | 284 | |
277 | 285 | |
278 | 286 | |
279 | 287 | |
| 288 | + |
| 289 | + |
| 290 | + |
| 291 | + |
| 292 | + |
| 293 | + |
280 | 294 | |
281 | 295 | |
282 | 296 | |
|
Collapse file
examples/basic-host/src/index.module.css
Copy file name to clipboardExpand all lines: examples/basic-host/src/index.module.css+40-12Lines changed: 40 additions & 12 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
1 | 26 | |
2 | 27 | |
3 | 28 | |
4 | | - |
| 29 | + |
5 | 30 | |
| 31 | + |
6 | 32 | |
7 | 33 | |
8 | 34 | |
| ||
28 | 54 | |
29 | 55 | |
30 | 56 | |
31 | | - |
| 57 | + |
32 | 58 | |
33 | 59 | |
| 60 | + |
| 61 | + |
34 | 62 | |
35 | 63 | |
36 | 64 | |
| ||
43 | 71 | |
44 | 72 | |
45 | 73 | |
46 | | - |
| 74 | + |
47 | 75 | |
48 | 76 | |
49 | 77 | |
| ||
53 | 81 | |
54 | 82 | |
55 | 83 | |
56 | | - |
| 84 | + |
57 | 85 | |
58 | 86 | |
59 | 87 | |
60 | 88 | |
61 | 89 | |
62 | 90 | |
63 | | - |
| 91 | + |
64 | 92 | |
65 | 93 | |
66 | 94 | |
| ||
103 | 131 | |
104 | 132 | |
105 | 133 | |
106 | | - |
| 134 | + |
107 | 135 | |
108 | 136 | |
109 | | - |
| 137 | + |
110 | 138 | |
111 | 139 | |
112 | 140 | |
113 | | - |
114 | | - |
| 141 | + |
| 142 | + |
115 | 143 | |
116 | 144 | |
117 | 145 | |
| ||
123 | 151 | |
124 | 152 | |
125 | 153 | |
126 | | - |
| 154 | + |
127 | 155 | |
128 | 156 | |
129 | 157 | |
| ||
246 | 274 | |
247 | 275 | |
248 | 276 | |
249 | | - |
250 | | - |
| 277 | + |
| 278 | + |
251 | 279 | |
Collapse file
examples/basic-host/src/index.tsx
Copy file name to clipboardExpand all lines: examples/basic-host/src/index.tsx+24Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
3 | 3 | |
4 | 4 | |
5 | 5 | |
| 6 | + |
6 | 7 | |
7 | 8 | |
8 | 9 | |
| ||
64 | 65 | |
65 | 66 | |
66 | 67 | |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
67 | 90 | |
68 | 91 | |
69 | 92 | |
| ||
84 | 107 | |
85 | 108 | |
86 | 109 | |
| 110 | + |
87 | 111 | |
88 | 112 | |
89 | 113 | |
|
0 commit comments