mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
fix(atlas): clear the client gates of the globe Atlas
Client lint, checks and tests were red on the globe Atlas: - The views own the globe and sky refs and hand them into useAtlasGlobe, so reading its state while rendering no longer counts as reading refs. - Helpers that shared a file with components move to their own modules (badge tiers, medal label, Dawarich notes, hub tabs, period label). - The place search derives its loading state, the search resets its active row on input, and the two silenced hook dependencies are named. - placeLabels, the hover chip and the overview figures are split up. - Raw text sizes become type tiers, the badge unlock docks on --z-overlay. - The stats card test follows the GlobeStat props; baselines lowered to the counts the run reported.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { Globe2, Layers, X } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router';
|
||||
import AtlasGlobe from '../../../components/AtlasGlobe/AtlasGlobe';
|
||||
import AtlasGlobe, { type AtlasGlobeHandle } from '../../../components/AtlasGlobe/AtlasGlobe';
|
||||
import type { GlobeEngine } from '../../../components/AtlasGlobe/GlobeEngine';
|
||||
import GlobePins, { type GlobePinsHandle } from '../../../components/AtlasGlobe/GlobePins';
|
||||
import GlobeSky from '../../../components/AtlasGlobe/GlobeSky';
|
||||
import GlobeSky, { type GlobeSkyHandle } from '../../../components/AtlasGlobe/GlobeSky';
|
||||
import '../../../components/AtlasGlobe/atlasGlobe.css';
|
||||
import { segmentStyle } from '../../../components/Map/mapControlShadow';
|
||||
import AtlasBadgeUnlock from '../../../pages/atlas/AtlasBadgeUnlock';
|
||||
@@ -27,7 +27,9 @@ import MAtlasHub from './hub/MAtlasHub';
|
||||
* same dialogs as the desktop. State and data come from useAtlasGlobe.
|
||||
*/
|
||||
export default function MAtlasGlobe(): React.ReactElement {
|
||||
const s = useAtlasGlobe();
|
||||
const globeRef = React.useRef<AtlasGlobeHandle>(null);
|
||||
const skyRef = React.useRef<GlobeSkyHandle>(null);
|
||||
const s = useAtlasGlobe({ globeRef, skyRef });
|
||||
const stats = useGlobeStats(s);
|
||||
const navigate = useNavigate();
|
||||
const [layersOpen, setLayersOpen] = React.useState(false);
|
||||
@@ -43,19 +45,18 @@ export default function MAtlasGlobe(): React.ReactElement {
|
||||
setSearchParams(next, { replace: true });
|
||||
setFocusSearch((n) => n + 1);
|
||||
}, [searchParams, setSearchParams]);
|
||||
const onFrame = React.useCallback(
|
||||
(e: GlobeEngine) => {
|
||||
s.skyRef.current?.layout(e);
|
||||
pinsRef.current?.layout(e);
|
||||
},
|
||||
[s.skyRef]
|
||||
);
|
||||
// A plain function: AtlasGlobe reads its props through a ref, so a new one
|
||||
// each render costs nothing.
|
||||
const onFrame = (e: GlobeEngine) => {
|
||||
skyRef.current?.layout(e);
|
||||
pinsRef.current?.layout(e);
|
||||
};
|
||||
|
||||
return (
|
||||
// h-dvh, as the classic phone Atlas: the shell gives no definite height (#1809).
|
||||
<div className="atlas-globe m-bleed relative h-dvh overflow-hidden">
|
||||
<AtlasGlobe
|
||||
ref={s.globeRef}
|
||||
ref={globeRef}
|
||||
fetchJson={s.fetchJson}
|
||||
dark
|
||||
labelFor={s.labelFor}
|
||||
@@ -69,7 +70,7 @@ export default function MAtlasGlobe(): React.ReactElement {
|
||||
insetBottom={170}
|
||||
/>
|
||||
<div className="pointer-events-none absolute inset-0">
|
||||
<GlobeSky ref={s.skyRef} dark />
|
||||
<GlobeSky ref={skyRef} dark />
|
||||
</div>
|
||||
<div className="pointer-events-none absolute inset-0 overflow-hidden">
|
||||
<GlobePins ref={pinsRef} pins={s.pins} />
|
||||
|
||||
@@ -89,7 +89,7 @@ export default function MAtlasLayersSheet({
|
||||
<div className="px-1 text-caption font-bold uppercase tracking-wide text-m-muted">
|
||||
{s.t('atlas.globe.colorBy')}
|
||||
</div>
|
||||
<MSegmented value={s.colorMode} onChange={s.setColorMode} options={modes} />
|
||||
<MSegmented<GlobeColorMode> value={s.colorMode} onChange={s.setColorMode} options={modes} />
|
||||
</div>
|
||||
</div>
|
||||
</MSheet>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { X } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import { useHubTabs } from '../../../../pages/atlas/AtlasHubRail';
|
||||
import type { AtlasGlobeState } from '../../../../pages/atlas/useAtlasGlobe';
|
||||
import { useHubTabs } from '../../../../pages/atlas/useHubTabs';
|
||||
import MChip from '../../../components/MChip';
|
||||
import MChipStrip from '../../../components/MChipStrip';
|
||||
import MIconBtn from '../../../components/MIconBtn';
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { BADGE_CATEGORIES, type Badge } from '@trek/shared';
|
||||
import { CalendarCheck, CheckCircle2, Hourglass, Target, Users, X } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import BadgeMedal, { TIERS } from '../../../../components/AtlasGlobe/BadgeMedal';
|
||||
import BadgeMedal from '../../../../components/AtlasGlobe/BadgeMedal';
|
||||
import { TIERS } from '../../../../components/AtlasGlobe/badgeTiers';
|
||||
import CountryFlag from '../../../../components/shared/CountryFlag';
|
||||
import { medalLabel } from '../../../../pages/atlas/AtlasGlobeBadges';
|
||||
import { badgeHolders, badgeLadder, formatNum } from '../../../../pages/atlas/atlasHubModel';
|
||||
import { fs } from '../../../../components/shared/DialogShell';
|
||||
import { badgeHolders, badgeLadder, formatNum, medalLabel } from '../../../../pages/atlas/atlasHubModel';
|
||||
import type { AtlasGlobeState } from '../../../../pages/atlas/useAtlasGlobe';
|
||||
import MIconBtn from '../../../components/MIconBtn';
|
||||
import MProgress from '../../../components/MProgress';
|
||||
@@ -52,7 +53,7 @@ export default function MHubBadges({ s }: { s: AtlasGlobeState }): React.ReactEl
|
||||
<span className="line-clamp-2 text-caption font-semibold leading-tight text-m-ink">
|
||||
{titleOf(s, b)}
|
||||
</span>
|
||||
<span className="text-[0.6875rem] tabular-nums text-m-muted">
|
||||
<span className="tabular-nums text-m-muted" style={fs(11, 'caption')}>
|
||||
{b.earned ? (b.year ?? '') : `${formatNum(b.current)} / ${formatNum(b.target)}`}
|
||||
</span>
|
||||
</button>
|
||||
@@ -196,7 +197,9 @@ function BadgeSheet({
|
||||
progress={x.target ? x.current / x.target : 0}
|
||||
label={medalLabel(x)}
|
||||
/>
|
||||
<span className="w-full truncate text-[0.6875rem] font-semibold text-m-muted">{titleOf(s, x)}</span>
|
||||
<span className="w-full truncate font-semibold text-m-muted" style={fs(11, 'caption')}>
|
||||
{titleOf(s, x)}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -2,9 +2,12 @@ import { Check, Globe2, Info, Loader2, RefreshCw, Star } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import { cityLine, countryLabel, formatDistance } from '../../../../components/Dawarich/dawarichAtlasModel';
|
||||
import { formatDuration } from '../../../../components/Dawarich/dawarichSuggestionModel';
|
||||
import { useDawarichAtlas } from '../../../../components/Dawarich/useDawarichAtlas';
|
||||
import {
|
||||
type DawarichAtlasTab,
|
||||
dawarichNotes,
|
||||
useDawarichAtlas,
|
||||
} from '../../../../components/Dawarich/useDawarichAtlas';
|
||||
import CountryFlag from '../../../../components/shared/CountryFlag';
|
||||
import { dawarichNotes } from '../../../../pages/atlas/AtlasGlobeDawarich';
|
||||
import type { AtlasGlobeState } from '../../../../pages/atlas/useAtlasGlobe';
|
||||
import MSegmented from '../../../components/MSegmented';
|
||||
import { M_CARD, M_INNER, MHubAction, MHubEmpty } from './mHubKit';
|
||||
@@ -24,7 +27,7 @@ export default function MHubDawarich({ s }: { s: AtlasGlobeState }): React.React
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<MSegmented
|
||||
<MSegmented<DawarichAtlasTab>
|
||||
value={d.tab}
|
||||
onChange={d.setTab}
|
||||
options={[
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Briefcase, Building2, CalendarDays, ChevronRight, Flame, Map as MapIcon, MapPin, Plane } from 'lucide-react';
|
||||
import { ChevronRight } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { continentCounts, WORLD_COUNTRIES } from '../../../../pages/atlas/atlasHubModel';
|
||||
import { fs } from '../../../../components/shared/DialogShell';
|
||||
import { continentCounts, overviewFigures, WORLD_COUNTRIES } from '../../../../pages/atlas/atlasHubModel';
|
||||
import type { AtlasGlobeState } from '../../../../pages/atlas/useAtlasGlobe';
|
||||
import MProgress from '../../../components/MProgress';
|
||||
import { M_CARD, MHubDawarichEntry, MHubHero, MHubSection, MHubTiles } from './mHubKit';
|
||||
@@ -41,7 +42,9 @@ export default function MHubOverview({ s }: { s: AtlasGlobeState }): React.React
|
||||
{typeof next.daysUntil === 'number' && (
|
||||
<span className="flex flex-none flex-col items-center rounded-[14px] bg-m-act px-3 py-1.5 text-m-actfg">
|
||||
<span className="text-subtitle font-bold tabular-nums leading-none">{next.daysUntil}</span>
|
||||
<span className="text-[0.625rem] font-semibold">{s.t('atlas.daysLeft')}</span>
|
||||
<span className="font-semibold" style={fs(10, 'caption')}>
|
||||
{s.t('atlas.daysLeft')}
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
<span className="min-w-0 flex-1">
|
||||
@@ -77,21 +80,7 @@ export default function MHubOverview({ s }: { s: AtlasGlobeState }): React.React
|
||||
/>
|
||||
)}
|
||||
|
||||
<MHubTiles
|
||||
tiles={[
|
||||
{ Icon: MapIcon, value: s.totals.regions, label: s.t('atlas.regions', { count: s.totals.regions }) },
|
||||
{ Icon: Briefcase, value: st?.totalTrips ?? 0, label: s.t('atlas.trips', { count: st?.totalTrips ?? 0 }) },
|
||||
{ Icon: MapPin, value: st?.totalPlaces ?? 0, label: s.t('atlas.places', { count: st?.totalPlaces ?? 0 }) },
|
||||
{ Icon: Building2, value: st?.totalCities ?? 0, label: s.t('atlas.cities', { count: st?.totalCities ?? 0 }) },
|
||||
{ Icon: CalendarDays, value: st?.totalDays ?? 0, label: s.t('atlas.days', { count: st?.totalDays ?? 0 }) },
|
||||
{ Icon: Flame, value: d?.streak ?? 0, label: s.t('atlas.yearsInRow', { count: d?.streak ?? 0 }) },
|
||||
{
|
||||
Icon: Plane,
|
||||
value: d?.tripsThisYear ?? 0,
|
||||
label: `${s.t('atlas.tripsIn', { count: d?.tripsThisYear ?? 0 })} ${new Date().getFullYear()}`,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<MHubTiles tiles={overviewFigures(s.t, s.totals.regions, d)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ import React from 'react';
|
||||
import {
|
||||
ActivityStatusLine,
|
||||
BasisBadges,
|
||||
periodLabel,
|
||||
UncountedBadges,
|
||||
} from '../../../../components/Atlas/tourActivity/tourActivityParts';
|
||||
import {
|
||||
distanceReading,
|
||||
heightReading,
|
||||
periodLabel,
|
||||
typeIcon,
|
||||
typeLabel,
|
||||
useDistanceUnit,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { ChevronRight, Flag, Globe2, Layers, Map as MapIcon, Plane, Users, X } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import BadgeMedal from '../../../../components/AtlasGlobe/BadgeMedal';
|
||||
import { medalLabel } from '../../../../pages/atlas/AtlasGlobeBadges';
|
||||
import { fs } from '../../../../components/shared/DialogShell';
|
||||
import { medalLabel } from '../../../../pages/atlas/atlasHubModel';
|
||||
import type { AtlasGlobeState } from '../../../../pages/atlas/useAtlasGlobe';
|
||||
import MIconBtn from '../../../components/MIconBtn';
|
||||
import MSheet from '../../../components/MSheet';
|
||||
@@ -82,7 +83,10 @@ export default function MHubTravellers({ s }: { s: AtlasGlobeState }): React.Rea
|
||||
<span className="flex min-w-0 items-center gap-1.5">
|
||||
<span className="truncate text-body font-semibold text-m-ink">{p.username}</span>
|
||||
{isMe && (
|
||||
<span className="flex-none rounded-full bg-m-act px-1.5 py-px text-[0.625rem] font-bold text-m-actfg">
|
||||
<span
|
||||
className="flex-none rounded-full bg-m-act px-1.5 py-px font-bold text-m-actfg"
|
||||
style={fs(10, 'caption')}
|
||||
>
|
||||
{s.t('atlas.globe.you')}
|
||||
</span>
|
||||
)}
|
||||
@@ -100,7 +104,9 @@ export default function MHubTravellers({ s }: { s: AtlasGlobeState }): React.Rea
|
||||
<span className="text-subtitle font-bold tabular-nums leading-none text-m-ink">
|
||||
{p.countries}
|
||||
</span>
|
||||
<span className="mt-0.5 text-[0.625rem] text-m-muted">{s.t('atlas.countries')}</span>
|
||||
<span className="mt-0.5 text-m-muted" style={fs(10, 'caption')}>
|
||||
{s.t('atlas.countries')}
|
||||
</span>
|
||||
</span>
|
||||
<ChevronRight
|
||||
size={16}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ChevronRight, type LucideIcon } from 'lucide-react';
|
||||
import React from 'react';
|
||||
import DawarichIcon from '../../../../components/shared/DawarichIcon';
|
||||
import { fs } from '../../../../components/shared/DialogShell';
|
||||
|
||||
/**
|
||||
* The phone's own pieces for the Atlas hub, on the mobile tokens (--m-*): a
|
||||
@@ -32,7 +33,9 @@ export function MHubHero({
|
||||
}}
|
||||
/>
|
||||
<div className="relative flex items-end gap-2">
|
||||
<span className="text-[3.25rem] font-bold tabular-nums leading-none tracking-tight text-m-ink">{value}</span>
|
||||
<span className="font-bold tabular-nums leading-none tracking-tight text-m-ink" style={fs(52, 'title')}>
|
||||
{value}
|
||||
</span>
|
||||
{unit && <span className="mb-1 text-subtitle font-semibold text-m-muted">{unit}</span>}
|
||||
</div>
|
||||
{children && <div className="relative mt-3.5">{children}</div>}
|
||||
@@ -60,7 +63,9 @@ export function MHubTiles({ tiles, cols = 2 }: { tiles: MHubTileData[]; cols?: 2
|
||||
<span className="whitespace-nowrap text-body font-bold tabular-nums leading-tight text-m-ink">
|
||||
{value}
|
||||
</span>
|
||||
<span className="line-clamp-2 text-[0.6875rem] leading-tight text-m-muted">{label}</span>
|
||||
<span className="line-clamp-2 leading-tight text-m-muted" style={fs(11, 'caption')}>
|
||||
{label}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -73,12 +78,7 @@ export function MHubTiles({ tiles, cols = 2 }: { tiles: MHubTileData[]; cols?: 2
|
||||
<span className="block text-title font-bold tabular-nums leading-tight text-m-ink">{value}</span>
|
||||
<span className="block truncate text-caption text-m-muted">{label}</span>
|
||||
</span>
|
||||
<Icon
|
||||
size={cols === 3 ? 22 : 30}
|
||||
strokeWidth={1.6}
|
||||
className="flex-none text-m-faint opacity-70"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<Icon size={30} strokeWidth={1.6} className="flex-none text-m-faint opacity-70" aria-hidden="true" />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user