Skip to content

Commit 4200a46

Browse files
Merge pull request #92 from jonathanhefner/responsive-basic-host
Enable responsive width growing in `basic-host`
2 parents d97ae07 + 5e96fcc commit 4200a46

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

examples/basic-host/src/implementation.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,13 @@ export function newAppBridge(serverInfo: ServerInfo, iframe: HTMLIFrameElement):
239239
if (isBorderBox) {
240240
width += parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);
241241
}
242-
from.width = `${iframe.offsetWidth}px`;
243-
iframe.style.width = to.width = `${width}px`;
242+
// Use min-width instead of width to allow responsive growing.
243+
// With auto-resize (the default), the app reports its minimum content
244+
// width; we honor that as a floor but allow the iframe to expand when
245+
// the host layout allows. And we use `min(..., 100%)` so that the iframe
246+
// shrinks with its container.
247+
from.minWidth = `${iframe.offsetWidth}px`;
248+
iframe.style.minWidth = to.minWidth = `min(${width}px, 100%)`;
244249
}
245250
if (height !== undefined) {
246251
if (isBorderBox) {

examples/basic-host/src/index.module.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
.toolCallInfoPanel {
7070
display: flex;
7171
gap: 1rem;
72-
max-width: 1120px;
7372
animation: slideDown 0.3s ease-out;
7473
}
7574

@@ -107,13 +106,10 @@
107106
}
108107

109108
.appIframePanel {
110-
display: flex;
111-
justify-content: center;
112-
width: 100%;
113109
min-height: 200px;
114110

115111
iframe {
116-
flex: 1 0 auto;
112+
width: 100%;
117113
height: 600px;
118114
box-sizing: border-box;
119115
border: 3px dashed #888;

0 commit comments

Comments
 (0)