From 6a49c8fe08b6fbe0f028913f1e57b87dfbceda52 Mon Sep 17 00:00:00 2001 From: Swrup Date: Tue, 22 Apr 2025 16:33:50 +0200 Subject: [PATCH] don't wrap new-thread-link in a div --- src/client/html_util.ml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/client/html_util.ml b/src/client/html_util.ml index 59a539a..06da401 100644 --- a/src/client/html_util.ml +++ b/src/client/html_util.ml @@ -86,18 +86,25 @@ let mk_dropdown_menu ~class_prefix ~label ~at_title ~placeholder mk_content = El.div ~at l let new_thread_link_el t_s = - let mk user = - match user with - | None -> - (* TODO redirect *) - mk_page_link ~label:"Login to post a thread!" Login - | Some _user -> - El.a ~at:[ href (Page.to_path New_thread) ] [ el_txt "New thread" ] + let is_logged_in = S.map get_user t_s |> S.map Option.is_some in + let href_s = + let open Page in + is_logged_in + |> S.map (function false -> Login | true -> New_thread) + |> S.map (fun p -> Some (Jstr.of_string (to_path p))) in - let el = El.div ~at:[ class' "new-thread-link-div" ] [] in + let content_s = + is_logged_in + |> S.map (function + | false -> + (* TODO redirect after login *) + [ el_txt "Login to post a thread!" ] + | true -> [ el_txt "New thread" ] ) + in + let el = El.a [] in + Elr.def_at At.Name.href href_s el; + Elr.def_children el content_s; def_visibility_when_page [ New_thread ] `Off el t_s; - let children = S.map get_user t_s |> S.map (fun u -> [ mk u ]) in - Elr.def_children el children; el let mk_image ~is_small img_info =