Skip to content

Commit 96bcced

Browse files
authored
Rollup merge of #102924 - notriddle:notriddle/sidebar-link-class, r=GuillaumeGomez
rustdoc: remove unused classes from sidebar links Since 98f05a0 removed separate colors from the currently-selected item, there's no need to have item classes on sidebar links. Preview: https://notriddle.com/notriddle-rustdoc-demos/sidebar-link-class/std/vec/struct.Vec.html While cleaning up the CSS to remove unneeded `.content` selectors, this PR changes the `h1.fqn a` CSS selector to just be `h1 a`, so that the header link color selector is less specific than the typed link at the end. Since #89506 made docblocks start at `h2`, the main page link header should be the only h1 in the page now.
2 parents 252ce10 + 062284a commit 96bcced

File tree

5 files changed

+95
-97
lines changed

5 files changed

+95
-97
lines changed

src/librustdoc/html/static/css/rustdoc.css

+27-27
Original file line numberDiff line numberDiff line change
@@ -218,55 +218,55 @@ pre.rust a,
218218
.sidebar h2 a,
219219
.sidebar h3 a,
220220
.mobile-topbar h2 a,
221-
h1.fqn a,
221+
h1 a,
222222
.search-results a,
223223
.module-item .stab,
224224
.import-item .stab,
225225
.result-name .primitive > i, .result-name .keyword > i,
226-
.content .method .where,
227-
.content .fn .where,
228-
.content .where.fmt-newline {
226+
.method .where,
227+
.fn .where,
228+
.where.fmt-newline {
229229
color: var(--main-color);
230230
}
231231

232-
.content span.enum, .content a.enum,
233-
.content span.struct, .content a.struct,
234-
.content span.union, .content a.union,
235-
.content span.primitive, .content a.primitive,
236-
.content span.type, .content a.type,
237-
.content span.foreigntype, .content a.foreigntype {
232+
span.enum, a.enum,
233+
span.struct, a.struct,
234+
span.union, a.union,
235+
span.primitive, a.primitive,
236+
span.type, a.type,
237+
span.foreigntype, a.foreigntype {
238238
color: var(--type-link-color);
239239
}
240240

241-
.content span.trait, .content a.trait,
242-
.content span.traitalias, .content a.traitalias {
241+
span.trait, a.trait,
242+
span.traitalias, a.traitalias {
243243
color: var(--trait-link-color);
244244
}
245245

246-
.content span.associatedtype, .content a.associatedtype,
247-
.content span.constant, .content a.constant,
248-
.content span.static, .content a.static {
246+
span.associatedtype, a.associatedtype,
247+
span.constant, a.constant,
248+
span.static, a.static {
249249
color: var(--assoc-item-link-color);
250250
}
251251

252-
.content span.fn, .content a.fn,
253-
.content .fnname,
254-
.content span.method, .content a.method,
255-
.content span.tymethod, .content a.tymethod {
252+
span.fn, a.fn,
253+
.fnname,
254+
span.method, a.method,
255+
span.tymethod, a.tymethod {
256256
color: var(--function-link-color);
257257
}
258258

259-
.content span.attr, .content a.attr,
260-
.content span.derive, .content a.derive,
261-
.content span.macro, .content a.macro {
259+
span.attr, a.attr,
260+
span.derive, a.derive,
261+
span.macro, a.macro {
262262
color: var(--macro-link-color);
263263
}
264264

265-
.content span.mod, .content a.mod, .block a.current.mod {
265+
span.mod, a.mod {
266266
color: var(--mod-link-color);
267267
}
268268

269-
.content span.keyword, .content a.keyword {
269+
span.keyword, a.keyword {
270270
color: var(--keyword-link-color);
271271
}
272272

@@ -685,9 +685,9 @@ pre, .rustdoc.source .example-wrap {
685685
}
686686

687687
/* Shift "where ..." part of method or fn definition down a line */
688-
.content .method .where,
689-
.content .fn .where,
690-
.content .where.fmt-newline {
688+
.method .where,
689+
.fn .where,
690+
.where.fmt-newline {
691691
display: block;
692692
font-size: 0.875rem;
693693
}

src/librustdoc/html/static/css/themes/ayu.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ input:focus + .slider {
5656
h1, h2, h3, h4 {
5757
color: white;
5858
}
59-
h1.fqn a {
59+
h1 a {
6060
color: #fff;
6161
}
6262
h4 {

src/librustdoc/html/static/js/main.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -451,21 +451,19 @@ function loadCss(cssFileName) {
451451
const name = item[0];
452452
const desc = item[1]; // can be null
453453

454-
let klass = shortty;
455454
let path;
456455
if (shortty === "mod") {
457456
path = name + "/index.html";
458457
} else {
459458
path = shortty + "." + name + ".html";
460459
}
461460
const current_page = document.location.href.split("/").pop();
462-
if (path === current_page) {
463-
klass += " current";
464-
}
465461
const link = document.createElement("a");
466462
link.href = path;
467463
link.title = desc;
468-
link.className = klass;
464+
if (path === current_page) {
465+
link.className = "current";
466+
}
469467
link.textContent = name;
470468
const li = document.createElement("li");
471469
li.appendChild(link);

0 commit comments

Comments
 (0)