[OCaml] Mobile-friendly clone of cgit.
refactor move toolbar outside main, page-header inside main
The breadcrumb/filter toolbar now renders between the topnav and <main>, so it visually merges with the nav banner when sticky. The page-header (repo description) moves inside <main> where it semantically belongs as content.
Changed files
lib/views/layout.ml
@@ -9,6 +9,7 @@
9
9
repo : string option;
10
10
subtitle : string;
11
11
active : page;
12
Added:
toolbar : node list;
12
13
content : node list;
13
14
}
14
15
@@ -141,10 +142,14 @@
141
142
(match page_data.repo with
142
143
| None -> rootnav ~title:root_title
143
144
| Some repo -> topnav ~active:page_data.active repo);
144
Removed:
(match page_data.repo with
145
Removed:
| None -> HTML.null []
146
Removed:
| Some _ -> page_header ~has_repo:true page_data.title page_data.subtitle);
147
Removed:
HTML.main [ id "main" ] page_data.content;
145
Added:
null page_data.toolbar;
146
Added:
HTML.main
147
Added:
[ id "main" ]
148
Added:
((match page_data.repo with
149
Added:
| None -> HTML.null []
150
Added:
| Some _ ->
151
Added:
page_header ~has_repo:true page_data.title page_data.subtitle)
152
Added:
:: page_data.content);
148
153
(match page_data.repo with
149
154
| None -> HTML.null []
150
155
| Some repo -> bottomnav ~active:page_data.active repo);
lib/views/repo.ml
@@ -249,7 +249,7 @@
249
249
250
250
let page_title context = context.repo ^ " — " ^ context.description
251
251
252
Removed:
let render_page ?heading context ~active content =
252
Added:
let render_page ?heading ?toolbar context ~active content =
253
253
respond
254
254
@@ Layout.render ~user_name:context.user_name ~root_title:context.root_title
255
255
~page_title:(page_title context)
@@ -258,6 +258,7 @@
258
258
title = Option.value heading ~default:context.repo;
259
259
subtitle = context.description;
260
260
active;
261
Added:
toolbar = Option.value toolbar ~default:[];
261
262
content;
262
263
}
263
264
@@ -659,10 +660,9 @@
659
660
[ class_ "toolbar"; role `toolbar; Aria.label "Filters and pagination" ]
660
661
[ filters_span; pagination_span ])
661
662
in
662
Removed:
render_page context ~active:Commits
663
Added:
render_page context ~active:Commits ~toolbar:[ tb ]
663
664
HTML.
664
665
[
665
Removed:
tb;
666
666
ul []
667
667
(List.map
668
668
(li_of_commit ~hide_pill ?filter_type ?author ?committer
@@ -722,12 +722,10 @@
722
722
[ class_ "readme-inline" ]
723
723
[ h3 [] [ txt "README" ]; div [ class_ "blob" ] formatted ])
724
724
in
725
Removed:
render_page context ~active:Files
725
Added:
render_page context ~active:Files ~toolbar:[ tb ]
726
726
HTML.
727
727
[
728
Removed:
tb;
729
Removed:
ul [] (List.map (li_of_tree_node context.repo) entries);
730
Removed:
readme_section;
728
Added:
ul [] (List.map (li_of_tree_node context.repo) entries); readme_section;
731
729
]
732
730
733
731
let file ?(active = Layout.Files) context trail (blob : Resolvers.Blob.t) =
@@ -774,12 +772,8 @@
774
772
| [] -> HTML.null []
775
773
in
776
774
render_page context ~active
777
Removed:
HTML.
778
Removed:
[
779
Removed:
toolbar [ breadcrumb_pill context.repo trail ];
780
Removed:
raw_link;
781
Removed:
div blob_attrs formatted_blob;
782
Removed:
]
775
Added:
~toolbar:[ toolbar [ breadcrumb_pill context.repo trail ] ]
776
Added:
HTML.[ raw_link; div blob_attrs formatted_blob ]
783
777
784
778
let commit context (commit : Resolvers.Commit.t) diff =
785
779
let message = parse_commit_message commit.message in
lib/views/root.ml
@@ -158,6 +158,7 @@
158
158
repo = None;
159
159
subtitle = "";
160
160
active = Summary;
161
Added:
toolbar = [];
161
162
content =
162
163
[
163
164
HTML.(