Pages and paths
The widget works on one page, or across one page for each step. A full page load loses nothing, as the order lives in three places:
| What | Where | Why |
|---|---|---|
| The search, the car type, the level, add-on covers, extras | The address | A link can be shared, and a page cache keeps working. |
| The customer's details | The tab's sessionStorage | Personal data never goes in an address. |
| The hold and the booking after Pay | The tab's sessionStorage | The done page and a reload find them. |
The address of an order looks like this. Products go by their code and the car type by its slug. The site's own parameters stay as they are:
Code
url-state="none" keeps the step and the order in memory instead. A reload then starts again.
One page
Without paths, every step is on the page, and the step is in ?step=. The browser's Back button goes one step back. An address with a whole search and no step opens on the car types.
One page for each step
paths names a page for each step:
Code
Put the same tag on each of those pages. Each page shows its own step. Next goes to the next step's page.
- A step with no path is on the page of the step before it. The steps before the first path are on the first path's page. Above, the search is thus on
/bookwith the car types. - A page whose earlier steps are not complete shows the first step that is not. Thus
/book/insuranceopened with no car type shows the car types, on/book. - A page that no path names holds every step.
Your own router
By default a move to another page is a full page load. That suits WordPress and plain HTML. A site with its own router, such as Next.js or Nuxt, takes the move itself:
- Listen for
mellow-stepand cancel it withpreventDefault(). - Send your router to
event.detail.path. - Once the router moved, call
store.locate(): the store reads the address again.
Code
Keep the same <mellow-booking> element in a layout that every booking page shares. The store then stays in memory across the pages, and the address and the storage are only for a reload.