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
33 changes: 23 additions & 10 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
viewportState.isCompact && uiState.sheetDetent !== "closed",
);

/* See `uiState.stepFocus` and `uiState.headerInCard`. */
let stepFocus = $derived(uiState.stepFocus);

/*
* Undo and redo from the keyboard.
*
Expand Down Expand Up @@ -275,17 +278,21 @@
instead of being the one thing left floating over a bare board.
-->
{#if !uiState.uiHidden}
<Header />
{#if !uiState.headerHidden}
<Header />
{/if}
<PreviewBanner />

<!--
Top-right readout. One card, not two: it carries the layout's figures and
the inspected tile on a single line at its foot, so a phone is never asked
to show two stacked panels over the map they describe.
-->
<div class="corner-cards" bind:this={uiState.statsRef}>
<BoardStatsCard />
</div>
{#if !stepFocus}
<div class="corner-cards" bind:this={uiState.statsRef}>
<BoardStatsCard />
</div>
{/if}

{#if !readOnly && !hudHidden}
<!--
Expand Down Expand Up @@ -412,7 +419,12 @@

.corner-cards {
position: absolute;
top: calc(var(--header-clearance, 4.5rem) + 0.5rem);
/*
* Floored at the safe area: on a short phone the header is not mounted
* (`uiState.headerHidden`), its clearance is 0, and the card takes the
* top line itself.
*/
top: calc(max(var(--header-clearance, 4.5rem), var(--safe-top)) + 0.5rem);
right: calc(var(--safe-right) + 0.75rem);
z-index: var(--z-inspector);
display: flex;
Expand All @@ -421,8 +433,8 @@
gap: 0.6rem;
/* Leaves room for the HUD, so a long card never runs under it. */
max-height: calc(
100dvh - var(--header-clearance, 4.5rem) - var(--hud-clearance, 0px) -
2rem
100dvh - max(var(--header-clearance, 4.5rem), var(--safe-top)) -
var(--hud-clearance, 0px) - 2rem
);
/* The strip itself must not intercept drags meant for the canvas. */
pointer-events: none;
Expand All @@ -444,10 +456,11 @@
* there is no banner, which is every board but a shared one.
*/
top: calc(
var(--header-clearance, 4.5rem) + 0.5rem + var(--preview-clearance, 0px)
max(var(--header-clearance, 4.5rem), var(--safe-top)) + 0.5rem +
var(--preview-clearance, 0px)
);
max-height: calc(
100dvh - var(--header-clearance, 4.5rem) -
100dvh - max(var(--header-clearance, 4.5rem), var(--safe-top)) -
var(--preview-clearance, 0px) - var(--hud-clearance, 0px) - 2rem
);
}
Expand Down Expand Up @@ -547,7 +560,7 @@
position: absolute;
left: 50%;
transform: translateX(-50%);
top: calc(var(--header-clearance, 4rem) + 0.5rem);
top: calc(max(var(--header-clearance, 4rem), var(--safe-top)) + 0.5rem);
max-width: calc(100vw - var(--safe-left) - var(--safe-right) - 2rem);
z-index: var(--z-toast);
display: flex;
Expand Down
62 changes: 52 additions & 10 deletions src/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@ order `App.svelte` happened to mount them in. Two layers sit at a token minus on
and both are the same lesson. `PreviewBanner` is `calc(var(--z-header) - 1)`: it is
header chrome and shares the token, but it mounts _after_ the header, and at an
equal z-index DOM order decides — which put a status line over everything the
header opens. The overflow menu is a plain absolutely-positioned child of a bar
with a z-index of its own, so it is sealed inside that stacking context and cannot
climb out to reach a sibling; the bar underneath has to yield instead — which is
also the honest reading, since the header's controls belong over a status line.
header opens. The overflow menu's list opens as a `popover` in the top layer, hung
off its button by measurement (`float` in `OverflowMenu`): absolutely positioned
it was sealed inside the header's stacking context, and hosted in the readout it
would be clipped by a card that hides its overflow and whose `backdrop-filter`
pins even `position: fixed` to it. Without popover support the absolute rules
still place it in the header; in the readout that fallback is clipped by the
card (popover is Safari 17+, Chrome 114+, Firefox 125+).

Note `--z-sheet` deliberately outranks `--z-header`: the mobile sheet is 90dvh at
its `full` detent, so it has to cover a top-anchored header.

**A floating menu needs a bound.** `OverflowMenu` caps itself at
`100dvh - var(--header-clearance) - var(--safe-bottom) - 1.5rem` and scrolls
inside it. That list only grows, and unbounded it simply ran off the bottom of the
screen — and since the page cannot scroll (`html, body { overflow: hidden }`) and
the menu is absolutely positioned, rows past the fold were not awkward to reach but
_unreachable_.
**A floating menu needs a bound.** `OverflowMenu` caps itself at the room below
its button (`float` writes the `max-height` as it opens; the CSS
`100dvh - var(--header-clearance) - …` cap is the no-popover fallback's) and
scrolls inside it. That list only grows, and unbounded it simply ran off the
bottom of the screen — and since the page cannot scroll
(`html, body { overflow: hidden }`), rows past the fold were not awkward to reach
but _unreachable_. It is placed once, so a resize closes it rather than leaving it
hanging where the button was.

### The ladders

Expand Down Expand Up @@ -229,3 +234,40 @@ Two more the layout depends on:

Touch-target bumps are keyed on `@media (pointer: coarse)`, not a width breakpoint,
for the same reason `viewportState` splits the two axes.

### Short viewports

`viewportState.isShort` (under 600px tall **and** under the 1024px sidebar
breakpoint) is a third axis: a phone split-screened beside the game — 330–450px,
and exactly when the steps are walked — or held in landscape. A short desktop
window is a laptop, not a thumb beside a game, and keeps the full chrome. Width
rules still apply on top. Three things pack tighter there:

- **The header folds into the readout** on a phone with a readout to fold
into (`uiState.headerInCard`): the header is not mounted, its menu sits in
the card's head beside the chevron, and Center View and the card's own
actions (Steps, Copy, Discard) become the menu's first rows (`actions` on
`OverflowMenu`). Two stacked bars become one line. Hosted there, the menu
always takes in Share and map size, since no header holds them even on a
landscape phone wider than `isPhone`. `TimelineStatus` goes with the header
— the Chronon pill is the full-height screen's — and the menu closes itself
on unmount, since `overflowOpen` is one flag across both hosts. With no
readout — an empty board of one's own — the header stays, as a corner pill
without the logo.
- **The readout starts folded** whatever `statsCardCollapsed` says; its chevron
opens it for the session without writing the preference, which belongs to
the full-height screen. Opened, it leaves out the solve's building
counts, which the kind filter in the HUD beneath already shows.
- **In step mode** the header and the readout both go (`uiState.stepFocus`) —
the steps bar carries the power, cost and place — and the bar moves its
arrows either side of the step's line and drops the slider.

The step bar's arrows (`--ctl` on touch) and its close button (`--ctl-sm`) sit
under the `--tap` floor at every height, by request: at 44px they were the
heaviest thing in the bar, and a pair fixed at its two ends is found by position.

`Header` zeroes `headerBottom` on teardown so nothing reserves its room;
everything anchored under it (the corner card, `PreviewBanner`, the update
notice) floors that clearance at the safe area; and `PixiCanvas`'s first framing
takes `headerHidden` in place of a header edge it would otherwise wait for
forever.
6 changes: 5 additions & 1 deletion src/lib/components/canvas/PixiCanvas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,11 @@
let framed = false;

$effect(() => {
const ready = uiState.headerBottom > 0 && uiState.hudHeight > 0;
// A short phone with a solve on screen never mounts the header (its
// controls ride in the readout), so there is no edge to wait for.
const ready =
(uiState.headerBottom > 0 || uiState.headerHidden) &&
uiState.hudHeight > 0;
if (framed || !ready || !isAtlasLoaded) return;
framed = true;
recenterGrid();
Expand Down
33 changes: 32 additions & 1 deletion src/lib/components/header/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
*/
let compact = $derived(viewportState.isPhone);

/*
* Short: a phone split-screened beside the game, or in landscape. The logo
* goes (the heading keeps its accessible name) and the bar tightens to its
* buttons, which is ~20px of a 400px screen handed back to the board. The
* buttons keep their size: they are still thumb targets.
*/
let short = $derived(viewportState.isShort);

/*
* Hidden, not disabled, on a shipped island. Its dimensions are part of the
* map, so a stepper there is not a control the user is temporarily barred
Expand Down Expand Up @@ -66,14 +74,25 @@
$effect(() => {
void headerHeight;
void compact;
void short;
if (headerEl)
uiState.headerBottom = headerEl.getBoundingClientRect().bottom;
});

/*
* Cleared when the bar unmounts (step mode on a short screen takes it away),
* so nothing goes on reserving room under a bar that is not there — the same
* teardown `hudHeight` has.
*/
$effect(() => () => {
uiState.headerBottom = 0;
});
</script>

<header
class="hud-header"
class:compact
class:short
bind:this={headerEl}
bind:clientHeight={headerHeight}
>
Expand All @@ -83,7 +102,7 @@
dimensions are the file's own (3x the 44px it draws at, for HiDPI), which
is what lets the browser reserve the right box before the image lands.
-->
<h1 class="logo">
<h1 class={short ? "sr-only" : "logo"}>
<img
class="logo-mark"
src={asset("logo.webp")}
Expand Down Expand Up @@ -265,6 +284,18 @@
}
}

/*
* Short: the logo is gone, so the controls carry the bar on their own —
* a pill in the top-right corner, where they always sit, rather than a
* full-width bar that is empty for half its length. The padding drops to a
* hairline around them.
*/
.hud-header.short {
top: calc(var(--safe-top) + 0.4rem);
left: auto;
padding: 0.2rem 0.3rem;
}

/* Icon-only, and squared up to the 44px minimum touch target. */
.hud-header.compact .action-btn {
width: var(--tap);
Expand Down
Loading
Loading