Skip to content

Commit

Permalink
feat: add ability to hide documentation search
Browse files Browse the repository at this point in the history
  • Loading branch information
ghivert committed Jul 23, 2024
1 parent ae04e2f commit c86203c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
12 changes: 9 additions & 3 deletions apps/frontend/src/data/model.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import frontend/view/body/cache
import gleam/dict.{type Dict}
import gleam/function
import gleam/int
import gleam/io
import gleam/list
import gleam/option.{type Option}
import gleam/pair
Expand All @@ -33,6 +32,7 @@ pub type Model {
keep_aliases: Bool,
keep_documented: Bool,
show_old_packages: Bool,
show_documentation_search: Bool,
show_vector_search: Bool,
)
}
Expand All @@ -54,6 +54,7 @@ pub fn init() {
keep_aliases: False,
keep_documented: False,
show_old_packages: False,
show_documentation_search: False,
show_vector_search: False,
)
}
Expand Down Expand Up @@ -90,12 +91,13 @@ pub fn search_key(key key: String, model model: Model) {
model.keep_aliases,
model.keep_documented,
model.show_old_packages,
model.show_documentation_search,
model.show_vector_search,
])
}

fn default_search_key(key key: String) {
key <> string.inspect([False, False, False, False, True, True])
key <> string.inspect([False, False, False, False, True, True, True])
}

pub fn update_search_results(
Expand Down Expand Up @@ -251,7 +253,10 @@ pub fn update_search_results_filter(model: Model) {
False -> []
True -> s |> list.filter(filter)
},
d |> list.filter(filter),
case model.show_documentation_search {
False -> []
True -> d |> list.filter(filter)
},
mods |> list.filter(filter),
)
}
Expand Down Expand Up @@ -297,6 +302,7 @@ pub fn reset(model: Model) {
keep_aliases: False,
keep_documented: False,
show_old_packages: False,
show_documentation_search: False,
show_vector_search: False,
)
}
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/data/msg.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub type Filter {
Aliases
Documented
ShowOldPackages
DocumentationSearch
VectorSearch
}

Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/src/data/search_result.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub type SearchResults {
InternalServerError
SearchResults(
exact_type_matches: List(SearchResult),
exact_matches: List(SearchResult),
matches: List(SearchResult),
signature_searches: List(SearchResult),
exact_name_matches: List(SearchResult),
name_signature_matches: List(SearchResult),
vector_signature_searches: List(SearchResult),
docs_searches: List(SearchResult),
module_searches: List(SearchResult),
)
Expand Down
2 changes: 2 additions & 0 deletions apps/frontend/src/frontend.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ fn handle_oncheck_filter(model, filter, value) {
msg.Documented, value -> model.Model(..model, keep_documented: value)
msg.ShowOldPackages, value -> model.Model(..model, show_old_packages: value)
msg.VectorSearch, value -> model.Model(..model, show_vector_search: value)
msg.DocumentationSearch, value ->
model.Model(..model, show_documentation_search: value)
}
|> model.update_search_results_filter
|> update.none
Expand Down
5 changes: 5 additions & 0 deletions apps/frontend/src/frontend/view/body/body.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ fn sidebar(model: Model) {
"Show old versions",
),
h.div([a.class("filter-separator")], []),
checkbox(
model.show_documentation_search,
msg.DocumentationSearch,
"Documentation Search",
),
checkbox(model.show_vector_search, msg.VectorSearch, "Vector Search"),
]),
h.div([a.class("sidebar-spacer")], []),
Expand Down

0 comments on commit c86203c

Please sign in to comment.