Skip to content

Commit 1be5ed4

Browse files
committed
fix: canvas is true 16:9 below bar; embed uses calc(56.25% + 62px) padding-top
1 parent f405a19 commit 1be5ed4

3 files changed

Lines changed: 22 additions & 13 deletions

File tree

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ A self-contained, embeddable web app that sequences the five interactive modes o
55
## Embedding
66

77
```html
8-
<iframe
9-
src="https://code-dot-org.github.io/ai-literacy-oceans/"
10-
width="100%"
11-
style="aspect-ratio: 16/9; border: none;"
12-
allow="microphone"
13-
title="AI for Oceans">
14-
</iframe>
8+
<!-- Responsive wrapper: 16:9 canvas + 62px progress bar -->
9+
<div style="position:relative; width:100%; padding-top:calc(56.25% + 62px);">
10+
<iframe
11+
src="https://code-dot-org.github.io/ai-literacy-oceans/"
12+
style="position:absolute; top:0; left:0; width:100%; height:100%; border:none;"
13+
allow="microphone"
14+
title="AI for Oceans">
15+
</iframe>
16+
</div>
1517
```
1618

1719
### Contract

public/iframe-test.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
margin: 0 auto;
2222
}
2323

24-
/* Responsive 16:9 wrapper — the standard host-page embed pattern. */
24+
/* Responsive wrapper: 16:9 canvas + 62px progress bar above it.
25+
padding-top = 56.25% (9/16 canvas) + 62px (fixed bar). */
2526
.aspect-box {
2627
position: relative;
2728
width: 100%;
28-
padding-top: 56.25%; /* 9/16 */
29+
padding-top: calc(56.25% + 62px);
2930
border-radius: 8px;
3031
overflow: hidden;
3132
box-shadow: 0 4px 24px rgba(0,0,0,0.15);
@@ -94,7 +95,8 @@ <h1>AI for Oceans — iframe embed test</h1>
9495
</div>
9596
<p class="caption">
9697
Embedded via <code>&lt;iframe src="/ai-literacy-oceans/"&gt;</code> in a
97-
56.25 % padding-top aspect-ratio wrapper (standard 16:9 responsive embed).
98+
<code>calc(56.25% + 62px)</code> padding-top wrapper
99+
(16:9 canvas + 62px progress bar).
98100
</p>
99101
</div>
100102

src/App.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function setLangParam(lang: string) {
7676
// ── App ─────────────────────────────────────────────────────────────────────
7777

7878
const DARK_BG = 'rgb(2, 0, 28)';
79+
const PROGRESS_BAR_HEIGHT = 62;
7980

8081
export default function App() {
8182
const session = loadSession();
@@ -160,6 +161,8 @@ export default function App() {
160161
/>
161162
);
162163

164+
const labHeight = `calc(100vh - ${PROGRESS_BAR_HEIGHT}px)`;
165+
163166
if (done) {
164167
return (
165168
<>
@@ -168,11 +171,12 @@ export default function App() {
168171
<div
169172
data-testid="play-again-screen"
170173
style={{
174+
marginTop: PROGRESS_BAR_HEIGHT,
171175
display: 'flex',
172176
alignItems: 'center',
173177
justifyContent: 'center',
174178
width: '100vw',
175-
height: '100vh',
179+
height: labHeight,
176180
background: DARK_BG,
177181
}}
178182
>
@@ -206,15 +210,16 @@ export default function App() {
206210
data-testid="lab-area"
207211
data-mode={MODES[modeIndex]}
208212
style={{
213+
marginTop: PROGRESS_BAR_HEIGHT,
209214
width: '100vw',
210-
height: '100vh',
215+
height: labHeight,
211216
background: DARK_BG,
212217
display: 'flex',
213218
alignItems: 'center',
214219
justifyContent: 'center',
215220
}}
216221
>
217-
<div style={{width: '100%', maxWidth: 'calc(100vh * 16 / 9)'}}>
222+
<div style={{width: '100%', maxWidth: `calc(${labHeight} * 16 / 9)`}}>
218223
<OceansLab
219224
appMode={MODES[modeIndex] as AppMode}
220225
guides="HoC"

0 commit comments

Comments
 (0)