Verified Commit 052d34ce authored by Camil Staps's avatar Camil Staps 🚀

Style search results (#4)

parent 17eb620e
Pipeline #14662 failed with stage
in 54 seconds
......@@ -73,7 +73,19 @@ a.hidden {
}
#search-results ul {
padding-left: 1.5em;
list-style-type: none;
padding-left: 0;
}
#search-results a {
color: #999;
text-decoration: none;
}
#search-results a code:first-child {
color: #000;
}
#search-results a:hover {
text-decoration: underline;
}
#content {
......@@ -87,6 +99,7 @@ a.hidden {
/* Icons */
.icon {
display: inline-block;
font-family: monospace;
font-size: 120%;
font-weight: bold;
text-align: center;
......@@ -110,6 +123,10 @@ a.hidden {
color: #49b8c6;
content: '\2261'; /* equivalence */
}
.icon-module:before {
color: #000000;
content: '\274b'; /* teardrop-spoked asterisk */
}
.icon-typedef:before {
color: #e3890b;
content: '\2e2a'; /* :: */
......
......@@ -133,9 +133,15 @@ function highlightCallback(span, cls, str) {
for (let i in results) {
let elem = lunr_items[results[i].ref];
let li = document.createElement('li');
let icon = document.createElement('span');
icon.classList = 'icon icon-' + elem.kind;
li.appendChild(icon);
let a = document.createElement('a');
a.href = make_relative_url('mod/' + elem.module + '.html#' + elem.htmlid);
a.innerHTML = '<code>' + elem.name + '</code> in <code>' + elem.module + '</code>';
if (elem.kind == 'module')
a.innerHTML = '<code>' + elem.name + '</code>';
else
a.innerHTML = '<code>' + elem.name + '</code> in <code>' + elem.module + '</code>';
li.appendChild(a);
searchresults.appendChild(li);
}
......
......@@ -25,6 +25,7 @@ JSONEncode{|IndexItemKind|} _ iik = [JSONString case iik of
JSONEncode{|IndexItem|} _ ii = [JSONObject $ catMaybes
[ Just ("module", JSONString ii.modul)
, Just ("name", JSONString ii.IndexItem.name)
, Just ("kind", hd (JSONEncode{|*|} True ii.kind))
, Just ("htmlid", JSONString (kind +++ "-" +++ ii.IndexItem.name))
, tuple "description" <$> JSONString <$> ii.IndexItem.description
]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment