diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-05-13 09:25:21 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-31 12:11:52 -0300 |
commit | 05f4385dc72df17eea850fd27b4b77d7b4f6f840 (patch) | |
tree | 5787342367fd570ac0735df5aecb758daceccc8e | |
parent | 685cbad73cab59210f7f8842e4399d0550f03905 (diff) |
client: search result kind accent
-rw-r--r-- | src/content/dependencies/generateSearchSidebarBox.js | 3 | ||||
-rw-r--r-- | src/static/css/site.css | 3 | ||||
-rw-r--r-- | src/static/js/client.js | 31 | ||||
-rw-r--r-- | src/strings-default.yaml | 3 |
4 files changed, 34 insertions, 6 deletions
diff --git a/src/content/dependencies/generateSearchSidebarBox.js b/src/content/dependencies/generateSearchSidebarBox.js index c534c492..3758f209 100644 --- a/src/content/dependencies/generateSearchSidebarBox.js +++ b/src/content/dependencies/generateSearchSidebarBox.js @@ -28,6 +28,9 @@ export default { html.tag('template', {class: 'wiki-search-end-search-string'}, language.$('misc.search.endSearch')), + + html.tag('template', {class: 'wiki-search-artist-result-kind-string'}, + language.$('misc.search.resultKind.artist')), ], }), }; 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; diff --git a/src/strings-default.yaml b/src/strings-default.yaml index 8486fa6a..7bc215b8 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -629,6 +629,9 @@ misc: currentResult: "(you are here)" endSearch: "(OK, I'm done searching now.)" + resultKind: + artist: "(artist)" + # skippers: # # These are navigational links that only show up when you're |