Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2b784a2
very basic odoc search working, but no keyboard nav yet
sabine Apr 17, 2023
21bd77d
no '.' on empty prefixname
sabine Apr 18, 2023
b30e188
serve search index under immutable digest URL
sabine Apr 24, 2023
d61eee5
vendor FuseJS and color entries
sabine Apr 24, 2023
470ea86
limit number of results to 200
sabine Apr 24, 2023
f750c25
replace fuseJS by MiniSearch
sabine May 8, 2023
40ff84d
move in package search styles
sabine May 8, 2023
3264cb8
load search index only if search input gets focused
sabine May 8, 2023
c2eeff6
basic keyboard interaction and position absolute overlay
sabine May 8, 2023
424f0fa
simplify, styles
sabine May 8, 2023
15b4fb9
not alpinejs' responsibility to hide/show the dropdown, let's do it c…
sabine May 9, 2023
1bd8737
adjust weights
sabine May 9, 2023
1c8c995
fmt
sabine May 9, 2023
5991047
in case there's no search index, don't render a search bar
sabine May 9, 2023
f773abb
hide <br>
sabine May 9, 2023
d3ad6dd
tailwindcss
sabine May 9, 2023
62a7cf4
class typ -> class type
sabine May 10, 2023
8f841f0
add a shadow and boost shorter results
sabine May 15, 2023
952c686
fix scrolling to element on current page
sabine May 19, 2023
2cd03ef
show the full docstring on active element
sabine May 19, 2023
ee20b4e
scrollTo is unnecessary, as is clearing search results when we stay
sabine May 19, 2023
dfcb6d8
only collapse docstring on md+ screens
sabine May 19, 2023
908c686
no longer need to reverse prefix name
sabine May 19, 2023
1940dfa
fixes scrolling on mobile, adds more quality of life features
sabine May 19, 2023
b8d6dce
prevent hijacking of 'S' key in top search bar
sabine May 19, 2023
b45d61b
add a loading indicator for the search index on first interaction wit…
sabine May 22, 2023
95618b6
limit max-height of docstring - see Lwt.bind
sabine May 22, 2023
e741b71
add aria attributes for better accessibility
sabine May 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions LICENSE-3RD-PARTY
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ URL: https://swiperjs.com/
License: MIT License
Copyright: Copyright 2014-2021 Vladimir Kharlampidi

asset/vendors/minisearch.min.js:

Name: Minisearch
Version: 6.0.1
URL: https://github.com/lucaong/minisearch
License: MIT License
Copyright: Copyright 2022 Luca Ongaro

--------------------------------------------------------------------------
Licenses
--------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions asset/vendors/minisearch.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/global/url.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module Package : sig

val file :
?hash:string -> ?version:string -> filepath:string -> string -> string

val search_index : ?version:string -> digest:string -> string -> string
end = struct
let with_hash = Option.fold ~none:"/p" ~some:(( ^ ) "/u/")
let with_version = Option.fold ~none:"/latest" ~some:(( ^ ) "/")
Expand All @@ -25,6 +27,7 @@ end = struct
base ?hash ?version ("/doc/" ^ page)

let file ?hash ?version ~filepath = base ?hash ?version ("/" ^ filepath)
let search_index ?version ~digest = base ?version ("/search-index/" ^ digest)
end

let sitemap = "/sitemap.xml"
Expand Down
2 changes: 1 addition & 1 deletion src/ocamlorg_frontend/components/header.eml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let render
<%s! Packages_autocomplete_fragment.form_attributes %>
action="/packages/search" method="GET">
<div class="header__search relative flex items-center justify-center">
<input type="search" name="q" class="header__search__input focus:border-gray-800 text-gray-800 border-primary-600 h-10 rounded-l-md appearance-none px-4 py-1 lg:w-56 xl:w-80"
<input @keydown.stop type="search" name="q" class="header__search__input focus:border-gray-800 text-gray-800 border-primary-600 h-10 rounded-l-md appearance-none px-4 py-1 lg:w-56 xl:w-80"
autocomplete="off"
placeholder="Search OCaml Packages"
<%s! Packages_autocomplete_fragment.input_attributes ~target_sel:"#header-search-results" ~indicator_sel:"#header-search-indicator" %>
Expand Down
124 changes: 124 additions & 0 deletions src/ocamlorg_frontend/css/partials/in_package_search.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#in-package-search-results ol {
@apply m-0 p-0 list-none text-sm;
}

#in-package-search-results li {
@apply m-0 p-0 border-b;
}

#in-package-search-results br {
@apply hidden;
}

#in-package-search-results .search-entry {
@apply px-4 py-1 font-normal text-body-600 flex flex-col;
--entry-color: gray;
}

#in-package-search-results li:first-child .search-entry {
@apply pt-2;
}

#in-package-search-results li:last-child .search-entry {
@apply pb-2;
}

#in-package-search-results .search-entry:hover {
text-decoration: none;
background: #f4f4f4;
}

/*
@media (min-width: 64em) {
#in-package-search-results .search-entry {
@apply flex-row;
}

#in-package-search-results .search-entry .entry-title {
@apply shrink-0 w-1/2;
}
}
*/

#in-package-search-results .search-entry .entry-kind {
@apply py-0.5 px-1 bg-body-600 text-white rounded mr-2 text-sm;
}

#in-package-search-results .search-entry .entry-kind {
background: var(--entry-color);
}

#in-package-search-results .search-entry.mod {
--entry-color: rgb(204, 78, 12);
}

#in-package-search-results .search-entry.mty {
--entry-color: #027491;
}

#in-package-search-results .search-entry.mtd {
--entry-color: #327d8e;
}

#in-package-search-results .search-entry.typ {
--entry-color: rgb(42, 84, 183);
}

#in-package-search-results .search-entry.val {
--entry-color: green;
}

#in-package-search-results .search-entry.par {
--entry-color: green;
}

#in-package-search-results .search-entry.cls {
--entry-color: rgb(163, 34, 34);
}

#in-package-search-results .search-entry.cty {
--entry-color: rgb(32, 68, 165);
}

#in-package-search-results .search-entry.exc {
--entry-color: #370c62;
}

#in-package-search-results .search-entry.man {
--entry-color: #47424b;
}

#in-package-search-results .search-entry .entry-title {
overflow-wrap: anywhere;
}

#in-package-search-results .search-entry .entry-name {
@apply font-bold;
color: var(--entry-color);
}

#in-package-search-results .search-entry .prefix-name {
@apply font-semibold;
}

#in-package-search-results .entry-comment {
@apply overflow-hidden text-ellipsis max-h-[10rem];
}

@media (min-width: 40em) {
#in-package-search-results .search-entry:not(.active):not(.open) .entry-comment {
@apply whitespace-nowrap;
}
}

#in-package-search-results .active {
@apply bg-primary-100;
}

#in-package-search #in-package-search-results {
@apply hidden;
}

#in-package-search:focus-within #in-package-search-results {
@apply block;
}
1 change: 1 addition & 0 deletions src/ocamlorg_frontend/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@import "./partials/cards.css";
@import "./partials/forms.css";
@import "./partials/grid_logos.css";
@import "./partials/in_package_search.css";
@import "./partials/search.css";
@import "./partials/package_breadcrumbs.css";
@import "./partials/shadows.css";
Expand Down
Loading