Viewer: phone layout for landscape

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
BigBodyCobainandClaude Fable 5.2 committed 2026-11-23 14:39:57 -07:00
1 parent ba646c1f04
commit 3db0803f74
2 files changed
+45 -7

No files matched your search

+11 -3
View File
@@ -43,7 +43,7 @@ import { layersOnLoad, layersToStore, readLayerRev, withHiddenOff, writeLayerRev
import { AboutModal, StaleBanner, ViewerHeaderCard, ViewerToolsPanel } from '@/viewer/ViewerChrome';
import SkillModal from '@/viewer/SkillModal';
import TokenCard from '@/viewer/TokenCard';
import { PHONE_QUERY, PhoneNav, PhoneStyles, scrollToMarker, usePhone } from '@/viewer/phone';
import { PHONE_LANDSCAPE_QUERY, PHONE_QUERY, PhoneNav, PhoneStyles, scrollToMarker, usePhone } from '@/viewer/phone';
import ChatPanel from '@/viewer/chat/ChatPanel';
const MaplibreViewer = dynamic(() => import('@/components/MaplibreViewer'), { ssr: false });
@@ -89,6 +89,14 @@ export default function ViewerDashboard() {
// Right-click: latest satellite picture of that spot, asked for by the visitor's own browser.
const { regionDossier, regionDossierLoading, handleMapRightClick } = useRegionDossier(selectedEntity, setSelectedEntity);
const phone = usePhone();
const [sideways, setSideways] = useState(false);
useEffect(() => {
const query = window.matchMedia(PHONE_LANDSCAPE_QUERY);
const update = () => setSideways(query.matches);
update();
query.addEventListener('change', update);
return () => query.removeEventListener('change', update);
}, []);
const [leftOpen, setLeftOpen] = useState(true);
const [rightOpen, setRightOpen] = useState(true);
const [legendOpen, setLegendOpen] = useState(false);
@@ -403,7 +411,7 @@ export default function ViewerDashboard() {
className="sb-left-col absolute left-6 top-24 bottom-[32px] w-80 flex flex-col gap-3 z-[201] pointer-events-auto overflow-y-auto styled-scrollbar pl-2 pr-2 hud-zone"
style={{ direction: 'rtl' }}
data-open={showLeft}
animate={phone ? { x: 0, y: showLeft ? 0 : 900 } : { x: showLeft ? 0 : -360, y: 0 }}
animate={phone ? (sideways ? { x: showLeft ? 0 : -700, y: 0 } : { x: 0, y: showLeft ? 0 : 900 }) : { x: showLeft ? 0 : -360, y: 0 }}
transition={{ type: 'spring', damping: 30, stiffness: 250 }}
>
<div className="contents" style={{ direction: 'ltr' }}>
@@ -508,7 +516,7 @@ export default function ViewerDashboard() {
<motion.div
className="sb-right-col absolute right-6 top-24 bottom-[32px] w-[400px] flex flex-col gap-4 z-[200] pointer-events-auto overflow-y-auto styled-scrollbar pr-2 pl-2 hud-zone"
data-open={showRight}
animate={phone ? { x: 0, y: showRight ? 0 : 900 } : { x: showRight ? 0 : 440, y: 0 }}
animate={phone ? (sideways ? { x: showRight ? 0 : -700, y: 0 } : { x: 0, y: showRight ? 0 : 900 }) : { x: showRight ? 0 : 440, y: 0 }}
transition={{ type: 'spring', damping: 30, stiffness: 250 }}
>
<TokenCard />
+34 -4
View File
@@ -4,15 +4,20 @@
* Phone layout for the public viewer.
*
* The app's panels are built for a wide screen. On a phone the map takes the
* whole screen, a bar of four buttons sits at the bottom, and the two side
* columns become sheets that slide up over the lower part of the map, one at
* a time.
* whole screen and the two side columns become sheets, one at a time.
* - Upright: four buttons along the bottom; a sheet slides up over the lower
* part of the map.
* - On its side: the screen is wide but short, so the buttons run down the
* left edge and a sheet opens beside them at full height.
*/
import React, { useEffect, useState } from 'react';
import { Info, Layers, MessagesSquare, Radar } from 'lucide-react';
export const PHONE_QUERY = '(max-width: 820px)';
/** A phone held upright (narrow) or on its side (short). */
export const PHONE_QUERY = '(max-width: 820px), (max-height: 520px)';
/** A phone on its side: wide but very short. */
export const PHONE_LANDSCAPE_QUERY = '(max-height: 520px) and (min-width: 560px)';
/** True on a phone-sized screen. False during the first render, so the server and browser agree. */
export function usePhone(): boolean {
@@ -145,6 +150,31 @@ export function PhoneStyles() {
.maplibregl-popup-content { max-width: calc(100vw - 20px) !important; }
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; }
}
/* phone on its side */
@media ${PHONE_LANDSCAPE_QUERY} {
.sb-phone-nav {
top: 0; bottom: 0; right: auto; left: 0;
width: calc(60px + env(safe-area-inset-left, 0px));
grid-template-columns: 1fr; grid-auto-rows: 1fr;
padding: 6px 5px 6px calc(5px + env(safe-area-inset-left, 0px));
border-top: 0; border-right: 1px solid rgba(69, 216, 255, 0.26);
background: linear-gradient(90deg, rgba(3, 8, 16, 0.99), rgba(8, 18, 32, 0.96));
}
.sb-phone-nav-btn { min-height: 0; font-size: 9px; letter-spacing: 0.1em; }
html .sb-left-col, html .sb-right-col {
top: 0 !important; bottom: 0 !important; right: auto !important;
left: calc(60px + env(safe-area-inset-left, 0px)) !important;
width: min(400px, 54vw) !important;
padding: 10px 10px 12px !important;
border-top: 0; border-right: 1px solid rgba(69, 216, 255, 0.34);
border-radius: 0 16px 16px 0;
box-shadow: 18px 0 50px -10px rgba(0, 0, 0, 0.85);
}
.sb-brandbar { left: calc(72px + env(safe-area-inset-left, 0px)) !important; }
.maplibregl-ctrl-bottom-left { bottom: 0 !important; left: calc(60px + env(safe-area-inset-left, 0px)) !important; }
.maplibregl-ctrl-bottom-right { bottom: 0 !important; }
}
`}</style>
);
}