7cd4474945
CI / changes (pull_request) Successful in 1s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 49s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m0s
The ad banner lives inside the grown game header (`.nav.grow`, portrait game only). That rule carried `flex: 1 1 auto`, so on a short viewport the flex algorithm shrank the header — clipping the banner (`.ad` is `overflow:hidden`) — *and* the board's scroll area at the same time. The banner and the board ended up splitting the vertical squeeze. Drop the shrink (`flex: 1 0 auto`): the header still grows into spare height (banner under the title, board pinned to the bottom), but on a short viewport it holds its natural height and the board's own scroll (`.stage`) absorbs the whole squeeze. The banner now keeps a constant height. Portrait-only: in landscape and on every other screen `.nav` is already `flex: 0 0 auto`, so the banner never shrank there. Verified in the mock UI (portrait, live banner): at 440px tall the banner held 30px (was clipped to 14px) while the board scrolled; the tall-viewport layout is unchanged. Full UI suite green locally (check, 272 unit, build, bundle-size, 140 e2e).
144 lines
4.9 KiB
Svelte
144 lines
4.9 KiB
Svelte
<script lang="ts">
|
|
import { navigate } from '../lib/router.svelte';
|
|
import { insideTelegram } from '../lib/telegram';
|
|
import { connection } from '../lib/connection.svelte';
|
|
import { t } from '../lib/i18n/index.svelte';
|
|
import { app } from '../lib/app.svelte';
|
|
import Spinner from './Spinner.svelte';
|
|
import AdBanner from './AdBanner.svelte';
|
|
|
|
let { title, back, grow = false }: { title: string; back?: string; grow?: boolean } = $props();
|
|
|
|
// Inside Telegram the native header back button (App.svelte) is the back control, so
|
|
// the app's own chevron is hidden to avoid two back affordances.
|
|
const showBack = $derived(!!back && !insideTelegram());
|
|
</script>
|
|
|
|
<header class="nav" class:grow>
|
|
<div class="bar">
|
|
{#if showBack}
|
|
<button class="icon back" onclick={() => back && navigate(back)} aria-label="Back">
|
|
<span class="chev"></span>
|
|
</button>
|
|
{:else}
|
|
<span class="spacer"></span>
|
|
{/if}
|
|
{#if connection.online}
|
|
<h1>{title}</h1>
|
|
{:else}
|
|
<h1 class="connecting"><Spinner /> <span>{t('connection.connecting')}</span></h1>
|
|
{/if}
|
|
<!-- A right-hand spacer balances the back button so the title stays centred. -->
|
|
<span class="spacer"></span>
|
|
</div>
|
|
<!-- The ad banner lives inside the nav, directly under the title bar, so it sits in the
|
|
same place on every screen — and in the game (grown nav) the spare height falls below
|
|
it (banner under the title, board pinned to the bottom). -->
|
|
{#if app.profile?.banner && app.profile.banner.campaigns.length}
|
|
<AdBanner
|
|
campaigns={app.profile.banner.campaigns}
|
|
timings={app.profile.banner.timings}
|
|
reduceMotion={app.reduceMotion}
|
|
/>
|
|
{/if}
|
|
</header>
|
|
|
|
<style>
|
|
/* By default the nav bar is minimal and the content fills the screen. In the game
|
|
it grows (class `grow`) to push the board and controls to the bottom. */
|
|
.nav {
|
|
flex: 0 0 auto;
|
|
min-height: 52px;
|
|
background: var(--bg-elev);
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex;
|
|
flex-direction: column;
|
|
user-select: none;
|
|
-webkit-user-select: none;
|
|
}
|
|
.nav.grow {
|
|
/* Grow into spare height (banner under the title, the board pinned to the bottom), but
|
|
never shrink: on a short viewport the banner keeps its height and the board's own
|
|
scroll (.stage) absorbs the squeeze, instead of the banner and the board splitting it. */
|
|
flex: 1 0 auto;
|
|
}
|
|
.bar {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--gap);
|
|
padding: 10px var(--pad);
|
|
}
|
|
h1 {
|
|
font-size: 1.05rem;
|
|
margin: 0;
|
|
flex: 1;
|
|
text-align: center;
|
|
font-weight: 600;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
/* The "Connecting…" indicator replaces the title while offline: a spinner + muted label,
|
|
centred like the title so the bar does not shift. */
|
|
h1.connecting {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
color: var(--text-muted);
|
|
font-weight: 500;
|
|
}
|
|
.icon,
|
|
.spacer {
|
|
min-width: 40px;
|
|
height: 36px;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.back {
|
|
background: none;
|
|
border: none;
|
|
color: var(--text);
|
|
border-radius: var(--radius-sm);
|
|
padding: 0 8px;
|
|
}
|
|
.back:hover {
|
|
background: var(--surface-2);
|
|
}
|
|
/* A thin, compact "<" drawn from two borders — lighter than a glyph. */
|
|
.chev {
|
|
width: 11px;
|
|
height: 11px;
|
|
border-left: 2.5px solid currentColor;
|
|
border-bottom: 2.5px solid currentColor;
|
|
transform: rotate(45deg);
|
|
margin-left: 3px;
|
|
}
|
|
/* Telegram fullscreen: TG's native nav occupies the band between the device notch
|
|
(--tg-safe-top) and --tg-content-top. Our header spans that full band (so the layout below
|
|
is unchanged) and centres the title within it, BELOW the notch — lining it up vertically
|
|
with Telegram's own back/menu controls, which sit in the band's corners. */
|
|
:global(html.tg-fullscreen) .bar {
|
|
/* The bar is sized by its content + padding — in Telegram the title is the only child (the
|
|
back chevron is hidden), so min-height (the nav-band height) doesn't bind. Without the
|
|
(removed) hamburger that content shrank and the bar sat flush under Telegram's native nav
|
|
band. So **padding-top** is the lever: it drops the title clear of the band — the notch
|
|
plus a **10px** gap (was 6). A fixed px (not rem/em) gap so the clearance from Telegram's
|
|
native controls stays constant if the user scales up the font (the title then grows
|
|
downward and the bar with it). (Owner-tunable: the 10px.) */
|
|
min-height: var(--tg-content-top);
|
|
box-sizing: border-box;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding-top: calc(var(--tg-safe-top) + 16px);
|
|
padding-bottom: 6px;
|
|
}
|
|
:global(html.tg-fullscreen) .spacer {
|
|
display: none;
|
|
}
|
|
:global(html.tg-fullscreen) h1 {
|
|
flex: 0 1 auto;
|
|
}
|
|
</style>
|