feat Add routine workout accordions

Collapse routine descriptions until a trainee expands a workout summary.

Commit
c3d85863ebe7b95588c8bf5ede454125a59aebdb
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/web/pages.ml
index 482e910a..42caba5f 100644..100644
@@ -317,18 +317,30 @@
317 317 html_page ~trainee ~active:"routine" "Routine"
318 318 [
319 319 tag "h2" [] [ txt "%s" (Prescription.Routine.name routine) ];
320 Removed: tag "ul" []
320 Added: tag "div"
321 Added: [ class_ "routine-accordions" ]
321 322 (List.map
322 323 (fun workout ->
323 Removed: tag "li" []
324 Added: tag "details"
325 Added: [ class_ "routine-accordion" ]
324 326 [
325 Removed: txt "%s" (Prescription.Workout.name workout);
326 Removed: tag "ul" []
327 Removed: (List.map
328 Removed: (fun stimulus ->
329 Removed: tag "li" []
330 Removed: [ txt "%s" (describe_prescription stimulus) ])
331 Removed: (Prescription.Workout.stimuli workout));
327 Added: tag "summary" []
328 Added: [
329 Added: txt "%s — %d prescribed stimuli"
330 Added: (Prescription.Workout.name workout)
331 Added: (List.length (Prescription.Workout.stimuli workout));
332 Added: ];
333 Added: tag "div"
334 Added: [ class_ "routine-description" ]
335 Added: [
336 Added: tag "p" [] [ txt "Description" ];
337 Added: tag "ul" []
338 Added: (List.map
339 Added: (fun stimulus ->
340 Added: tag "li" []
341 Added: [ txt "%s" (describe_prescription stimulus) ])
342 Added: (Prescription.Workout.stimuli workout));
343 Added: ];
332 344 ])
333 345 (Prescription.Routine.workouts routine));
334 346 ]
test/test_web.ml
index fb5071d6..fa7954d2 100644..100644
@@ -248,6 +248,31 @@
248 248 Alcotest.(check bool)
249 249 "first effort form" true
250 250 (contains ~substring:"/workout/slots/0" workout_page) );
251 Added: ( "the routine page uses workout description accordions",
252 Added: `Quick,
253 Added: fun () ->
254 Added: let c = client () in
255 Added: let _ = sign_in_new c in
256 Added: let selection_page = body (get c "/") in
257 Added: let token = Option.get (csrf_token selection_page) in
258 Added: let selection =
259 Added: post c "/routines/ideal/select" [ ("dream.csrf", token) ]
260 Added: in
261 Added: Alcotest.(check int) "routine selected" 303 (status selection);
262 Added: let page = body (get c "/routine") in
263 Added: Alcotest.(check bool)
264 Added: "uses details" true
265 Added: (contains ~substring:"<details" page);
266 Added: Alcotest.(check bool)
267 Added: "summarizes Day 1" true
268 Added: (contains ~substring:"<summary>Day 1" page);
269 Added: Alcotest.(check bool)
270 Added: "includes description" true
271 Added: (contains ~substring:"Description" page);
272 Added: Alcotest.(check bool)
273 Added: "includes prescription" true
274 Added: (contains ~substring:"Dumbbell Flyes into Incline Presses" page)
275 Added: );
251 276 ( "signing out returns the trainee to the sign-in page",
252 277 `Quick,
253 278 fun () ->