View raw

1 open Dream_html 2 open Page_kit 3 open Page_shell 4 5 (* The settings page. It currently stores the user's light or dark theme choice 6 in the session. *) 7 let settings request ?workout_started ~viewer ~theme () = 8 let next_theme, label = 9 match theme with 10 | "dark" -> ("light", "Use light theme") 11 | _ -> ("dark", "Use dark theme") 12 in 13 html_page ~viewer ~request ~active:"settings" ?workout_started "Settings" 14 [ 15 tag "h1" [] [ txt "Settings" ]; 16 tag "section" 17 [ class_ "settings-section" ] 18 [ 19 tag "h2" [] [ txt "Theme" ]; 20 tag "p" [] [ txt "Choose a light or dark theme for this session." ]; 21 tag "form" 22 [ action Routes.settings_theme; post_form; class_ "settings-form" ] 23 [ 24 Dream_html.csrf_tag request; 25 void "input" 26 [ 27 type_ "hidden"; 28 name "theme"; 29 Dream_html.string_attr "value" "%s" next_theme; 30 ]; 31 void "input" 32 [ type_ "submit"; Dream_html.string_attr "value" "%s" label ]; 33 ]; 34 ]; 35 ] 36