Repeat tile placement confirmation under the hand on phones
On narrow layouts the decision panel sits above the board, so confirming a tile chosen in the rack meant scrolling back up past the board. Extract the place confirmation into PlaceConfirm, used by the action panel and, below 700px, directly under the rack, where it scrolls into view when it opens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5f5aee5ac0
commit
2cfb5332f6
3 changed files with 86 additions and 29 deletions
|
|
@ -5,6 +5,7 @@
|
|||
import Chat from "./lib/Chat.svelte";
|
||||
import Hand from "./lib/Hand.svelte";
|
||||
import Log from "./lib/Log.svelte";
|
||||
import PlaceConfirm from "./lib/PlaceConfirm.svelte";
|
||||
import Players from "./lib/Players.svelte";
|
||||
import PriceTable from "./lib/PriceTable.svelte";
|
||||
import Status from "./lib/Status.svelte";
|
||||
|
|
@ -30,7 +31,10 @@
|
|||
/>
|
||||
</div>
|
||||
{#if store.seats.length > 0 && store.replayAt === undefined}
|
||||
<div class="hand"><Hand {store} /></div>
|
||||
<div class="hand">
|
||||
<Hand {store} />
|
||||
<div class="hand-confirm"><PlaceConfirm {store} nearHand /></div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="market">
|
||||
<ChainTable {state} seats={store.seats} />
|
||||
|
|
@ -70,6 +74,12 @@
|
|||
.hand {
|
||||
grid-area: hand;
|
||||
}
|
||||
/* Phones show the decision above the board: repeat the placement confirmation under the rack. */
|
||||
@media (min-width: 700px) {
|
||||
.hand-confirm {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
.market {
|
||||
grid-area: market;
|
||||
display: grid;
|
||||
|
|
|
|||
|
|
@ -7,22 +7,14 @@
|
|||
merger,
|
||||
sharePrice,
|
||||
sharePurchaseLimit,
|
||||
tileLabel,
|
||||
type ChainId,
|
||||
type Shares,
|
||||
} from "acquire-engine";
|
||||
import ChainMark from "./ChainMark.svelte";
|
||||
import PlaceConfirm from "./PlaceConfirm.svelte";
|
||||
import StockSwap from "./StockSwap.svelte";
|
||||
import { mergerPreview } from "./mergerPreview";
|
||||
import {
|
||||
adjustShares,
|
||||
canBuy,
|
||||
canDispose,
|
||||
describePlacement,
|
||||
disposalPresets,
|
||||
nextDefunctChoices,
|
||||
ofType,
|
||||
} from "./decisions";
|
||||
import { adjustShares, canBuy, canDispose, disposalPresets, nextDefunctChoices, ofType } from "./decisions";
|
||||
import { chainName } from "./format";
|
||||
import type { ViewerStore } from "./store.svelte";
|
||||
|
||||
|
|
@ -72,12 +64,6 @@
|
|||
const price = (chain: ChainId) => sharePrice(chain, chainSize(game.board, chain));
|
||||
const cost = $derived(Object.entries(shares).reduce((sum, [chain, n]) => sum + n * price(chain as ChainId), 0));
|
||||
const total = $derived(Object.values(shares).reduce((sum, n) => sum + n, 0));
|
||||
|
||||
function placeSelected(): void {
|
||||
if (store.selected !== undefined) {
|
||||
store.send({ type: "place", tile: tileLabel(store.selected) });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if moves.length > 0 && !store.sending}
|
||||
|
|
@ -115,18 +101,7 @@
|
|||
|
||||
{#if game.phase === "place"}
|
||||
{#if store.selected !== undefined}
|
||||
<p>
|
||||
{t("place.effect", {
|
||||
tile: tileLabel(store.selected),
|
||||
effect: describePlacement(game, store.selected, lang),
|
||||
})}
|
||||
</p>
|
||||
<button type="button" class="actionable primary" onclick={placeSelected}
|
||||
>{t("place.button", { tile: tileLabel(store.selected) })}</button
|
||||
>
|
||||
<button type="button" class="actionable" onclick={() => (store.selected = undefined)}
|
||||
>{t("place.another")}</button
|
||||
>
|
||||
<PlaceConfirm {store} />
|
||||
{:else if legal("place")}
|
||||
<p>{t("place.choose")}</p>
|
||||
{/if}
|
||||
|
|
|
|||
72
packages/viewer/src/lib/PlaceConfirm.svelte
Normal file
72
packages/viewer/src/lib/PlaceConfirm.svelte
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<script lang="ts">
|
||||
import { tileLabel } from "acquire-engine";
|
||||
import { describePlacement } from "./decisions";
|
||||
import type { ViewerStore } from "./store.svelte";
|
||||
|
||||
let {
|
||||
store,
|
||||
nearHand = false,
|
||||
}: {
|
||||
store: ViewerStore;
|
||||
/** The copy under the rack on phones, where the decision panel is above the board, out of view. */
|
||||
nearHand?: boolean;
|
||||
} = $props();
|
||||
|
||||
const t = $derived(store.lang.t);
|
||||
const tile = $derived(
|
||||
store.state?.phase === "place" && store.moves.length > 0 && !store.sending ? store.selected : undefined
|
||||
);
|
||||
|
||||
let row = $state<HTMLElement>();
|
||||
// Bring the confirmation into view when it opens below a rack at the bottom of the screen.
|
||||
$effect(() => {
|
||||
if (nearHand && row && tile !== undefined && row.getClientRects().length > 0) {
|
||||
const still = matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
row.scrollIntoView({ block: "nearest", behavior: still ? "auto" : "smooth" });
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if tile !== undefined}
|
||||
<div class="place-confirm" class:near-hand={nearHand} bind:this={row}>
|
||||
<p>{t("place.effect", { tile: tileLabel(tile), effect: describePlacement(store.state!, tile, store.lang) })}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="actionable primary"
|
||||
onclick={() => store.send({ type: "place", tile: tileLabel(tile) })}
|
||||
>{t("place.button", { tile: tileLabel(tile) })}</button
|
||||
>
|
||||
<button type="button" class="actionable" onclick={() => (store.selected = undefined)}>{t("place.another")}</button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.place-confirm.near-hand {
|
||||
margin-top: 8px;
|
||||
padding: 10px 12px 12px;
|
||||
background: var(--panel);
|
||||
}
|
||||
p {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
button {
|
||||
margin-block: 4px;
|
||||
margin-inline: 0 8px;
|
||||
padding: 6px 12px;
|
||||
min-height: 36px;
|
||||
background: var(--page);
|
||||
color: var(--ink);
|
||||
font: inherit;
|
||||
border: none;
|
||||
}
|
||||
button.primary {
|
||||
background: var(--accent);
|
||||
color: var(--on-accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
@media (pointer: coarse) {
|
||||
button {
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue