[OCaml] Mobile-friendly clone of cgit.
refactor hide per-item pills in filtered commit list view
When the commits list is filtered by type, the pill is already shown in the toolbar so repeating it on every list item is redundant. Added a ~hide_pill parameter to li_of_commit and pass true when filter_type is active.
lib/views/repo.ml
@@ -108,7 +108,7 @@
108
108
if months < 12 then quantity months "month"
109
109
else quantity (months / 12) "year"
110
110
111
Removed:
let li_of_commit repo (commit : Resolvers.Commit.t) =
111
Added:
let li_of_commit ?(hide_pill = false) repo (commit : Resolvers.Commit.t) =
112
112
let message = parse_commit_message commit.message in
113
113
let commit_type, commit_title = parse_conventional message.summary in
114
114
let commit_route = Routes.Commit (repo, commit.hash) in
@@ -118,6 +118,7 @@
118
118
in
119
119
let pill =
120
120
match commit_type with
121
Added:
| _ when hide_pill -> HTML.null []
121
122
| None -> HTML.null []
122
123
| Some ct ->
123
124
HTML.(
@@ -192,9 +193,10 @@
192
193
| None -> None
193
194
| Some ct -> Some (ct, Printf.sprintf "/%s/commits/" context.repo)
194
195
in
196
Added:
let hide_pill = Option.is_some filter_type in
195
197
let tb = toolbar ?filter [] in
196
198
render_page context ~active:Commits
197
Removed:
HTML.[ tb; ul [] (List.map (li_of_commit context.repo) commits) ]
199
Added:
HTML.[ tb; ul [] (List.map (li_of_commit ~hide_pill context.repo) commits) ]
198
200
199
201
let breadcrumbs repo (trail : (string * string) list) =
200
202
let root_link = HTML.li [] [ Routes.link_to (Files repo) (txt "Home") ] in