feat add unit placeholders to load and reps fields

Hint the load and reps inputs with their unit ("kg", "reps"). The placeholders name the field's unit, not a target: a set ends at failure, never at a rep count, so no prescribed number is suggested.

Commit
f3a5551021bfedd9fbc8b86f9ef512a5d947a26d
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
ENHANCEMENTS.org
index bf197856..db6a24fd 100644..100644
@@ -11,7 +11,7 @@
11 11 Replace the top bar brand with `hito` in Work Sans, without a subtitle.
12 12 ** DONE Remove the mobile hamburger menu
13 13 Do not show a hamburger menu on mobile.
14 Removed: ** TODO Add placeholders to load and reps fields
14 Added: ** DONE Add placeholders to load and reps fields
15 15 Add placeholder values to the load and reps fields on the workout logging page.
16 16 ** TODO Remove the redundant fieldset legend
17 17 Remove the redundant fieldset legend from workout logging.
lib/web/pages.ml
index 0f943396..89676bc1 100644..100644
@@ -429,7 +429,8 @@
429 429 [ txt "%s" (Decode.errors_to_text [ (field, error) ]) ];
430 430 ]
431 431
432 Removed: let input_row ?value:v ?(invalid = false) ~input_id (field : string) label =
432 Added: let input_row ?value:v ?(invalid = false) ?placeholder ~input_id
433 Added: (field : string) label =
433 434 let error_attrs =
434 435 if invalid then
435 436 [
@@ -438,6 +439,11 @@
438 439 ]
439 440 else []
440 441 in
442 Added: let placeholder_attr =
443 Added: match placeholder with
444 Added: | None -> []
445 Added: | Some p -> [ Dream_html.string_attr "placeholder" "%s" p ]
446 Added: in
441 447 tag "div"
442 448 [ class_ "field" ]
443 449 [
@@ -452,7 +458,7 @@
452 458 step "0.5";
453 459 required;
454 460 ]
455 Removed: @ error_attrs
461 Added: @ placeholder_attr @ error_attrs
456 462 @
457 463 match v with
458 464 | None -> []
@@ -461,16 +467,17 @@
461 467
462 468 (* Load and reps sit side by side. The [.row] class is a two-column grid that
463 469 collapses to one column on a narrow screen. Each movement of a pre-exhaust
464 Removed: pair gets its own row, so both stay paired. *)
470 Added: pair gets its own row, so both stay paired. The placeholders hint the field's
471 Added: unit, not a target: a set ends at failure, never at a number. *)
465 472 let load_reps_row ~(errors : (string * string) list) ~load_id ~load_field
466 473 ~reps_id ~reps_field ?load_value ?reps_value ~reps_label () =
467 474 tag "div"
468 475 [ class_ "row" ]
469 476 [
470 Removed: input_row ?value:load_value
477 Added: input_row ?value:load_value ~placeholder:"kg"
471 478 ~invalid:(List.mem_assoc load_field errors)
472 479 ~input_id:load_id load_field "Load (kg)";
473 Removed: input_row ?value:reps_value
480 Added: input_row ?value:reps_value ~placeholder:"reps"
474 481 ~invalid:(List.mem_assoc reps_field errors)
475 482 ~input_id:reps_id reps_field reps_label;
476 483 ]
test/test_web.ml
index 4a61ca5e..41c257ff 100644..100644
@@ -485,7 +485,13 @@
485 485 (contains ~substring:"class=\"row\"" page);
486 486 Alcotest.(check bool)
487 487 "still labels load" true
488 Removed: (contains ~substring:"Load (kg)" page) );
488 Added: (contains ~substring:"Load (kg)" page);
489 Added: Alcotest.(check bool)
490 Added: "hints the load field with its unit" true
491 Added: (contains ~substring:"placeholder=\"kg\"" page);
492 Added: Alcotest.(check bool)
493 Added: "hints the reps field" true
494 Added: (contains ~substring:"placeholder=\"reps\"" page) );
489 495 ( "a recorded slot can be corrected, replacing it rather than adding \
490 496 volume",
491 497 `Quick,