Refine fullscreen layout and lock background viewport
This commit is contained in:
parent
f907f21942
commit
b90d20341e
3 changed files with 36 additions and 13 deletions
|
|
@ -21,6 +21,7 @@
|
|||
};
|
||||
const viewOrder = ["dashboardView", "historyView", "leaderboardView", "addView"];
|
||||
let transitionCleanupTimer = 0;
|
||||
let backgroundViewportHeight = 0;
|
||||
const categories = {
|
||||
income: ["Зарплата", "Фриланс", "Подарок", "Продажа", "Инвестиции", "Другое"],
|
||||
expense: ["Продукты", "Жильё", "Транспорт", "Здоровье", "Развлечения", "Покупки", "Другое"],
|
||||
|
|
@ -33,6 +34,9 @@
|
|||
}
|
||||
|
||||
function initTelegram() {
|
||||
captureBackgroundViewport();
|
||||
window.visualViewport?.addEventListener("resize", captureBackgroundViewport);
|
||||
window.addEventListener("resize", captureBackgroundViewport);
|
||||
if (!tg) return;
|
||||
safeTelegram(() => tg.ready());
|
||||
safeTelegram(() => tg.expand());
|
||||
|
|
@ -42,6 +46,21 @@
|
|||
if (tg.isVersionAtLeast?.("6.9")) safeTelegram(() => tg.setHeaderColor("#111111"));
|
||||
if (tg.isVersionAtLeast?.("7.7")) safeTelegram(() => tg.disableVerticalSwipes());
|
||||
if (tg.isVersionAtLeast?.("7.10")) safeTelegram(() => tg.setBottomBarColor("#111111"));
|
||||
safeTelegram(() => tg.onEvent?.("viewportChanged", captureBackgroundViewport));
|
||||
safeTelegram(() => tg.onEvent?.("fullscreenChanged", captureBackgroundViewport));
|
||||
window.setTimeout(captureBackgroundViewport, 350);
|
||||
window.setTimeout(captureBackgroundViewport, 900);
|
||||
}
|
||||
|
||||
function captureBackgroundViewport() {
|
||||
const height = Math.round(Math.max(
|
||||
Number(tg?.viewportStableHeight) || 0,
|
||||
Number(window.visualViewport?.height) || 0,
|
||||
window.innerHeight || 0,
|
||||
));
|
||||
if (height <= backgroundViewportHeight) return;
|
||||
backgroundViewportHeight = height;
|
||||
document.documentElement.style.setProperty("--app-background-height", `${height}px`);
|
||||
}
|
||||
|
||||
function showToast(message) {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
<meta name="color-scheme" content="dark" />
|
||||
<meta name="theme-color" content="#111111" />
|
||||
<title>Пожитки</title>
|
||||
<link rel="stylesheet" href="./styles.css?v=12" />
|
||||
<link rel="stylesheet" href="./styles.css?v=13" />
|
||||
<script src="./telegram-web-app.js"></script>
|
||||
<script src="./app.js?v=10" defer></script>
|
||||
<script src="./app.js?v=13" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<main class="shell">
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@
|
|||
--danger: #ff9188;
|
||||
--line: rgba(255, 255, 255, .18);
|
||||
--shadow: 0 18px 55px rgba(0, 0, 0, .2);
|
||||
--app-safe-top: max(var(--tg-content-safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px), env(safe-area-inset-top));
|
||||
--app-device-safe-top: max(var(--tg-safe-area-inset-top, 0px), env(safe-area-inset-top));
|
||||
--app-safe-top: max(var(--tg-content-safe-area-inset-top, 0px), calc(var(--app-device-safe-top) + 72px));
|
||||
--app-safe-right: max(var(--tg-content-safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px), env(safe-area-inset-right));
|
||||
--app-safe-bottom: max(var(--tg-content-safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom));
|
||||
--app-safe-left: max(var(--tg-content-safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px), env(safe-area-inset-left));
|
||||
|
|
@ -52,7 +53,10 @@ body {
|
|||
body::before,
|
||||
body::after {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: var(--app-background-height, 100dvh);
|
||||
z-index: -2;
|
||||
content: "";
|
||||
pointer-events: none;
|
||||
|
|
@ -81,13 +85,13 @@ button:focus { outline: none; }
|
|||
button:focus-visible { outline: 2px solid rgba(255, 255, 255, .72); outline-offset: 2px; }
|
||||
button:active { filter: brightness(.88); }
|
||||
|
||||
.shell { display: flex; flex-direction: column; width: min(100%, 560px); min-height: calc(var(--tg-viewport-stable-height, 100dvh) - 126px - var(--app-safe-top) - var(--app-safe-bottom)); margin: 0 auto; overflow-x: hidden; }
|
||||
.topbar { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 26px; text-shadow: 0 2px 14px rgba(0, 0, 0, .55); }
|
||||
.shell { display: flex; flex-direction: column; width: min(100%, 560px); min-height: calc(var(--tg-viewport-stable-height, 100dvh) - 126px - var(--app-safe-top) - var(--app-safe-bottom)); margin: 0 auto; }
|
||||
.topbar { display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 6px 2px 26px; text-shadow: 0 2px 14px rgba(0, 0, 0, .55); }
|
||||
.eyebrow { margin: 0 0 3px; text-transform: uppercase; letter-spacing: .12em; font-size: 10px; font-weight: 750; color: var(--muted); }
|
||||
h1, h2, p { margin-top: 0; }
|
||||
h1 { margin-bottom: 0; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
|
||||
h2 { margin: 0; font-size: 23px; letter-spacing: -.025em; }
|
||||
.user-chip { display: flex; align-items: center; gap: 8px; max-width: 48%; padding: 5px 11px 5px 5px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 12px; font-weight: 650; white-space: nowrap; overflow: hidden; }
|
||||
.user-chip { position: fixed; z-index: 9; top: calc(var(--app-device-safe-top) + 10px); left: 50%; display: flex; align-items: center; gap: 8px; max-width: min(42vw, 190px); padding: 5px 11px 5px 5px; border: 1px solid var(--line); border-radius: 999px; transform: translateX(-50%); background: var(--surface); font-size: 12px; font-weight: 650; white-space: nowrap; overflow: hidden; backdrop-filter: blur(50px); -webkit-backdrop-filter: blur(50px); }
|
||||
.mini-avatar { display: grid; flex: 0 0 auto; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: rgba(0, 0, 0, .28); color: var(--text); }
|
||||
|
||||
.view-stage { display: flex; flex: 1; flex-direction: column; width: 100%; min-width: 0; }
|
||||
|
|
@ -193,12 +197,12 @@ h2 { margin: 0; font-size: 23px; letter-spacing: -.025em; }
|
|||
.leader-percent.negative { color: var(--danger); }
|
||||
.friend-hint { margin: 13px 18px; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; }
|
||||
|
||||
.bottom-nav { position: fixed; z-index: 10; right: max(12px, calc(var(--app-safe-right) + 8px)); bottom: max(12px, calc(var(--app-safe-bottom) + 8px)); left: max(12px, calc(var(--app-safe-left) + 8px)); display: flex; align-items: stretch; gap: 10px; width: auto; max-width: 540px; height: 62px; margin: 0 auto; }
|
||||
.nav-tabs { display: grid; flex: 1; grid-template-columns: repeat(3, 1fr); gap: 4px; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(50px); -webkit-backdrop-filter: blur(50px); }
|
||||
.bottom-nav { position: fixed; z-index: 10; bottom: max(12px, calc(var(--app-safe-bottom) + 8px)); left: 50%; display: flex; align-items: stretch; gap: 9px; width: min(340px, calc(100% - var(--app-safe-left) - var(--app-safe-right) - 24px)); height: 54px; transform: translateX(-50%); }
|
||||
.nav-tabs { display: grid; flex: 1; grid-template-columns: repeat(3, 1fr); gap: 2px; min-width: 0; padding: 5px 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(50px); -webkit-backdrop-filter: blur(50px); }
|
||||
.nav-tabs button { display: grid; place-items: center; gap: 1px; min-width: 0; padding: 2px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 9px; font-weight: 650; }
|
||||
.nav-tabs button > span { font-size: 20px; line-height: 26px; }
|
||||
.nav-tabs button.active { color: var(--accent); background: rgba(255, 255, 255, .07); }
|
||||
.app-action { display: grid; flex: 0 0 62px; place-items: center; width: 62px; padding: 0; border: 1px solid rgba(255, 255, 255, .35); border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 34px; font-weight: 500; line-height: 1; box-shadow: var(--shadow); transition: flex-basis .24s ease, width .24s ease, border-radius .24s ease; }
|
||||
.nav-tabs button.active { color: var(--accent); }
|
||||
.app-action { display: grid; flex: 0 0 54px; place-items: center; width: 54px; padding: 0; border: 1px solid rgba(255, 255, 255, .35); border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 31px; font-weight: 500; line-height: 1; box-shadow: var(--shadow); transition: flex-basis .24s ease, width .24s ease, border-radius .24s ease; }
|
||||
.app-action:disabled { opacity: .72; cursor: default; }
|
||||
.form-open .nav-tabs { display: none; }
|
||||
.form-open .app-action { flex-basis: 100%; width: 100%; border-radius: 999px; font-size: 16px; font-weight: 800; }
|
||||
|
|
@ -226,12 +230,12 @@ input::placeholder { color: rgba(255, 255, 255, .48); }
|
|||
select option { color: #ffffff; background: #252525; }
|
||||
|
||||
@keyframes view-stage-from-right {
|
||||
from { transform: translate3d(34px, 0, 0); }
|
||||
from { transform: translate3d(100vw, 0, 0); }
|
||||
to { transform: translate3d(0, 0, 0); }
|
||||
}
|
||||
|
||||
@keyframes view-stage-from-left {
|
||||
from { transform: translate3d(-34px, 0, 0); }
|
||||
from { transform: translate3d(-100vw, 0, 0); }
|
||||
to { transform: translate3d(0, 0, 0); }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue