Skip to content

Planner: a night and a town open as pages #3371

Closed

Description

@timohueser

Status: done
Size: M
Part of #3286 (round 2, after the owner's browser check).
Systems: route-planning

TL;DR

Goal: The side panel shows one level at a time: the trip, then one night, then one town. Each level below the trip starts with a back row that names the level above.
Problem: A night opens as a box inside the day list, and a town opens as a card inside that box. The panel then holds three levels at once, and the list moves when a night opens or closes. The owner gets lost in it.
Decision: "Choose" on a night replaces the day list with a page for that night. A town replaces the night page. Nothing opens inside the day list. (Wireframe page https://claude.ai/artifact/HibXoqwkvZM9jHwdae1Ka7, question 3, option A.)
Rejected: The night stays in the list as a filled block (option B): the panel still holds two levels, and the list still moves.

Words

  • Day list: the list of riding days and nights in the side panel (Itinerary.svelte in builder/web/src/components/planner/). A night row is one night of it (NightNode.svelte).
  • Night picker: the list of towns where the rider can sleep on one night (StopPicker.svelte). A stop is one town of it, with its places to sleep. The town card shows one stop (StopCard.svelte).
  • Open day: a day that the rider opened from the day list. The panel then shows only that day, with the back row "All days" (.day-nav in Itinerary.svelte). This exists today and is the model for the night page.
  • Stay kind: one of the five kinds of place to sleep (camp, hut, hostel, hotel, shelter).

Facts

  • All state is in PlannerApp.svelte: choosingNight, the derived pickerNight (null in a search), stopId (the open town) and expandedDay (the open day). The object nights (NightChoices in lib/planner/night-stops.svelte.ts) gives them to the day list.
  • NightNode.svelte: "Choose" or "Change" calls nights.choose(day.number). While nights.choosing === day.number, the row renders .night-panel with a close button and its children. Escape on the panel and the close button call nights.choose(null).
  • Itinerary.svelte passes the snippet towns, which renders StopPicker. StopPicker shows StopCard in place of the list while a town is open; the card has the back row "All towns".
  • While a night is open from the day list, the side panel still shows the search field, the totals, the notes row, the trip row and the whole day list.
  • An open day hides the totals, the notes row and the trip row. Inside an open day, DayRow.svelte shows the picker under "Where to sleep" (.choose), with "Cancel".
  • stopCounts in lib/planner/stops.ts gives a text such as "1 campsite · 2 hostels · 17 hotels · 1 shelter". The night row and the town rows show it.
  • The footer row of StopPicker holds the stay kinds (StayChip) and "Pick on the map".
  • PlannerApp.svelte hides the search field with style:display on .query-slot while the signed routes are open.
  • pickerNight is also null while the route is recalculated (session.stale), for example after a drag of a route point; choosingNight stays set in that time.
  • With a rest day, the number of a night in the code (the riding number) differs from the number that the rider sees. StopPicker gets the visible numbers as labels: the day that ends and the day that starts.
  • Itinerary.svelte shows the block "N campsites suggested" with "Keep all" (.keep) whenever no day is open.
  • The side panel scrolls in .pane-scroll. Itinerary.svelte resets the scroll position only when the open day changes.
  • A night also opens from the elevation profile (openNight) and from the callout of the map.

Plan

  1. PlannerApp.svelte: one derived flag nightPage says that the night page shows: choosingNight is set, no day is open and no search is open. It does not depend on session.stale, so the page stays while the route is recalculated; the picker then shows its loading line. PlannerApp.svelte passes the flag to Itinerary, so the two cannot disagree.
  2. Itinerary.svelte: while nightPage is true, the component renders the night page in place of the list and of the block .keep: a back row "All days" (the markup and the class of .day-nav, the same text as the back row of an open day), the heading "Night " and the first of labels, the line "Where day X ends and day Y starts" with both labels, then {@render towns(N)}.
  3. Back and Escape: the back row calls nights.choose(null). Escape goes back one level: it closes the open town, or, with no town open, the night. When the page opens, from the day list, the profile or the map, focus moves to the back row. When the page closes, by the back row, Escape, the end of a day in a town or "Let the planner choose", focus goes to the "Choose" or "Change" button of that night in the day list.
  4. Scroll: when the page opens, PlannerApp.svelte or Itinerary.svelte keeps the scroll position of .pane-scroll and sets it to the top. When the page closes, it restores the position, so the day list is where the rider left it. A town page also opens at the top.
  5. NightNode.svelte: delete .night-panel, its close button, its Escape handler, its children and their styles. The row keeps its name, its counts, its two step buttons and "Choose" or "Change".
  6. PlannerApp.svelte: while nightPage is true, the side panel hides the search field (as for the signed routes), the notes row and the trip row. Planner: the totals leave the side panel (two variants to compare) #3370 removes the totals from the side panel; if it is not merged yet, hide .trip-summary here too.
  7. StopPicker.svelte: the row with the stay kinds and "Pick on the map" becomes the first row of the picker, above the towns. "Cancel", which shows only inside an open day, stays in that row. "Let the planner choose" stays below the towns. The picker of an open day gets the same order; nothing else of it changes. StopCard.svelte: the back row reads "Night " and the first of labels on the night page, and stays "All towns" inside an open day.
  8. lib/planner/stops.ts: a short form of the counts for a row. It counts the same places as stopCounts (only the stay kinds of the night). With more than two stay kinds present, the text is "21 places to sleep"; with one or two kinds it is the text of stopCounts. The night row and the town rows show the short form; the accessible name of a town row keeps the full text. The header of the town card keeps stopCounts.
  9. The move of the map does not change: nightToShow and showNight act as today when the night page opens.
  10. Tests: update the cases of Planner.svelte.test.ts and PlannerApp.svelte.test.ts that read .night-panel, its close button and Escape. New cases: "Choose" shows the night page and hides the day list, .keep, the search field, the notes row and the trip row; the page stays while the route is recalculated; the back row and Escape return to the day list with focus on the button of the night; Escape with an open town closes only the town; the heading of a night after a rest day; the short form of the counts.
  11. Docs, in its own docs: commit: docs/content/software/trips.md, where it describes how the rider chooses a night.

Done when

  • From builder/web: npx vitest run src/components/planner/ src/lib/planner/ and npm run check
  • python3 docs/build_docs.py --check-links
  • In the running planner: "Choose" on a night shows only that night; a town shows only that town; each back row returns one level, and the day list is where the rider left it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions