From a3fc6965109fd7470de8dd25b4f3b0e74fe7b9f6 Mon Sep 17 00:00:00 2001
From: Maurice
Date: Fri, 23 Oct 2026 15:20:43 +0200
Subject: [PATCH] feat(assistant): the chat's cards wear the trip dialogs' look
The cards were rows of badges in badges with no head of their own; they now
follow the frame #2541 gave the trip's dialogs and booking cards.
- Every answer card and the change card open on a tinted head band: a raised
tile with the icon (a route its sketch), the kind as an eyebrow, the title,
one quiet line and the count; the change card turns green once decided.
- Figures are framed fields under their labels (a route's distance, climb,
descent, time), the parts of a card sit under eyebrows (height profile,
stops), and the ways onward sit in a foot bar across the card.
- A route's stops are a timeline down a line, each walk on the line between
two stops; the ways of a route are calm choices with their figures in one
line and how they differ from the chosen one in another.
- Packing, to-dos, the journal, Vacay and the Atlas get the band; quantities
and weights are quiet figures, an expense's place and split share one line.
---
.../Assistant/AssistantChangeCard.tsx | 49 ++---
.../cards/atlas/AtlasCountryCard.tsx | 9 +-
.../Assistant/cards/budget/ExpenseChange.tsx | 10 +-
.../cards/budget/ExpensesCard.test.tsx | 13 +-
.../cards/journey/JourneyEntriesBlock.tsx | 38 ++--
.../cards/packing/PackingListCard.tsx | 62 +++---
.../Assistant/cards/packing/TodoListCard.tsx | 34 +--
.../cards/packing/checklistParts.tsx | 2 +-
.../Assistant/cards/packing/packingParts.tsx | 27 ++-
.../Assistant/cards/parts/CardFrame.tsx | 4 +-
.../Assistant/cards/parts/CardHeader.tsx | 83 ++++++--
.../Assistant/cards/parts/CardRows.tsx | 6 +-
.../Assistant/cards/parts/CardSection.tsx | 49 +++++
.../Assistant/cards/tour/TourFigureLine.tsx | 46 ++++
.../Assistant/cards/tour/TourRouteActions.tsx | 7 +-
.../cards/tour/TourRouteCard.test.tsx | 12 +-
.../Assistant/cards/tour/TourRouteCard.tsx | 38 ++--
.../Assistant/cards/tour/TourRouteHead.tsx | 81 ++++---
.../Assistant/cards/tour/TourRouteInRow.tsx | 47 +++--
.../Assistant/cards/tour/TourRouteProfile.tsx | 4 +-
.../Assistant/cards/tour/TourRouteStops.tsx | 183 ++++++++--------
.../Assistant/cards/tour/TourWays.tsx | 199 +++++++++++++-----
.../cards/vacay/VacayAnswerBlock.tsx | 10 +-
shared/src/i18n/ar/assistantTour.ts | 1 +
shared/src/i18n/az/assistantTour.ts | 1 +
shared/src/i18n/br/assistantTour.ts | 1 +
shared/src/i18n/ca/assistantTour.ts | 1 +
shared/src/i18n/cs/assistantTour.ts | 1 +
shared/src/i18n/de/assistantTour.ts | 1 +
shared/src/i18n/en/assistantTour.ts | 1 +
shared/src/i18n/es/assistantTour.ts | 1 +
shared/src/i18n/et/assistantTour.ts | 1 +
shared/src/i18n/fr/assistantTour.ts | 1 +
shared/src/i18n/gr/assistantTour.ts | 1 +
shared/src/i18n/hu/assistantTour.ts | 1 +
shared/src/i18n/id/assistantTour.ts | 1 +
shared/src/i18n/it/assistantTour.ts | 1 +
shared/src/i18n/ja/assistantTour.ts | 1 +
shared/src/i18n/ko/assistantTour.ts | 1 +
shared/src/i18n/nl/assistantTour.ts | 1 +
shared/src/i18n/pl/assistantTour.ts | 1 +
shared/src/i18n/ru/assistantTour.ts | 1 +
shared/src/i18n/sk/assistantTour.ts | 1 +
shared/src/i18n/sv/assistantTour.ts | 1 +
shared/src/i18n/th/assistantTour.ts | 1 +
shared/src/i18n/tr/assistantTour.ts | 1 +
shared/src/i18n/uk/assistantTour.ts | 1 +
shared/src/i18n/vi/assistantTour.ts | 1 +
shared/src/i18n/zh-TW/assistantTour.ts | 1 +
shared/src/i18n/zh/assistantTour.ts | 1 +
50 files changed, 699 insertions(+), 341 deletions(-)
create mode 100644 client/src/components/Assistant/cards/parts/CardSection.tsx
create mode 100644 client/src/components/Assistant/cards/tour/TourFigureLine.tsx
diff --git a/client/src/components/Assistant/AssistantChangeCard.tsx b/client/src/components/Assistant/AssistantChangeCard.tsx
index ddc631b81..319c4373a 100644
--- a/client/src/components/Assistant/AssistantChangeCard.tsx
+++ b/client/src/components/Assistant/AssistantChangeCard.tsx
@@ -1,10 +1,11 @@
-import { Check, LoaderCircle, MapPin, Undo2 } from 'lucide-react';
+import { Check, CheckCheck, ListChecks, LoaderCircle, MapPin, Undo2 } from 'lucide-react';
import { type ReactNode, useEffect, useMemo, useState } from 'react';
import { useTranslation } from '../../i18n';
import { blockKeyOf } from '../../store/assistantMapModel';
import { chatOf, useAssistantStore } from '../../store/assistantStore';
import { useTripStore } from '../../store/tripStore';
+import { DialogButton, NEUTRAL_TINT } from '../shared/DialogShell';
import { useToast } from '../shared/Toast';
import { Tooltip } from '../shared/Tooltip';
import AssistantCompareSwitch from './AssistantCompareSwitch';
@@ -13,6 +14,8 @@ import AssistantWeekOverview from './AssistantWeekOverview';
import { type ChangeItem, undoLeftMs } from './assistantParts';
import { useAssistantView } from './assistantViewContext';
import { ChangeRows } from './cards/ChangeCardSlots';
+import CardHeader from './cards/parts/CardHeader';
+import { CardFoot } from './cards/parts/CardSection';
import { ICON_BUTTON } from './cards/parts/assistantTones';
import { useChangeExclusions } from './cards/useChangeExclusions';
import { changePoints, type DayChange } from './dayAfterModel';
@@ -60,6 +63,9 @@ function undoableNow(item: ChangeItem, undone: Readonly>, n
);
}
+/** The band of a card whose changes are all decided: the green of a done booking. */
+const DONE_TINT = 'color-mix(in srgb, var(--success) 9%, transparent)';
+
/** The waiting changes the user left on that touch the day plan. */
function dayChangesOf(items: readonly ChangeItem[], excluded: ReadonlySet): DayChange[] {
return items.flatMap((i) =>
@@ -69,17 +75,18 @@ function dayChangesOf(items: readonly ChangeItem[], excluded: ReadonlySet
-
- {t(open ? 'assistant.change.title' : 'assistant.change.doneTitle')}
-
- {actions}
- {count}
-
+
);
}
@@ -224,7 +231,7 @@ export default function AssistantChangeCard({ items }: { items: ChangeItem[] })
const open = pending.length > 0;
return (
-
+
{t('assistant.change.pending', { count: pending.length })}
-
-
-
-
+
+
>
)}
diff --git a/client/src/components/Assistant/cards/atlas/AtlasCountryCard.tsx b/client/src/components/Assistant/cards/atlas/AtlasCountryCard.tsx
index 1a2d421e4..4aa3113d8 100644
--- a/client/src/components/Assistant/cards/atlas/AtlasCountryCard.tsx
+++ b/client/src/components/Assistant/cards/atlas/AtlasCountryCard.tsx
@@ -1,5 +1,5 @@
import type { AssistantMessage, AtlasCountryCard as CountryCard } from '@trek/shared';
-import { Briefcase, MapPin, Radio } from 'lucide-react';
+import { Briefcase, Globe2, MapPin, Radio } from 'lucide-react';
import { useTranslation } from '../../../../i18n';
import { SoftPill, WhiteBadge } from '../../../Planner/planParts';
@@ -8,8 +8,10 @@ import type { ChangeItem } from '../../assistantParts';
import type { CardEntry } from '../cardTypes';
import { CardFacts } from '../parts/CardFacts';
import CardFrame from '../parts/CardFrame';
+import CardHeader from '../parts/CardHeader';
import { CardOpenButton } from '../parts/CardOpen';
import { CardMore } from '../parts/CardRows';
+import { CardFoot } from '../parts/CardSection';
import { CONTINENT_LABEL, continentOf, shortDay, STATUS_LOOK } from './atlasCardModel';
import { ATLAS_PAGE } from './atlasPage';
import { ChangeFlag, FlagTile, StatusFact } from './AtlasParts';
@@ -112,14 +114,15 @@ export default function AtlasCountryBlock({ cards }: { cards: readonly CardEntry
if (countries.length === 0) return null;
return (
+
{countries.map((entry, index) => (
- );
+ return 2 ? count : undefined} />;
}
/** One entry as a row: its photo, its title (the way to it), its facts and the start of its text. */
@@ -116,6 +115,7 @@ function JournalRows({ journal, fallbackRef }: { journal: JournalEntries; fallba
const hover = useEntryHover(journal.journeyId, fallbackRef);
return (
+
{journal.entries.map((look, index) => (
0} open={open} hover={hover} />
))}
diff --git a/client/src/components/Assistant/cards/packing/PackingListCard.tsx b/client/src/components/Assistant/cards/packing/PackingListCard.tsx
index 9102578d3..328710e16 100644
--- a/client/src/components/Assistant/cards/packing/PackingListCard.tsx
+++ b/client/src/components/Assistant/cards/packing/PackingListCard.tsx
@@ -1,14 +1,16 @@
import type { PackingListCard as PackingCard, PackingCardGroup } from '@trek/shared';
-import { Check } from 'lucide-react';
+import { Backpack, Check } from 'lucide-react';
import { useTranslation } from '../../../../i18n';
import { SoftPill } from '../../../Planner/planParts';
-import { PackedBar, PackTile } from '../../../Tours/packing/packingLinkParts';
+import { PackedBar } from '../../../Tours/packing/packingLinkParts';
import AssistantChangeFields from '../../AssistantChangeFields';
import type { ChangeItem } from '../../assistantParts';
import type { CardEntry, EntityTarget } from '../cardTypes';
import CardFrame from '../parts/CardFrame';
-import { isRunnable, mergePackingCards, packingColorOf, rowCount } from './checklistModel';
+import CardHeader from '../parts/CardHeader';
+import { CardFoot } from '../parts/CardSection';
+import { isRunnable, mergePackingCards, rowCount } from './checklistModel';
import { ChecklistFoot, ChecklistRun, type RunEntry, type RunProps } from './checklistParts';
import { PackingGroup, PackingRowAside, PackingRowFacts } from './packingParts';
@@ -62,7 +64,7 @@ function useTitle(card: PackingCard): string {
: t('assistant.card.packing.title');
}
-/** The head of an answer: the tile with the count, the title, how much is packed, and "All packed" once it is. */
+/** The head band of an answer: the backpack, the title, how much is packed with its bar, and "All packed" once it is. */
function PackingHead({ card }: { card: PackingCard }) {
const { t } = useTranslation();
const title = useTitle(card);
@@ -73,50 +75,46 @@ function PackingHead({ card }: { card: PackingCard }) {
if (source.type === 'tour') caption = t('assistant.card.packing.forTour');
else if (source.type === 'template') caption = t('assistant.card.packing.templateAdds', { count: source.itemCount });
else if (card.progress && total > 0) caption = t('tours.packing.packed', { packed, count: total });
- const first = card.groups[0]?.key;
- const color =
- source.type === 'tour' && source.category !== null && first?.by === 'category'
- ? packingColorOf(first.slot, source.category)
- : null;
+ const done = card.progress !== null && total > 0 && packed === total;
return (
-
+
);
}
diff --git a/client/src/components/Assistant/cards/packing/checklistParts.tsx b/client/src/components/Assistant/cards/packing/checklistParts.tsx
index 25ae19e77..e689437a7 100644
--- a/client/src/components/Assistant/cards/packing/checklistParts.tsx
+++ b/client/src/components/Assistant/cards/packing/checklistParts.tsx
@@ -90,7 +90,7 @@ export function ChecklistRow({
>
{name}
- {aside && {aside}}
+ {aside && {aside}}
{under}
diff --git a/client/src/components/Assistant/cards/packing/packingParts.tsx b/client/src/components/Assistant/cards/packing/packingParts.tsx
index bde5e98c0..e8240a58c 100644
--- a/client/src/components/Assistant/cards/packing/packingParts.tsx
+++ b/client/src/components/Assistant/cards/packing/packingParts.tsx
@@ -7,7 +7,6 @@ import { formatWeight } from '../../../Packing/packingListModel';
import { bagFillPct } from '../../../Packing/packingListPanel.helpers';
import { SoftPill, WhiteBadge } from '../../../Planner/planParts';
import { Tooltip } from '../../../shared/Tooltip';
-import { CountBadge } from '../../../Tours/packing/packingLinkParts';
import { ChangeMark, FactChange, NoLonger } from '../parts/CardFacts';
import { PeopleStack, PersonFace } from '../parts/CardPeople';
import { packingColorOf } from './checklistModel';
@@ -56,15 +55,31 @@ function BagSwatch({ bag, size = 'row' }: { bag: PackingCardBag | undefined; siz
* What a row says at its end: how many, how many packed, its weight, its tier
* and its bag. A bag the card does not carry draws nothing rather than "Unassigned".
*/
+/** A row's quantity and weight: quiet figures at its end, no frame each. */
+const QUIET = 'text-caption tabular-nums text-content-muted';
+
+/** How many rows a group holds, quiet beside its name. */
+function GroupCount({ count }: { count: number }) {
+ const { t } = useTranslation();
+ return (
+
+ {count}
+
+ );
+}
+
export function PackingRowAside({ row, bag }: { row: PackingCardItem; bag: PackingCardBag | undefined }) {
const { t } = useTranslation();
const personal = t('assistant.card.packing.tierPersonal');
const partial = !row.checked && row.packed > 0 && row.packed < row.quantity;
return (
<>
- {row.quantity > 1 && ×{row.quantity}}
- {partial && {`${row.packed}/${row.quantity}`}}
- {row.weightGrams !== null && {formatWeight(row.weightGrams)}}
+ {row.quantity > 1 && ×{row.quantity}}
+ {partial && {`${row.packed}/${row.quantity}`}}
+ {row.weightGrams !== null && {formatWeight(row.weightGrams)}}
{row.tier === 'personal' && (
@@ -216,7 +231,7 @@ function BagHead({
}) {
const { t } = useTranslation();
if (!bag) {
- const badge = inChange ? undefined : ;
+ const badge = inChange ? undefined : ;
const lead = ;
return ;
}
@@ -283,7 +298,7 @@ export function PackingGroup({
}
+ badge={inChange ? undefined : }
people={group.assignees}
removed={group.assigneesRemoved}
/>
diff --git a/client/src/components/Assistant/cards/parts/CardFrame.tsx b/client/src/components/Assistant/cards/parts/CardFrame.tsx
index 201412e8f..03e59e2f0 100644
--- a/client/src/components/Assistant/cards/parts/CardFrame.tsx
+++ b/client/src/components/Assistant/cards/parts/CardFrame.tsx
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react';
/**
* The frame every answer card sits in, the same as the change card's: a
- * rounded card on the chat. A waiting change shows its frame dashed, a
+ * rounded card on the chat whose head band (CardHeader) runs to its edges. A waiting change shows its frame dashed, a
* removed one faded, a settled one (discarded, expired, undone) fainter
* still. The chat card (a message in the trip chat) sits on the quieter
* secondary surface.
@@ -32,7 +32,7 @@ export default function CardFrame({
return (
diff --git a/client/src/components/Assistant/cards/parts/CardHeader.tsx b/client/src/components/Assistant/cards/parts/CardHeader.tsx
index cf69eab0e..bc180ee7f 100644
--- a/client/src/components/Assistant/cards/parts/CardHeader.tsx
+++ b/client/src/components/Assistant/cards/parts/CardHeader.tsx
@@ -1,43 +1,94 @@
import type { LucideIcon } from 'lucide-react';
import type { ReactNode } from 'react';
-import { WhiteBadge } from '../../../Planner/planParts';
+import { fs, NEUTRAL_TINT } from '../../../shared/DialogShell';
import type { Tone } from './assistantTones';
-import KindTile from './KindTile';
/**
- * The head of an answer card: its tile, what it is about (wrapping to two
- * lines at most, the whole title in its tooltip), how many it holds, one
- * quiet line of context under it, and its actions at the end.
+ * The head band of an answer card, as the trip's dialogs and booking cards
+ * wear it: a tinted band across the card's top, a raised white tile with the
+ * icon of what the card is about in its tone, an eyebrow naming the kind,
+ * the title, one quiet line under it, a count, and the card's actions at the
+ * end. It reaches the card's edges, so a card that opens with it needs no
+ * other head.
*/
+
+/** The icon's colour on the white tile, per tone. */
+const GLYPH: Record = {
+ success: 'text-success',
+ info: 'text-info',
+ warning: 'text-warning',
+ danger: 'text-danger',
+};
+
export default function CardHeader({
- icon,
+ icon: Icon,
tone,
title,
+ eyebrow,
count,
meta,
actions,
+ tile,
+ tint = NEUTRAL_TINT,
+ children,
}: {
icon: LucideIcon;
tone: Tone;
title: string;
+ /** The kind above the title ("PACKING LIST"); none when the title says it. */
+ eyebrow?: string;
count?: number;
meta?: ReactNode;
actions?: ReactNode;
+ /** In place of the icon tile: a drawing of what the card shows (a route's sketch). */
+ tile?: ReactNode;
+ tint?: string;
+ /** Under the title row, on the band: a progress bar, a row of pills. */
+ children?: ReactNode;
}) {
return (
-
);
}
diff --git a/client/src/components/Assistant/cards/parts/CardRows.tsx b/client/src/components/Assistant/cards/parts/CardRows.tsx
index 2e754c143..ef326fe4d 100644
--- a/client/src/components/Assistant/cards/parts/CardRows.tsx
+++ b/client/src/components/Assistant/cards/parts/CardRows.tsx
@@ -44,7 +44,11 @@ export function CardRow({
{title}
{facts}
- {aside && {aside}}
+ {aside && (
+
+ {aside}
+
+ )}
>
);
const hover = onHover
diff --git a/client/src/components/Assistant/cards/parts/CardSection.tsx b/client/src/components/Assistant/cards/parts/CardSection.tsx
new file mode 100644
index 000000000..08d67d1f0
--- /dev/null
+++ b/client/src/components/Assistant/cards/parts/CardSection.tsx
@@ -0,0 +1,49 @@
+import type { ReactNode } from 'react';
+
+import { Eyebrow, Field } from '../../../Planner/bookings/bookingParts';
+
+/**
+ * The body of an answer card in the trip dialogs' look: sections under an
+ * eyebrow of their own, figures as framed fields with their label over them
+ * (the field every booking card is made of), and a foot bar for the card's
+ * ways onward, set off by a line across the card.
+ */
+
+/** One part of a card under its eyebrow, with room for something on the right of the label. */
+export function CardSection({ label, aside, children }: { label: string; aside?: ReactNode; children: ReactNode }) {
+ return (
+
+
+ {label}
+ {aside && {aside}}
+
+ {children}
+
+ );
+}
+
+/** A card's figures, side by side in framed fields: as many columns as figures, at most four. */
+export function CardFields({ fields }: { fields: readonly { key: string; label: string; value: ReactNode }[] }) {
+ if (fields.length === 0) return null;
+ const columns = ['grid-cols-1', 'grid-cols-2', 'grid-cols-3', 'grid-cols-4'][Math.min(fields.length, 4) - 1];
+ return (
+
+ {fields.map((field) => (
+
+
+ {field.value}
+
+
+ ))}
+
+ );
+}
+
+/** The foot of a card: its actions at the end, under a line that runs to the card's edges. */
+export function CardFoot({ children }: { children: ReactNode }) {
+ return (
+
+ {children}
+
+ );
+}
diff --git a/client/src/components/Assistant/cards/tour/TourFigureLine.tsx b/client/src/components/Assistant/cards/tour/TourFigureLine.tsx
new file mode 100644
index 000000000..0a28caad9
--- /dev/null
+++ b/client/src/components/Assistant/cards/tour/TourFigureLine.tsx
@@ -0,0 +1,46 @@
+import { Clock, MoveHorizontal, TrendingUp } from 'lucide-react';
+import type { ReactNode } from 'react';
+
+import type { DistanceUnit } from '../../../../types';
+import { formatDistance, formatElevation } from '../../../../utils/units';
+import type { LegVariant } from '../../../Tours/planner/legVariants';
+import { formatTourDuration } from '../../../Tours/planner/tourDurationInput';
+
+/**
+ * A way's length, climb and time as one quiet line of glyphs and values,
+ * without a frame around each: what a choice of ways and a change row show
+ * where framed fields would crowd the row.
+ */
+
+/** One figure of a way: its glyph and its value, quiet, in a line of them. */
+function Figure({ name, icon, children }: { name: string; icon: ReactNode; children: ReactNode }) {
+ return (
+
+ {icon}
+ {children}
+
+ );
+}
+
+const GLYPH = { size: 11, strokeWidth: 2.2, 'aria-hidden': true, className: 'flex-none text-content-faint' } as const;
+
+/** A way's length, climb and time in one quiet line. */
+export default function WayFigures({ way, unit }: { way: LegVariant; unit: DistanceUnit }) {
+ return (
+
+ }>
+ {formatDistance(way.distanceM / 1000, unit)}
+
+ {way.gainM !== null && (
+ }>
+ {formatElevation(way.gainM, unit)}
+
+ )}
+ {way.minutes !== null && (
+ }>
+ {formatTourDuration(way.minutes)}
+
+ )}
+
+ );
+}
diff --git a/client/src/components/Assistant/cards/tour/TourRouteActions.tsx b/client/src/components/Assistant/cards/tour/TourRouteActions.tsx
index 455703b62..f5461c231 100644
--- a/client/src/components/Assistant/cards/tour/TourRouteActions.tsx
+++ b/client/src/components/Assistant/cards/tour/TourRouteActions.tsx
@@ -5,6 +5,7 @@ import { useTranslation } from '../../../../i18n';
import { SoftPill } from '../../../Planner/planParts';
import { useAssistantView } from '../../assistantViewContext';
import { CardOpenButton } from '../parts/CardOpen';
+import { CardFoot } from '../parts/CardSection';
import { tourTarget } from './tourLook';
import { useTakeProposal } from './useTourRouteCard';
@@ -58,7 +59,7 @@ export default function TourRouteActions({
if (take.state === 'failed') caption = t('assistant.card.tour.askAgain');
else if (take.state !== 'taken' && take.reasonKey) caption = t(take.reasonKey);
return (
-
+
+
);
}
diff --git a/client/src/components/Assistant/cards/tour/TourRouteCard.test.tsx b/client/src/components/Assistant/cards/tour/TourRouteCard.test.tsx
index db81a0b0d..644b31146 100644
--- a/client/src/components/Assistant/cards/tour/TourRouteCard.test.tsx
+++ b/client/src/components/Assistant/cards/tour/TourRouteCard.test.tsx
@@ -115,11 +115,11 @@ afterEach(() => {
});
describe('TourRouteCard', () => {
- it('FE-AI-TOUR-021: states the name, the figures as badges, the day and the hardest grade, uncertain when little is graded', () => {
+ it('FE-AI-TOUR-021: states the name, the figures as framed fields, the day and the hardest grade, uncertain when little is graded', () => {
const { container } = renderCard(HIKE);
expect(screen.getByText('Hochfelln from Bergen')).toBeInTheDocument();
for (const figure of ['time', 'distance', 'ascent', 'descent']) {
- expect(container.querySelector(`[data-figure="${figure}"]`)).not.toBeNull();
+ expect(container.querySelector(`[data-field="${figure}"]`)).not.toBeNull();
}
expect(screen.getByText('8.2 km')).toBeInTheDocument();
expect(screen.getAllByText('640 m')).toHaveLength(2);
@@ -159,7 +159,7 @@ describe('TourRouteCard', () => {
it('FE-AI-TOUR-024: a stop chip moves the spot in focus to the stop while pointed at', () => {
renderCard(HIKE);
- const hut = screen.getByRole('button', { name: 'Strausshütte, 09:40' });
+ const hut = screen.getByRole('button', { name: /^Strausshütte, 09:40/ });
fireEvent.mouseEnter(hut);
expect(useAssistantStore.getState().routeFocus?.focus.distanceMeters).toBeCloseTo(2400, 0);
fireEvent.mouseLeave(hut);
@@ -171,11 +171,11 @@ describe('TourRouteCard', () => {
it('FE-AI-TOUR-024b: the stops run as a timeline, each walk on the line between two stops and read with the one it leads to', () => {
renderCard(HIKE);
const list = screen.getByRole('list', { name: 'Stops along the way' });
- // One row per stop; the lines between them are not rows.
- expect(list.querySelectorAll('[role="listitem"]')).toHaveLength(5);
+ // One row per stop; the walks between them are hidden, read with the stop they lead to.
+ expect(list.querySelectorAll('li:not([aria-hidden="true"])')).toHaveLength(5);
// The place beside the way has no time: the hut measures from the start, then each stop from the last.
expect(screen.getAllByText(/from the last stop$/)).toHaveLength(3);
- const legs = [...list.querySelectorAll('[aria-hidden="true"]')].map((leg) => leg.textContent).filter(Boolean);
+ const legs = [...list.querySelectorAll('li[aria-hidden="true"]')].map((leg) => leg.textContent).filter(Boolean);
expect(legs).toHaveLength(3);
});
diff --git a/client/src/components/Assistant/cards/tour/TourRouteCard.tsx b/client/src/components/Assistant/cards/tour/TourRouteCard.tsx
index e80b6aea6..1fa6bcd89 100644
--- a/client/src/components/Assistant/cards/tour/TourRouteCard.tsx
+++ b/client/src/components/Assistant/cards/tour/TourRouteCard.tsx
@@ -4,11 +4,11 @@ import { useMemo } from 'react';
import { useTranslation } from '../../../../i18n';
import type { DistanceIndexedProfileSample } from '../../../../utils/routeGeometry';
import { variantPaintCss } from '../../../Tours/planner/legVariantPaint';
-import { useAssistantView } from '../../assistantViewContext';
import CardFrame from '../parts/CardFrame';
+import { CardSection } from '../parts/CardSection';
import TourRouteActions from './TourRouteActions';
import TourRouteDay from './TourRouteDay';
-import TourRouteHead from './TourRouteHead';
+import TourRouteHead, { TourRouteFields } from './TourRouteHead';
import { profileSamples } from './tourRouteModel';
import { TourRouteProblem, TourRouteWarnings } from './TourRouteNotes';
import TourRouteProfile from './TourRouteProfile';
@@ -40,19 +40,30 @@ export function TourRouteBody({
compare?: ReadonlyArray<{ key: string; samples: readonly DistanceIndexedProfileSample[]; color: string }>;
letter?: string;
}) {
+ const { t } = useTranslation();
const samples = useMemo(() => profileSamples(card), [card]);
return (
<>
-
-
+
+ {/* A way drawn straight has neither heights nor the line to say so under: no section at all. */}
+ {(samples.length >= 2 || card.routed) && (
+
+
+
+ )}
+ {card.stops.length > 0 && (
+
+
+
+ )}
@@ -63,12 +74,11 @@ export function TourRouteBody({
export default function TourRouteCard({ toolCallId, card }: { toolCallId: string; card: Route }) {
const { t } = useTranslation();
- const { density } = useAssistantView();
const route = useTourRouteCard(toolCallId, card);
return (
-
+
diff --git a/client/src/components/Assistant/cards/tour/TourRouteHead.tsx b/client/src/components/Assistant/cards/tour/TourRouteHead.tsx
index 2e7162d97..6fc0d6a91 100644
--- a/client/src/components/Assistant/cards/tour/TourRouteHead.tsx
+++ b/client/src/components/Assistant/cards/tour/TourRouteHead.tsx
@@ -4,12 +4,14 @@ import { createElement } from 'react';
import { useTranslation } from '../../../../i18n';
import { SoftPill, WhiteBadge } from '../../../Planner/planParts';
+import { fs, PILL } from '../../../shared/DialogShell';
import { Tooltip } from '../../../shared/Tooltip';
import { SacStepChip } from '../../../Tours/hike/SacStepChip';
import { variantPaintCss } from '../../../Tours/planner/legVariantPaint';
import { formatTourDuration } from '../../../Tours/planner/tourDurationInput';
import { tourDayRowIcon } from '../../../Tours/tourDayRowIcon';
-import { CardFacts } from '../parts/CardFacts';
+import CardHeader from '../parts/CardHeader';
+import { CardFields } from '../parts/CardSection';
import RouteSketch from '../parts/RouteSketch';
import { useCardFormat } from '../parts/useCardFormat';
import { factKeysOf, factValue, percentText, type FactKey } from './tourRouteModel';
@@ -89,7 +91,7 @@ export function TourGrade({ card }: { card: TourRouteCard }) {
);
}
-/** The day a route is planned on, as words: "Day 2, Tue 14 Oct", or the date alone. */
+/** The day a route is planned on, as a white pill on the band: "Day 2, Tue 14 Oct", or the date alone. */
function DayPill({ card }: { card: TourRouteCard }) {
const { t } = useTranslation();
const format = useCardFormat();
@@ -98,7 +100,12 @@ function DayPill({ card }: { card: TourRouteCard }) {
const date = format.date(schedule.date);
const text =
schedule.dayNumber !== null ? `${t('assistant.card.tour.day', { day: schedule.dayNumber })}, ${date}` : date;
- return }>{text};
+ return (
+
+
+ {text}
+
+ );
}
/** The route drawn small: a button that shows it on the map. */
@@ -127,35 +134,51 @@ export function TourRouteSketch({
);
}
-export default function TourRouteHead({
- card,
- sketchHeight,
- onShow,
-}: {
- card: TourRouteCard;
- sketchHeight: number;
- onShow: () => void;
-}) {
+/** The route's figures as framed fields, each under its label: distance, climb, descent and time, as known. */
+export function TourRouteFields({ card }: { card: TourRouteCard }) {
+ const { t } = useTranslation();
+ const format = useCardFormat();
+ const fields = factKeysOf(card).flatMap((key) => {
+ const value = factValue(card, key);
+ if (value === null) return [];
+ // A field's label is short; how the time was reckoned is the figure badges' tooltip.
+ const label = t(FACT_LOOK[key].labelKey ?? 'tours.planner.inspector.duration');
+ let text: string;
+ if (key === 'time') text = formatTourDuration(value);
+ else text = key === 'distance' ? format.distance(value / 1000) : format.elevation(value);
+ return [{ key, label, value: text }];
+ });
+ return ;
+}
+
+/**
+ * The head band of a route card: the route drawn small on a raised tile, what
+ * kind of tour it is above its name, the label under it, and its grade and
+ * the day it is planned on as pills on the band.
+ */
+export default function TourRouteHead({ card, onShow }: { card: TourRouteCard; onShow: () => void }) {
const { t } = useTranslation();
const name = routeName(card, t);
+ const tile = (
+
+
+
+ );
return (
-
+ {glyph}
+ {stop.stageEnd && }
+
+ );
+}
+
+function StopRow({
stop,
+ leg,
samples,
onFocus,
}: {
stop: TourRouteStop;
+ /** The walk from the last stop with a time to this one, read with it. */
+ leg: number | null;
samples: readonly DistanceIndexedProfileSample[];
onFocus: (focus: RouteProfileFocus | null) => void;
}) {
@@ -65,44 +85,45 @@ function StopChip({
: null;
const stay = stop.stayMinutes ? t('assistant.card.tour.stay', { time: format.minutes(stop.stayMinutes) }) : null;
const clock = stop.clock ? format.clock(stop.clock) : null;
- const label = [name, clock, off, stay].filter(Boolean).join(', ');
- const glyph = createElement(iconOf(stop), {
- size: 10,
- strokeWidth: 2.2,
- 'aria-hidden': true,
- className: 'flex-none text-content-faint',
- });
- const body = (
- <>
- {name}
- {clock && {clock}}
- {off && {off}}
- >
- );
+ const walked = leg !== null ? t('assistant.card.tour.legTime', { time: format.minutes(leg) }) : null;
+ const label = [name, clock, off, stay, walked].filter(Boolean).join(', ');
+ const point = () => onFocus(focusOf(stop, samples));
+ const under = [off, stay].filter((part): part is string => part !== null);
return (
-
-
-
-
- {stay && {stay}}
- {stop.flag && (
- }>
- {t(FLAG_LOOK[stop.flag].labelKey)}
-
- )}
-
+
+
+
);
}
@@ -112,38 +133,36 @@ function legMinutes(from: TourRouteStop | undefined, to: TourRouteStop): number
return to.minutes - from.minutes;
}
-/** The line between two rows, with the stretch's walking time on it. */
+/** The walk between two rows, beside the line: read with the row it leads to, so hidden here. */
function Leg({ minutes }: { minutes: number | null }) {
const format = useCardFormat();
+ if (minutes === null) return ;
return (
- // Read with the stop it leads to; a list holds only its rows.
-
-
-
+
+
);
}
-/** One row of the timeline: its dot on the line, then the stop, read after the walk that leads to it. */
-function Row({ end, leg, children }: { end: boolean; leg?: number | null; children: ReactNode }) {
+/** The middle stops folded into one row past eight, naming them in its tooltip. */
+function FoldedRow({ stops }: { stops: readonly TourRouteStop[] }) {
const { t } = useTranslation();
- const format = useCardFormat();
+ const names = stops.map((stop) => stopName(stop, t)).join(', ');
return (
-
- {leg != null && (
- {t('assistant.card.tour.legTime', { time: format.minutes(leg) })}
- )}
-
-
+
+
+
- {children}
-
+
+
+ {t('assistant.card.tour.stopsMore', { count: stops.length })}
+ {`: ${names}`}
+
+
+
);
}
@@ -159,42 +178,30 @@ export default function TourRouteStops({
const { t } = useTranslation();
const { head, folded, tail } = chipStops(card);
if (head.length === 0) return null;
- const names = folded.map((stop) => stopName(stop, t)).join(', ');
// The time is walked from the last stop that has one: a place beside the way has none.
let walked: TourRouteStop | undefined;
const rows: ReactNode[] = [];
const pushStop = (stop: TourRouteStop, key: string) => {
const leg = legMinutes(walked, stop);
if (rows.length > 0) rows.push();
- rows.push(
-
-
-
- );
+ rows.push();
if (stop.minutes !== null) walked = stop;
};
head.forEach((stop, index) => pushStop(stop, `h-${index}`));
if (folded.length > 0) {
rows.push();
- rows.push(
-
-
-
-
- {t('assistant.card.tour.stopsMore', { count: folded.length })}
- {`: ${names}`}
-
-
-
-
- );
+ rows.push();
// The folded stretch's time is not one leg; the next stop measures from the last folded one.
walked = [...folded].reverse().find((stop) => stop.minutes !== null) ?? walked;
}
tail.forEach((stop, index) => pushStop(stop, `t-${index}`));
return (
-
- {rows}
+
+ {/* The line down the timeline, from the first mark to the last, under the marks. */}
+
+
+ {rows}
+
);
}
diff --git a/client/src/components/Assistant/cards/tour/TourWays.tsx b/client/src/components/Assistant/cards/tour/TourWays.tsx
index 6c353606c..cd01af628 100644
--- a/client/src/components/Assistant/cards/tour/TourWays.tsx
+++ b/client/src/components/Assistant/cards/tour/TourWays.tsx
@@ -1,19 +1,128 @@
+import type { TourRouteCard as Route } from '@trek/shared';
+import { Route as RouteIcon } from 'lucide-react';
import { useMemo } from 'react';
import { useTranslation } from '../../../../i18n';
import { chatOf, useAssistantStore } from '../../../../store/assistantStore';
import { useSettingsStore } from '../../../../store/settingsStore';
+import type { DistanceUnit } from '../../../../types';
+import { formatDistance, formatElevation } from '../../../../utils/units';
import { SacStepChip } from '../../../Tours/hike/SacStepChip';
import { variantPaintCss } from '../../../Tours/planner/legVariantPaint';
-import { VariantDelta } from '../../../Tours/planner/LegVariantsCard';
-import { VariantFigures, WayChoice } from '../../../Tours/planner/mapCardParts';
+import { type LegVariant, variantDelta } from '../../../Tours/planner/legVariants';
+import { VariantMark } from '../../../Tours/planner/mapCardParts';
+import { formatTourDuration } from '../../../Tours/planner/tourDurationInput';
import { useAssistantView } from '../../assistantViewContext';
import CardFrame from '../parts/CardFrame';
+import CardHeader from '../parts/CardHeader';
+import { CardSection } from '../parts/CardSection';
+import WayFigures from './TourFigureLine';
import { TourRouteBody } from './TourRouteCard';
import { legVariantOf, profileSamples, type RouteEntry, WAY_KEYS } from './tourRouteModel';
+import { routeName, TOUR_TYPE_WORDS } from './tourRouteWords';
import { useLineHover, useTourRouteCard } from './useTourRouteCard';
-/** The ways of one answer with the chosen one known: its choices, then the chosen way's body. */
+/** A signed difference: a plus for more, a minus sign for less, nothing for none worth printing. */
+function signed(value: number, format: (absolute: number) => string): string | null {
+ const text = format(Math.abs(value));
+ if (Math.abs(value) < 1e-9 || /^0\s/.test(text)) return null;
+ return `${value > 0 ? '+' : '−'}${text}`;
+}
+
+/** How a way differs from the chosen one, as one faint line: "Compared with way A: −4.3 km −178 m −1 h 33 min". */
+function WayDelta({
+ way,
+ chosen,
+ letter,
+ unit,
+}: {
+ way: LegVariant;
+ chosen: LegVariant;
+ letter: string;
+ unit: DistanceUnit;
+}) {
+ const { t } = useTranslation();
+ const delta = variantDelta(way, chosen);
+ const parts = [
+ signed(delta.distanceM / 1000, (km) => formatDistance(km, unit)),
+ delta.gainM === null ? null : signed(delta.gainM, (m) => formatElevation(m, unit)),
+ delta.minutes === null ? null : signed(delta.minutes, formatTourDuration),
+ ].filter((part): part is string => part !== null);
+ if (parts.length === 0) return null;
+ return (
+
+ {t('assistant.card.tour.deltaTo', { letter })}
+ {parts.map((part) => (
+
+ {part}
+
+ ))}
+
+ );
+}
+
+/** One way to choose: its letter in the colour it is drawn in, its name and grade, its figures, how it differs. */
+function WayOption({
+ entry,
+ index,
+ chosen,
+ chosenWay,
+ chosenLetter,
+ unit,
+ onSelect,
+ onHover,
+}: {
+ entry: RouteEntry;
+ index: number;
+ chosen: boolean;
+ chosenWay: LegVariant;
+ chosenLetter: string;
+ unit: DistanceUnit;
+ onSelect: () => void;
+ onHover: (on: boolean) => void;
+}) {
+ const { t } = useTranslation();
+ const key = WAY_KEYS[index] ?? 'a';
+ const letter = key.toUpperCase();
+ const way = legVariantOf(entry.card, key);
+ const grades = entry.card.grades;
+ const name = entry.card.label ?? t('tours.variants.option', { letter });
+ return (
+
+ );
+}
+
+/** The ways of one answer with the chosen one known: the band, the choices, then the chosen way's body. */
function WaysCard({
entries,
chosen,
@@ -44,57 +153,49 @@ function WaysCard({
[entries, chosenIndex]
);
- const current = legVariantOf(chosen.card, chosenKey);
+ const chosenWay = legVariantOf(chosen.card, chosenKey);
// Side by side where the window is roomy; on the phone the ways stay rows, so a finger scrubs the profile freely.
let columns = '';
if (density === 'roomy' && variant !== 'fullscreen') columns = entries.length >= 3 ? 'grid-cols-3' : 'grid-cols-2';
const title = t('assistant.card.tour.ways', { count: entries.length });
+ const card: Route = chosen.card;
return (
-
);
@@ -102,12 +203,12 @@ function WaysCard({
/**
* Two or three ways of one route an answer proposed, as the planner offers a
- * section's ways: each a choice with its letter in the colour it is drawn in,
- * its own words, how it differs from the chosen one and its hardest grade,
- * its figures below. One profile holds them all, the chosen way filled and
- * the others thin on the same axes; under it the chosen way's stops, day and
- * warnings, and "Plan way B". A choice is kept per answer, and pointing at a
- * way lights its line on the map.
+ * section's ways: a band naming the route, each way a choice with its letter
+ * in the colour it is drawn in, its name and hardest grade, its figures and
+ * how it differs from the chosen one; one profile holds them all, the chosen
+ * way filled and the others thin on the same axes; under it the chosen way's
+ * figures, stops, day and warnings, and "Plan way B". A choice is kept per
+ * answer, and pointing at a way lights its line on the map.
*/
export default function TourWays({ entries }: { entries: readonly RouteEntry[] }) {
const { tripId } = useAssistantView();
diff --git a/client/src/components/Assistant/cards/vacay/VacayAnswerBlock.tsx b/client/src/components/Assistant/cards/vacay/VacayAnswerBlock.tsx
index 9fe5aca3b..36f5e1605 100644
--- a/client/src/components/Assistant/cards/vacay/VacayAnswerBlock.tsx
+++ b/client/src/components/Assistant/cards/vacay/VacayAnswerBlock.tsx
@@ -1,10 +1,14 @@
import type { CSSProperties } from 'react';
+import { Palmtree } from 'lucide-react';
+
import { useTranslation } from '../../../../i18n';
import { safeHexColor } from '../../../../utils/safeColor';
import type { CardEntry } from '../cardTypes';
import CardFrame from '../parts/CardFrame';
+import CardHeader from '../parts/CardHeader';
import { CardOpenButton } from '../parts/CardOpen';
+import { CardFoot } from '../parts/CardSection';
import { useViewerId } from '../parts/useViewerId';
import VacayBalance from './VacayBalance';
import { balanceLines, mergeVacayCards, type VacayView } from './vacayCardModel';
@@ -26,7 +30,6 @@ const SQUARE = 'size-2 flex-none rounded-sm';
const COMPANY = 'size-2 flex-none rounded-sm bg-warning-soft ring-1 ring-inset ring-warning';
const TRIP = 'size-1.5 flex-none rounded-full bg-info';
const OTHER = 'mt-1.5 text-caption text-content-muted';
-const FOOT = 'mt-1 flex justify-end';
interface LegendItem {
key: string;
@@ -79,13 +82,14 @@ export default function VacayAnswerBlock({ cards }: { cards: readonly CardEntry[
const first = own[0] ?? null;
return (
+
{view.months.length > 0 && ''} />}
{view.otherDays > 0 &&