Skip to content

Commit 149cdf0

Browse files
committed
ui(tour): move "Nearest stop" next to "Surprise me"
The nearest-stop action now lives in the form actions beside "Surprise me" (styled as a ghost button) instead of under the cities input, and is shown only in tour mode. "Clear all" stays with the cities input. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GjYKzVUaZR1Awer3K9BTXW
1 parent a792530 commit 149cdf0

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎src/app.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ interface InstallPromptEvent extends Event {
103103
let installPrompt: InstallPromptEvent | null = null;
104104
let surpriseMsgEl: HTMLElement | null = null;
105105
let cityClearBtnEl: HTMLElement | null = null;
106+
let nearestBtnEl: HTMLElement | null = null;
106107

107108
/** Set (or clear with "") the inline status next to the "surprise" button. */
108109
function setSurpriseMsg(text: string): void {
@@ -1001,6 +1002,8 @@ function updateFieldVisibility(): void {
10011002
refs.regionField.style.display = query.mode === "best" || query.mode === "tour" ? "" : "none";
10021003
refs.citiesField.style.display = query.mode === "tour" ? "" : "none";
10031004
refs.stayField.style.display = query.mode === "tour" ? "" : "none";
1005+
// "Nearest stop" sits beside "Surprise me" but only makes sense for a tour.
1006+
nearestBtnEl?.toggleAttribute("hidden", query.mode !== "tour");
10041007
}
10051008

10061009
function buildLayout(root: HTMLElement): void {
@@ -1288,18 +1291,20 @@ function buildForm(): FormBuild {
12881291
});
12891292
cityClearBtnEl = clearCitiesBtn;
12901293
// "Nearest stop": greedily extend the trip to the closest reachable new station.
1294+
// It lives next to "Surprise me" in the form actions and only shows for a tour.
12911295
const nearestBtn = el("button", {
1292-
class: "linklike cities-nearest",
1296+
class: "btn btn-ghost nearest-btn",
12931297
type: "button",
12941298
text: t("act_nearest"),
1295-
attrs: { title: t("nearest_hint") },
1299+
attrs: { title: t("nearest_hint"), hidden: "" },
12961300
on: { click: addNearestCity },
12971301
});
1302+
nearestBtnEl = nearestBtn;
12981303
const citiesField = field(
12991304
t("field_cities"),
13001305
el("div", { class: "cities-wrap" }, [
13011306
citiesBox,
1302-
el("div", { class: "cities-actions" }, [nearestBtn, clearCitiesBtn]),
1307+
el("div", { class: "cities-actions" }, [clearCitiesBtn]),
13031308
]),
13041309
);
13051310
// How many days to spend in each city before the next hop — a range, so the
@@ -1387,7 +1392,7 @@ function buildForm(): FormBuild {
13871392
stayField,
13881393
]),
13891394
advanced,
1390-
el("div", { class: "form-actions" }, [searchBtn, surpriseBtn]),
1395+
el("div", { class: "form-actions" }, [searchBtn, surpriseBtn, nearestBtn]),
13911396
surpriseMsgEl,
13921397
howto,
13931398
stationList,

‎src/styles.css‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,7 @@ a {
358358
gap: 0.75rem;
359359
flex-wrap: wrap;
360360
}
361-
.cities-clear,
362-
.cities-nearest {
361+
.cities-clear {
363362
font-size: 0.8rem;
364363
}
365364
.cities-input {

0 commit comments

Comments
 (0)