mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
fix: the map falls back to raster where the vector style cannot load, the tour layer pill fits narrow maps and stands on the side in 3D, the dashboard's widget column scrolls on its own, and the CI checks the watch sync and journey write-up broke
This commit is contained in:
@@ -136,7 +136,7 @@ function NeutralRail({
|
||||
canEdit: boolean
|
||||
onOpenWanderer?: () => void
|
||||
}) {
|
||||
const railHead = useRailHeadProps()
|
||||
const railHead = useRailHeadProps({ bare: true })
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<section className="flex h-full min-h-0 flex-col" aria-label={t('tours.planner.title')}>
|
||||
|
||||
@@ -23,4 +23,21 @@ describe('rail heads', () => {
|
||||
expect(head.className).not.toContain('border-b');
|
||||
expect(head.getAttribute('style')).toBeNull();
|
||||
});
|
||||
|
||||
it('FE-TOUR-RAILHEAD-002: a head of buttons only stands without a band in the touch tab, and keeps its strip on the desktop', () => {
|
||||
function Bare() {
|
||||
return <div data-testid="bare" {...useRailHeadProps({ bare: true })} />;
|
||||
}
|
||||
const { unmount } = render(<Bare />);
|
||||
expect(screen.getByTestId('bare').className).toBe(RAIL_HEAD);
|
||||
unmount();
|
||||
render(
|
||||
<FloatingRailHeads value>
|
||||
<Bare />
|
||||
</FloatingRailHeads>
|
||||
);
|
||||
const bare = screen.getByTestId('bare');
|
||||
expect(bare.className).not.toMatch(/border|rounded|bg-/);
|
||||
expect(bare.getAttribute('style')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,9 +15,17 @@ const FLOATING_RAIL_HEAD =
|
||||
*/
|
||||
export const FloatingRailHeads = createContext(false);
|
||||
|
||||
/** The class and style of a rail's head band, as the surrounding tab wants it. */
|
||||
export function useRailHeadProps(): { className: string; style?: { background: string } } {
|
||||
return use(FloatingRailHeads)
|
||||
? { className: FLOATING_RAIL_HEAD }
|
||||
: { className: RAIL_HEAD, style: { background: NEUTRAL_TINT } };
|
||||
/** A head that holds only buttons: in the touch tab they stand on their own, without a band. */
|
||||
const BARE_RAIL_HEAD = 'mx-3 mt-3 flex flex-none items-start gap-2';
|
||||
|
||||
/**
|
||||
* The class and style of a rail's head band, as the surrounding tab wants it.
|
||||
* `bare`: the head holds only buttons (the editor with nothing open).
|
||||
*/
|
||||
export function useRailHeadProps({ bare = false }: { bare?: boolean } = {}): {
|
||||
className: string;
|
||||
style?: { background: string };
|
||||
} {
|
||||
if (!use(FloatingRailHeads)) return { className: RAIL_HEAD, style: { background: NEUTRAL_TINT } };
|
||||
return { className: bare ? BARE_RAIL_HEAD : FLOATING_RAIL_HEAD };
|
||||
}
|
||||
|
||||
@@ -88,7 +88,20 @@ export default function TourTerrainMap(props: TourTerrainMapProps) {
|
||||
terrain.canReplay && !props.water ? (
|
||||
<GradeLegend stats={stats} unit={unit} onLayout={props.onLegendLayout} />
|
||||
) : null;
|
||||
const legendAbove = fit === 'stacked';
|
||||
const legendAbove = fit === 'stacked' || fit === 'side';
|
||||
const layerSwitcher = (vertical: boolean) => (
|
||||
<TourMapLayerSwitcher
|
||||
active={baseLayer}
|
||||
onChange={onBaseLayerChange}
|
||||
terrainActive
|
||||
onToggleTerrain={onExit}
|
||||
ferrataLayer={props.ferrataLayer}
|
||||
placeTool={props.placeTool}
|
||||
layers={props.tourLayers}
|
||||
compact={fit !== 'full'}
|
||||
vertical={vertical}
|
||||
/>
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (controlsHeight !== null) onControlsHeightChange?.(controlsHeight);
|
||||
@@ -112,21 +125,11 @@ export default function TourTerrainMap(props: TourTerrainMapProps) {
|
||||
insetInlineEnd: rightWidth + MAP_LAYER_SWITCHER_INSET,
|
||||
}}
|
||||
>
|
||||
{fit === 'side' && layerSwitcher(true)}
|
||||
<BaseMapCredit layer={baseLayer} />
|
||||
{legendAbove && legend}
|
||||
<div ref={attachRow} className="flex w-full items-end gap-3" data-fit={fit} data-testid="terrain-control-row">
|
||||
<div className="flex-none">
|
||||
<TourMapLayerSwitcher
|
||||
active={baseLayer}
|
||||
onChange={onBaseLayerChange}
|
||||
terrainActive
|
||||
onToggleTerrain={onExit}
|
||||
ferrataLayer={props.ferrataLayer}
|
||||
placeTool={props.placeTool}
|
||||
layers={props.tourLayers}
|
||||
compact={fit !== 'full'}
|
||||
/>
|
||||
</div>
|
||||
{fit !== 'side' && <div className="flex-none">{layerSwitcher(false)}</div>}
|
||||
<div className="grid min-w-0 flex-1 grid-cols-[1fr_auto_1fr] items-end gap-3">
|
||||
<span />
|
||||
{terrain.canReplay ? (
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// FE-TERRAIN-FIT-001 to FE-TERRAIN-FIT-002: the 3D map's bottom row steps down to fit between the panels.
|
||||
// FE-TERRAIN-FIT-001 to FE-TERRAIN-FIT-003: the 3D map's bottom row steps down to fit between the panels.
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { type ControlRowFit, useControlRowFit } from './useControlRowFit';
|
||||
|
||||
/** What the row's content needs at each step, in pixels. */
|
||||
const NEEDS: Record<ControlRowFit, number> = { full: 700, compact: 480, stacked: 400 };
|
||||
const NEEDS: Record<ControlRowFit, number> = { full: 700, compact: 480, stacked: 400, side: 260 };
|
||||
|
||||
function fakeRow(room: { width: number }, fit: () => ControlRowFit): HTMLDivElement {
|
||||
const row = document.createElement('div');
|
||||
@@ -49,4 +49,21 @@ describe('useControlRowFit', () => {
|
||||
rerender();
|
||||
expect(result.current.fit).toBe('full');
|
||||
});
|
||||
|
||||
it('FE-TERRAIN-FIT-003: where even the stacked row overflows, the layer pill goes to the side, and comes back with the room', () => {
|
||||
const room = { width: 300 };
|
||||
const { result, rerender } = renderHook(() => useControlRowFit());
|
||||
const row = fakeRow(room, () => result.current.fit);
|
||||
act(() => result.current.attachRow(row));
|
||||
rerender();
|
||||
rerender();
|
||||
expect(result.current.fit).toBe('side');
|
||||
|
||||
room.width = 399;
|
||||
rerender();
|
||||
expect(result.current.fit).toBe('side');
|
||||
room.width = 400;
|
||||
rerender();
|
||||
expect(result.current.fit).toBe('stacked');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,12 +2,14 @@ import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
||||
|
||||
/**
|
||||
* How the 3D map's bottom row fits between the side panels: `full` with every
|
||||
* label, `compact` with the layer pill on its icons, and `stacked` with the
|
||||
* grade legend on a row of its own above the dock as well.
|
||||
* label, `compact` with the layer pill on its icons, `stacked` with the grade
|
||||
* legend on a row of its own above the dock as well, and `side` with the layer
|
||||
* pill standing on the map's trailing edge, leaving the row to the dock (a map
|
||||
* as narrow as the iPad's beside the tour pane).
|
||||
*/
|
||||
export type ControlRowFit = 'full' | 'compact' | 'stacked';
|
||||
export type ControlRowFit = 'full' | 'compact' | 'stacked' | 'side';
|
||||
|
||||
const STEPS: readonly ControlRowFit[] = ['full', 'compact', 'stacked'];
|
||||
const STEPS: readonly ControlRowFit[] = ['full', 'compact', 'stacked', 'side'];
|
||||
|
||||
/**
|
||||
* Steps the row down while its content is wider than the room between the
|
||||
|
||||
Reference in New Issue
Block a user