open Dream_html
open Page_kit
open Page_shell
(* The settings page. It currently stores the user's light or dark theme choice
in the session. *)
let settings request ?workout_started ~viewer ~theme () =
let next_theme, label =
match theme with
| "dark" -> ("light", "Use light theme")
| _ -> ("dark", "Use dark theme")
in
html_page ~viewer ~request ~active:"settings" ?workout_started "Settings"
[
tag "h1" [] [ txt "Settings" ];
tag "section"
[ class_ "settings-section" ]
[
tag "h2" [] [ txt "Theme" ];
tag "p" [] [ txt "Choose a light or dark theme for this session." ];
tag "form"
[ action Routes.settings_theme; post_form; class_ "settings-form" ]
[
Dream_html.csrf_tag request;
void "input"
[
type_ "hidden";
name "theme";
Dream_html.string_attr "value" "%s" next_theme;
];
void "input"
[ type_ "submit"; Dream_html.string_attr "value" "%s" label ];
];
];
]