Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps/demo/app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,15 @@
.app .recent-list :focus-visible { outline-offset: -2px; }

/* The player: as wide as the window on a phone, edge to edge, and at the page's width with room
around it on a larger screen. */
at its sides on a larger screen. Never with room above it: there it costs the window's height,
and content that fits the window below the bar, as a book's chapter can, would scroll the
window by that much (#168). A message above the player keeps room of its own. */
.app[data-screen="player"] main { width: min(100%, var(--content)); padding: 0 0 env(safe-area-inset-bottom); }
.app[data-screen="player"] .message { margin: 0.75rem var(--gutter) 0; }

@media (min-width: 48rem) {
.app[data-screen="player"] main { width: min(100% - 2 * var(--gutter), var(--content)); padding-top: 1.25rem; }
.app[data-screen="player"] .message { margin: 0 0 1rem; }
.app[data-screen="player"] main { width: min(100% - 2 * var(--gutter), var(--content)); }
.app[data-screen="player"] .message { margin: 1.25rem 0 1rem; }
}

.app .stage { position: relative; }
Expand Down
29 changes: 29 additions & 0 deletions apps/demo/tests/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,35 @@ it('keeps the bar’s icons on its first row at every width, with Install off th
await page.close()
})

it('puts the player right under the bar, and a message a little below it', async () => {
const { page, errors } = await openApp()
const choosing = page.waitForEvent('filechooser')
await page.click('#open')
await (await choosing).setFiles(QUIZ)
await playerIs(page, 'ready')
const belowBar = (selector: string) =>
page.evaluate(
(selector) => Math.round(document.querySelector(selector)!.getBoundingClientRect().top - document.querySelector('.topbar')!.getBoundingClientRect().bottom),
selector
)

// Room above the player costs the window's height: content that fits the window below the bar,
// as a book's chapter can, would scroll it by that much (#168). On a phone and a wide window alike.
for (const width of [1000, 600]) {
await page.setViewportSize({ width, height: 760 })
expect(await belowBar('h5p-player'), `at ${width}px`).toBe(0)
}
expect(errors).toEqual([])

// A message keeps room of its own, on the wide window.
await page.setViewportSize({ width: 1000, height: 760 })
await page.goto(`${origin}/app/?src=/demo/content/missing.h5p`)
await playerIs(page, 'error')
expect(await seen(page)).toMatchObject({ screen: 'player', message: expect.stringMatching(/./) })
expect(await belowBar('#message')).toBeGreaterThanOrEqual(16)
await page.close()
})

it('has a menu and an About dialog that Escape closes', async () => {
const { page } = await openApp()
const open = (selector: string) => page.evaluate((selector) => document.querySelector(selector)!.matches(':popover-open, [open]'), selector)
Expand Down
Loading