From 05f4385dc72df17eea850fd27b4b77d7b4f6f840 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 13 May 2024 09:25:21 -0300 Subject: client: search result kind accent --- src/static/css/site.css | 3 ++- src/static/js/client.js | 31 ++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) (limited to 'src/static') diff --git a/src/static/css/site.css b/src/static/css/site.css index 766a4010..41d0414b 100644 --- a/src/static/css/site.css +++ b/src/static/css/site.css @@ -575,7 +575,8 @@ summary .group-name { text-decoration: underline; } -.wiki-search-current-result-text { +.wiki-search-current-result-text, +.wiki-search-result-kind { font-style: oblique; opacity: 0.9; display: inline-block; diff --git a/src/static/js/client.js b/src/static/js/client.js index 31e16aa2..5b762c49 100644 --- a/src/static/js/client.js +++ b/src/static/js/client.js @@ -3589,6 +3589,8 @@ const sidebarSearchInfo = initInfo('sidebarSearchInfo', { currentResultString: null, endSearchString: null, + artistResultKindString: null, + state: { stoppedTypingTimeout: null, }, @@ -3627,6 +3629,9 @@ function getSidebarSearchReferences() { info.endSearchString = findString('end-search'); + + info.artistResultKindString = + findString('artist-result-kind'); } function mutateSidebarSearchContent() { @@ -3820,6 +3825,8 @@ function showSidebarSearchResults(results) { } function generateSidebarSearchResult(result) { + const info = sidebarSearchInfo; + const preparedSlots = { color: result.data.color ?? null, @@ -3836,6 +3843,9 @@ function generateSidebarSearchResult(result) { preparedSlots.href = openArtist(result.directory); + preparedSlots.kindString = + info.artistResultKindString; + break; } @@ -3920,18 +3930,29 @@ function generateSidebarSearchResultTemplate(slots) { text.appendChild(span); } + let accentSpan = null; + if (link.href) { const here = location.href.replace(/\/$/, ''); const there = link.href.replace(/\/$/, ''); if (here === there) { - const span = document.createElement('span'); - span.classList.add('wiki-search-current-result-text'); - span.appendChild(templateContent(info.currentResultString)); - text.appendChild(document.createTextNode(' ')); - text.appendChild(span); + accentSpan = document.createElement('span'); + accentSpan.classList.add('wiki-search-current-result-text'); + accentSpan.appendChild(templateContent(info.currentResultString)); } } + if (!accentSpan && slots.kindString) { + accentSpan = document.createElement('span'); + accentSpan.classList.add('wiki-search-result-kind'); + accentSpan.appendChild(templateContent(slots.kindString)); + } + + if (accentSpan) { + text.appendChild(document.createTextNode(' ')); + text.appendChild(accentSpan); + } + link.appendChild(text); return link; -- cgit 1.3.0-6-gf8a5