Skip to content

Commit f653e1e

Browse files
committed
vertical layout for search results
1 parent 386602a commit f653e1e

File tree

3 files changed

+47
-35
lines changed

3 files changed

+47
-35
lines changed

src/Main.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ let make = (~cil, ~goblint, ~warnings, ~meta, ~stats, ~file_loc) => {
5353
<div className="navbar-brand mx-2" >{React.string("Gobview")}</div>
5454
</header>
5555
<div className="main row vh-100">
56-
<div className="col-2 border-end overflow-auto bg-light py-2 h-100">
56+
<div className="col-3 border-end overflow-auto bg-light py-2 h-100">
5757
<SidebarLeft
5858
active={state.selected_sidebar_left}
5959
dispatch
6060
search={state.search}
6161
cil={state.cil}
6262
/>
6363
</div>
64-
<div className="col-7 d-flex flex-column">
64+
<div className="col-6 d-flex flex-column">
6565
{switch (state.display) {
6666
| None => <div className="d-flex flex-column h-75 overflow-auto p-4" />
6767
| Some(f) => <Content state display=f dispatch />

src/ui/search/searchResultView.re

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,45 @@ let make_table = (matches, dispatch) => {
1212
<Button class_=["btn", "my-2"] color=`Danger outline=true on_click=clear>
1313
{"Clear results" |> React.string}
1414
</Button>
15-
<table className="table table-hover">
16-
<thead>
17-
<tr>
18-
<th scope="col"> {"#" |> React.string} </th>
19-
<th scope="col"> {"Name" |> React.string} </th>
20-
<th scope="col"> {"Signature" |> React.string} </th>
21-
<th scope="col"> {"Location" |> React.string} </th>
22-
</tr>
23-
</thead>
24-
<tbody>
25-
{matches
26-
|> List.mapi((i, m) => {
27-
let (name, loc, signature, _) = m;
28-
let key = string_of_int(i);
29-
<tr key>
30-
<th scope="row"> {key |> React.string} </th>
31-
<td> {name |> React.string} </td>
32-
<td> {signature |> React.string} </td>
33-
<td>
34-
<Link on_click={on_click(loc)}>
35-
{loc.file
36-
++ ":"
37-
++ string_of_int(loc.line)
38-
|> React.string}
39-
</Link>
40-
</td>
41-
</tr>;
42-
})
43-
|> React.list}
44-
</tbody>
45-
</table>
15+
<CollapsibleList collapsed=false>
16+
{matches
17+
|> List.mapi((i,m) => {
18+
let (name, loc, signature, _) = m;
19+
let key = string_of_int(i);
20+
<CollapsibleListItem key=key name=key>
21+
<table className="table table-hover">
22+
<thead>
23+
<tr>
24+
<th scope="col"></th>
25+
</tr>
26+
</thead>
27+
<tbody>
28+
<tr>
29+
<th scope="row"> {"Name" |> React.string} </th>
30+
<td> {name |> React.string} </td>
31+
</tr>
32+
<tr>
33+
<th scope="row"> {"Signature" |> React.string} </th>
34+
<td> {signature |> React.string} </td>
35+
</tr>
36+
<tr>
37+
<th scope="row"> {"Location" |> React.string} </th>
38+
<td>
39+
<Link on_click={on_click(loc)}>
40+
{loc.file
41+
++ ":"
42+
++ string_of_int(loc.line)
43+
|> React.string}
44+
</Link>
45+
</td>
46+
</tr>
47+
</tbody>
48+
</table>
49+
</CollapsibleListItem>
50+
})
51+
|> React.list
52+
}
53+
</CollapsibleList>
4654
</>;
4755
};
4856

@@ -63,7 +71,6 @@ let make = (~matches: Search.matches, ~dispatch) => {
6371
};
6472

6573
<>
66-
<h5 className="card-title"> {"Results" |> React.string} </h5>
6774
{switch (matches) {
6875
| Loading =>
6976
<div className="d-flex justify-content-center">

src/ui/search/searchView.re

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ open Batteries;
33
[@react.component]
44
let make = (~search: Search.t, ~dispatch) => {
55
<div className="card">
6-
<div className="card-header"> {"Search" |> React.string} </div>
6+
<div className="card-header">
7+
{switch (search.matches) {
8+
| None => "Search" |> React.string
9+
| _ => "Results" |> React.string
10+
}}
11+
</div>
712
<div className="card-body">
813
{switch (search.matches) {
914
| None => <SearchQueryView search dispatch />

0 commit comments

Comments
 (0)