about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2023-06-20 14:23:39 +0200
committerGitHub <noreply@github.com>2023-06-20 14:23:39 +0200
commita318824b434b6f60a467dca09cd8cefcd35d24c9 (patch)
treedf752b138f4120b3b62fc87efcd47bf275c58652
parent816b659157a6ab530883992a19a0768a51bb1c30 (diff)
parentc3cdf8542d8af35d45dedfa2d9eaccd968e69db7 (diff)
downloadrust-a318824b434b6f60a467dca09cd8cefcd35d24c9.tar.gz
rust-a318824b434b6f60a467dca09cd8cefcd35d24c9.zip
Rollup merge of #112720 - poliorcetics:rustdoc-item-type-color-same-as-item-color, r=notriddle,GuillaumeGomez
Rustdoc: search: color item type and reduce size to avoid clashing

- rustdoc: search: color item type same as item
- rustdoc: search: reduce item type size to 0.875rem to avoid clashing with path and item
-rw-r--r--src/librustdoc/html/static/css/rustdoc.css4
-rw-r--r--src/librustdoc/html/static/js/search.js4
-rw-r--r--tests/rustdoc-gui/search-result-color.goml6
3 files changed, 13 insertions, 1 deletions
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index b487cfa5c25..21c1eb631e0 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -890,6 +890,10 @@ so that we can apply CSS-filters to change the arrow color in themes */
 .search-results .result-name .grey {
 	color: var(--search-results-grey-color);
 }
+.search-results .result-name .typename {
+	color: var(--search-results-grey-color);
+	font-size: 0.875rem;
+}
 
 .popover {
 	position: absolute;
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 3059dac8207..452348dc865 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -2024,7 +2024,9 @@ function initSearch(rawSearchIndex) {
 
                 resultName.insertAdjacentHTML(
                     "beforeend",
-                    `${typeName} ${item.displayPath}<span class="${type}">${name}</span>`);
+                    `<span class="typename">${typeName}</span>`
+                    + ` ${item.displayPath}<span class="${type}">${name}</span>`
+                );
                 link.appendChild(resultName);
 
                 const description = document.createElement("div");
diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml
index c75e4141434..193a3eb3fd1 100644
--- a/tests/rustdoc-gui/search-result-color.goml
+++ b/tests/rustdoc-gui/search-result-color.goml
@@ -28,6 +28,12 @@ define-function: (
             ".result-" + |result_kind| + ":focus ." + |result_kind|,
             {"color": |hover_color|},
         )
+        // color of the typename (struct, module, method, ...) before search results
+        assert-css: (
+            ".result-name .typename",
+            {"color": "#888"},
+            ALL,
+        )
     },
 )