feat(tours): plan ski and winter tours, snowshoeing and winter hiking among them

Ski becomes "Ski & winter", a type the planner plans with six disciplines
(alpine, snowboard, cross-country, ski touring, snowshoeing, winter hiking),
nothing preselected; saving needs a discipline, and a technique for
cross-country. Every leg is drawn straight between the points through
planner/skiRouting.ts, the one place the piste router will plug in, with its
heights from the elevation source and no ski time worked out.

The hike's winter label goes entirely: its migration, column, field, marks,
GPX rule, MCP field and strings. A hike is summer only; a ski tour with the
snowshoe discipline exports as snowshoeing. The unreleased ski migration takes
the six disciplines and the collection migration loses the winter column.

The pistes are offered for a ski tour, shown until switched off, and with no
tour open, never for a hike. Export, copy, collections, stages (untimed),
actual tracks, the atlas, list and day marks (one glyph per discipline), 3D,
planning over a ski import and list_tours/get_tour_plan know the planned ski
tour.
This commit is contained in:
Maurice
2026-10-20 18:27:53 +02:00
parent 204ee2ef86
commit 164a3633ac
116 changed files with 1675 additions and 1576 deletions
@@ -1,8 +0,0 @@
import type { WinterActivity } from '@trek/shared';
import { Footprints, Snowflake, type LucideIcon } from 'lucide-react';
/** HIK-01: the icon each winter label goes by, a snowflake for winter hiking and footprints in the snow for snowshoes. */
export const WINTER_ACTIVITY_ICON: Record<WinterActivity, LucideIcon> = {
winter_hike: Snowflake,
snowshoe: Footprints,
};
@@ -1,55 +0,0 @@
import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { TourDayRowAvatar } from '../TourDayRowFacts';
import { TourGradeTile } from '../tourParts';
import { WinterActivityPill, WinterCornerMark } from './winterMarks';
// FE-TOUR-WINTER-MARK-001 to FE-TOUR-WINTER-MARK-005
const hike = { tour_type: 'hike' as const, max_hiking_difficulty: 2, wanderer_ref: null, has_waypoints: true };
describe('winter marks (HIK-01)', () => {
it('FE-TOUR-WINTER-MARK-001: the corner mark names the label, and a hike without one shows none', () => {
const { container, rerender } = render(<WinterCornerMark activity={null} />);
expect(container).toBeEmptyDOMElement();
rerender(<WinterCornerMark activity="snowshoe" size={20} />);
const mark = screen.getByRole('img', { name: 'tours.winter.activity.snowshoe' });
expect(mark).toHaveAttribute('data-testid', 'tour-winter-mark');
expect(mark).toHaveStyle({ width: '20px', height: '20px' });
});
it('FE-TOUR-WINTER-MARK-002: the pill names the label in the head look it is given', () => {
render(<WinterActivityPill activity="winter_hike" className="head-pill" />);
const pill = screen.getByTestId('tour-detail-winter');
expect(pill).toHaveTextContent('tours.winter.activity.winter_hike');
expect(pill).toHaveClass('head-pill');
});
it('FE-TOUR-WINTER-MARK-003: a tour list tile carries the mark beside its grade', () => {
const { rerender } = render(<TourGradeTile tour={hike} />);
expect(screen.queryByTestId('tour-winter-mark')).toBeNull();
rerender(<TourGradeTile tour={{ ...hike, winter_activity: 'winter_hike' }} />);
expect(screen.getByRole('img', { name: 'tours.winter.activity.winter_hike' })).toBeInTheDocument();
expect(screen.getByText('T2')).toBeInTheDocument();
});
it('FE-TOUR-WINTER-MARK-004: the day plan tile stays as it was without a label, and carries the mark with one', () => {
const { container, rerender } = render(<TourDayRowAvatar tour={hike} size={32} />);
expect(container.firstElementChild).toHaveAttribute('data-testid', 'plan-tour-icon');
rerender(<TourDayRowAvatar tour={{ ...hike, winter_activity: 'snowshoe' }} size={50} />);
expect(screen.getByTestId('plan-tour-icon')).toHaveTextContent('T2');
expect(screen.getByTestId('tour-winter-mark')).toHaveStyle({ width: '22px' });
});
it('FE-TOUR-WINTER-MARK-005: the corner mark goes by the same icon as the head pill of its label', () => {
for (const activity of ['winter_hike', 'snowshoe'] as const) {
const icon = activity === 'snowshoe' ? 'lucide-footprints' : 'lucide-snowflake';
const mark = render(<WinterCornerMark activity={activity} />);
expect(mark.container.querySelector(`svg.${icon}`)).not.toBeNull();
mark.unmount();
const pill = render(<WinterActivityPill activity={activity} className="head-pill" />);
expect(pill.container.querySelector(`svg.${icon}`)).not.toBeNull();
pill.unmount();
}
});
});
@@ -1,50 +0,0 @@
import type { WinterActivity } from '@trek/shared';
import { useTranslation } from '../../../i18n';
import { fs } from '../../shared/DialogShell';
import { Tooltip } from '../../shared/Tooltip';
import { TourCornerMark } from '../TourCornerMark';
import { WINTER_ACTIVITY_ICON } from './winterActivityIcon';
/**
* HIK-01: a hike's winter label on its round tile, a frosted badge at the
* tile's top corner with the label's own icon, the one its head pill shows,
* the way the tile carries where a tour came from at its foot. Its tooltip
* names the label; nothing is drawn for a hike without one.
*/
export function WinterCornerMark({
activity,
size = 15,
}: {
activity: WinterActivity | null | undefined;
/** The badge's diameter in pixels, about half the tile's. */
size?: number;
}) {
const { t } = useTranslation();
if (!activity) return null;
return (
<TourCornerMark
icon={WINTER_ACTIVITY_ICON[activity]}
label={t(`tours.winter.activity.${activity}`)}
size={size}
testId="tour-winter-mark"
/>
);
}
/**
* HIK-01: the winter label as a pill of a tour's head, its icon in the info
* tone. The tooltip says it is the travellers' label only, never a check of
* the way in winter.
*/
export function WinterActivityPill({ activity, className }: { activity: WinterActivity; className: string }) {
const { t } = useTranslation();
const Icon = WINTER_ACTIVITY_ICON[activity];
return (
<Tooltip label={t('tours.winter.labelOnly')}>
<span data-testid="tour-detail-winter" className={className} style={fs(10.5)}>
<Icon size={11} strokeWidth={2} className="flex-none text-info" aria-hidden="true" />
{t(`tours.winter.activity.${activity}`)}
</span>
</Tooltip>
);
}