fix keep one source for the active nav page class

The body and the app-shell div both carried the page- class. The client replaces only the app-shell on in-place navigation, so the body class went stale: after moving to the logbook mid-workout, the stale page-workout on the body kept the Current workout action highlighted while the fresh page-logbook highlighted Logbook. Drop the page- class from the body; the app-shell is now the single source, so exactly one bottom-nav action is active.

Commit
b351f47ce2a0b41277fa75d03bcf50315e9d17a6
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
ENHANCEMENTS.org
index 9beff9f7..780296b1 100644..100644
@@ -24,7 +24,7 @@
24 24 Use a secondary brass color for secondary buttons.
25 25 ** DONE Replace history with a logbook endpoint
26 26 Replace the history endpoint with a logbook endpoint that shows all recorded evidence for the user.
27 Removed: ** TODO Fix active bottom-navigation state for current workout and logbook
27 Added: ** DONE Fix active bottom-navigation state for current workout and logbook
28 28 When a current workout is open, selecting the logbook tab marks both Current Workout and Logbook as active in the bottom navigation. Ensure only the selected page is highlighted.
29 29 ** TODO Increase the masthead brand size
30 30 Make the masthead brand name appear much larger.
lib/web/pages.ml
index 58c0d0f4..a4f9ccf1 100644..100644
@@ -110,7 +110,7 @@
110 110 void "link" [ rel "stylesheet"; href Routes.stylesheet ];
111 111 ];
112 112 tag "body"
113 Removed: [ Dream_html.string_attr "class" "hito-app page-%s" active ]
113 Added: [ Dream_html.string_attr "class" "hito-app" ]
114 114 ([
115 115 tag "a"
116 116 [
test/test_web.ml
index 2d2fcf84..546c097e 100644..100644
@@ -275,6 +275,31 @@
275 275 Alcotest.(check bool)
276 276 "drops the routine action while logging" false
277 277 (contains ~substring:">Routine</a>" logging) );
278 Added: ( "only the app shell carries the page class, so active state is single",
279 Added: `Quick,
280 Added: fun () ->
281 Added: (* Regression guard for the double-highlight bug: while a workout is
282 Added: in progress, the body must not carry a stale page- class. Only
283 Added: the app-shell div holds the page class, which the client replaces
284 Added: on navigation, so exactly one bottom-nav action can be active. *)
285 Added: let c = client () in
286 Added: let _ = sign_in_new c in
287 Added: let token = Option.get (csrf_token (body (get c "/"))) in
288 Added: let _ = post c "/routines/ideal/select" [ ("dream.csrf", token) ] in
289 Added: let token = Option.get (csrf_token (body (get c "/"))) in
290 Added: let _ =
291 Added: post c "/workout" [ ("dream.csrf", token); ("override", "false") ]
292 Added: in
293 Added: let logbook = body (get c "/logbook") in
294 Added: Alcotest.(check bool)
295 Added: "the body carries no page class" false
296 Added: (contains ~substring:"class=\"hito-app page-" logbook);
297 Added: Alcotest.(check bool)
298 Added: "the app shell marks the logbook page" true
299 Added: (contains ~substring:"app-shell page-logbook" logbook);
300 Added: Alcotest.(check bool)
301 Added: "the app shell does not also mark the workout page" false
302 Added: (contains ~substring:"app-shell page-workout" logbook) );
278 303 ( "auth pages omit the hamburger menu",
279 304 `Quick,
280 305 fun () ->