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
21 changes: 21 additions & 0 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ImportModal,
HudToolbar,
MoveStepsBar,
KindFilter,
PixiCanvas,
PreviewBanner,
SettingsModal,
Expand Down Expand Up @@ -344,6 +345,14 @@
>
<Eye size={18} />
</button>
<!--
The one control that stays: picking a kind out of the solver's board is
a way of reading the board, which is what the interface was put away
for. Where the HUD would offer it — the solver's board, not mid-run.
-->
{#if !readOnly && uiState.showingSolver && uiState.canSwitchBoards}
<div class="hidden-filter"><KindFilter /></div>
{/if}
{/if}

<ShareModal />
Expand Down Expand Up @@ -552,6 +561,18 @@
color: var(--text);
}

/* Bottom centre, where the HUD that normally carries it sits. */
.hidden-filter {
position: absolute;
left: 50%;
bottom: calc(var(--safe-bottom) + 0.75rem);
transform: translateX(-50%);
max-width: calc(100vw - var(--safe-left) - var(--safe-right) - 1.5rem);
z-index: var(--z-hud);
display: flex;
justify-content: center;
}

/*
* `--warn`: this page is past a limit — the deploy it was loaded from is
* gone. Nothing is destroyed, so not `--danger`.
Expand Down
8 changes: 6 additions & 2 deletions src/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,14 @@ 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
actions (Steps, Copy, Discard) become rows of the menu (`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
landscape phone wider than `isPhone`, and it is ordered by use, each
action placed by its `group`: Hide interface and Center View; Steps, Copy,
Share and Save as image; Island stats, Import, Transfer and Settings; map
size; Discard alone near the foot, away from the thumb's first landing;
Support. `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
Expand Down
302 changes: 182 additions & 120 deletions src/lib/components/header/OverflowMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
import type { LocateFixed } from "lucide-svelte";

/**
* A row a host adds to the top of the menu. `onclick` returns `false` to
* keep the menu open — a two-press confirmation that has only armed, whose
* second press has to land on the same row.
* A row a host adds to the menu. `onclick` returns `false` to keep the menu
* open — a two-press confirmation that has only armed, whose second press
* has to land on the same row.
*/
export interface MenuAction {
key: string;
/**
* Where it goes in the readout's menu (`bare`): with Hide interface at
* the top (`view`), with Share and Save as image (`layout`), or alone
* near the foot (`end`), where a destructive row is not the first thing
* a thumb lands on. The header's menu puts every action first.
*/
group: "view" | "layout" | "end";
/** Any lucide icon; they all share one component type. */
icon: typeof LocateFixed;
label: string;
Expand Down Expand Up @@ -45,9 +52,9 @@
*/

/*
* Rows the host puts first. On a short phone the readout hosts this menu in
* its head, and its own actions — Center View, Steps, Copy, Discard — come
* in here rather than taking a line of their own.
* Rows the host adds. On a short phone the readout hosts this menu in its
* head, and its own actions — Center View, Steps, Copy, Discard — come in
* here rather than taking a line of their own, each placed by its `group`.
*/
let {
actions = [],
Expand Down Expand Up @@ -169,133 +176,188 @@

{#if uiState.overflowOpen}
<div class="menu thin-scroll" role="menu" popover="manual" {@attach float}>
{#if actions.length > 0}
{#each actions as a (a.key)}
<button
class="menu-item"
class:danger={a.danger}
class:armed={a.armed}
role="menuitem"
onclick={() => runAction(a)}
>
<a.icon size={16} />
<span>{a.label}</span>
</button>
{/each}
{#if bare}
<!--
Hosted in the readout on a short screen, the menu is the whole of the
chrome, so it is ordered by use rather than by where each row came
from: looking at the board first, then this layout, then the app,
then map size, with a destructive row last but one.
-->
{@render hideRow()}
{@render actionRows("view")}

<div class="menu-divider"></div>
{/if}

{#if showSize}
<div class="menu-section">
<span class="menu-title">Map size</span>
<GridControls variant="stacked" />
</div>
{@render actionRows("layout")}
{@render shareRow()}
{@render imageRow()}

<div class="menu-divider"></div>
{@render statsRow()}
{@render importRows()}
{@render settingsRow()}

{#if showSize}
<div class="menu-divider"></div>
{@render sizeSection()}
{/if}

{#if actions.some((a) => a.group === "end")}
<div class="menu-divider"></div>
{@render actionRows("end")}
{/if}
{:else}
{#if actions.length > 0}
{@render actionRows()}
<div class="menu-divider"></div>
{/if}

{#if showSize}
{@render sizeSection()}
<div class="menu-divider"></div>
{/if}

{#if compact}{@render shareRow()}{/if}
{@render imageRow()}
{@render hideRow()}
{@render importRows()}
{@render statsRow()}
{@render settingsRow()}
{/if}

{#if compact}
<button
class="menu-item share"
role="menuitem"
onclick={() => uiState.shareLayout()}
>
<Share2 size={16} />
<span>Share this layout</span>
</button>
{/if}

<!--
Present at every width, and in preview too: it captures the board on
screen and writes nothing the visitor owns. The label says what comes
back rather than what it does, because "export" is what the two rows
around it also are — a code, a link, and now a picture.
-->
<button
class="menu-item"
role="menuitem"
disabled={uiState.isSavingImage}
onclick={() => uiState.saveLayoutImage()}
>
<ImageDown size={16} />
<span>{uiState.isSavingImage ? "Saving image…" : "Save as image"}</span>
</button>

<!--
Puts every other pixel away and leaves the board. It sits beside "Save
as image" because the two answer the same wish from opposite ends —
one takes the board out of the app, the other takes the app off the
board — and it belongs in preview for the same reason that one does:
it shows the visitor more of the layout and writes nothing they own.
-->
<button
class="menu-item"
role="menuitem"
onclick={() => uiState.setUiHidden(true)}
>
<EyeOff size={16} />
<span>Hide interface</span>
</button>

{#if showImport}
<button
class="menu-item"
role="menuitem"
onclick={() => uiState.openImport()}
>
<Download size={16} />
<span>Import code</span>
</button>
<!--
Everything this browser holds, to another one — see
`modals/TransferModal.svelte`. Absent in preview with Import: the
board on screen is not the visitor's to send.
-->
<button
class="menu-item"
role="menuitem"
onclick={() => uiState.openTransfer()}
>
<MonitorSmartphone size={16} />
<span>Transfer to another device</span>
</button>
{/if}

<!--
Read-only figures over the player's own islands, so present in preview
too: a previewed board is not counted, and nothing here writes.
-->
<button
class="menu-item"
role="menuitem"
onclick={() => uiState.openIslandStats()}
>
<LandPlot size={16} />
<span>Island stats</span>
</button>

<!--
Present in preview too, unlike Import: it changes how the app behaves
rather than what board is loaded, so there is nothing about a shared
layout that should put it out of reach.
-->
<button
class="menu-item"
role="menuitem"
onclick={() => uiState.openSettings()}
>
<Settings size={16} />
<span>Settings</span>
</button>

<div class="menu-divider"></div>

<DonateButton variant="menu" />
</div>
{/if}
</div>

{#snippet actionRows(group?: MenuAction["group"])}
{#each actions.filter((a) => !group || a.group === group) as a (a.key)}
<button
class="menu-item"
class:danger={a.danger}
class:armed={a.armed}
role="menuitem"
onclick={() => runAction(a)}
>
<a.icon size={16} />
<span>{a.label}</span>
</button>
{/each}
{/snippet}

{#snippet sizeSection()}
<div class="menu-section">
<span class="menu-title">Map size</span>
<GridControls variant="stacked" />
</div>
{/snippet}

{#snippet shareRow()}
<button
class="menu-item share"
role="menuitem"
onclick={() => uiState.shareLayout()}
>
<Share2 size={16} />
<span>Share this layout</span>
</button>
{/snippet}

<!--
Present at every width, and in preview too: it captures the board on
screen and writes nothing the visitor owns. The label says what comes
back rather than what it does, because "export" is what the two rows
around it also are — a code, a link, and now a picture.
-->
{#snippet imageRow()}
<button
class="menu-item"
role="menuitem"
disabled={uiState.isSavingImage}
onclick={() => uiState.saveLayoutImage()}
>
<ImageDown size={16} />
<span>{uiState.isSavingImage ? "Saving image…" : "Save as image"}</span>
</button>
{/snippet}

<!--
Puts every other pixel away and leaves the board. In the header's menu it
sits beside "Save as image" because the two answer the same wish from
opposite ends — one takes the board out of the app, the other takes the
app off the board; in the readout's it leads. It belongs in preview for
the same reason that one does: it shows the visitor more of the layout and
writes nothing they own.
-->
{#snippet hideRow()}
<button
class="menu-item"
role="menuitem"
onclick={() => uiState.setUiHidden(true)}
>
<EyeOff size={16} />
<span>Hide interface</span>
</button>
{/snippet}

<!--
Transfer is everything this browser holds, to another one — see
`modals/TransferModal.svelte`. Absent in preview with Import: the board on
screen is not the visitor's to send.
-->
{#snippet importRows()}
{#if showImport}
<button
class="menu-item"
role="menuitem"
onclick={() => uiState.openImport()}
>
<Download size={16} />
<span>Import code</span>
</button>
<button
class="menu-item"
role="menuitem"
onclick={() => uiState.openTransfer()}
>
<MonitorSmartphone size={16} />
<span>Transfer to another device</span>
</button>
{/if}
{/snippet}

<!--
Read-only figures over the player's own islands, so present in preview
too: a previewed board is not counted, and nothing here writes.
-->
{#snippet statsRow()}
<button
class="menu-item"
role="menuitem"
onclick={() => uiState.openIslandStats()}
>
<LandPlot size={16} />
<span>Island stats</span>
</button>
{/snippet}

<!--
Present in preview too, unlike Import: it changes how the app behaves
rather than what board is loaded, so there is nothing about a shared
layout that should put it out of reach.
-->
{#snippet settingsRow()}
<button
class="menu-item"
role="menuitem"
onclick={() => uiState.openSettings()}
>
<Settings size={16} />
<span>Settings</span>
</button>
{/snippet}

<style>
.overflow-wrap {
position: relative;
Expand Down
Loading