Skip to content

Commit

Permalink
Rollup merge of #102924 - notriddle:notriddle/sidebar-link-class, r=G…
Browse files Browse the repository at this point in the history
…uillaumeGomez

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.
  • Loading branch information
Dylan-DPC committed Oct 12, 2022
2 parents 252ce10 + 062284a commit 96bcced
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 97 deletions.
54 changes: 27 additions & 27 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -218,55 +218,55 @@ pre.rust a,
.sidebar h2 a,
.sidebar h3 a,
.mobile-topbar h2 a,
h1.fqn a,
h1 a,
.search-results a,
.module-item .stab,
.import-item .stab,
.result-name .primitive > i, .result-name .keyword > i,
.content .method .where,
.content .fn .where,
.content .where.fmt-newline {
.method .where,
.fn .where,
.where.fmt-newline {
color: var(--main-color);
}

.content span.enum, .content a.enum,
.content span.struct, .content a.struct,
.content span.union, .content a.union,
.content span.primitive, .content a.primitive,
.content span.type, .content a.type,
.content span.foreigntype, .content a.foreigntype {
span.enum, a.enum,
span.struct, a.struct,
span.union, a.union,
span.primitive, a.primitive,
span.type, a.type,
span.foreigntype, a.foreigntype {
color: var(--type-link-color);
}

.content span.trait, .content a.trait,
.content span.traitalias, .content a.traitalias {
span.trait, a.trait,
span.traitalias, a.traitalias {
color: var(--trait-link-color);
}

.content span.associatedtype, .content a.associatedtype,
.content span.constant, .content a.constant,
.content span.static, .content a.static {
span.associatedtype, a.associatedtype,
span.constant, a.constant,
span.static, a.static {
color: var(--assoc-item-link-color);
}

.content span.fn, .content a.fn,
.content .fnname,
.content span.method, .content a.method,
.content span.tymethod, .content a.tymethod {
span.fn, a.fn,
.fnname,
span.method, a.method,
span.tymethod, a.tymethod {
color: var(--function-link-color);
}

.content span.attr, .content a.attr,
.content span.derive, .content a.derive,
.content span.macro, .content a.macro {
span.attr, a.attr,
span.derive, a.derive,
span.macro, a.macro {
color: var(--macro-link-color);
}

.content span.mod, .content a.mod, .block a.current.mod {
span.mod, a.mod {
color: var(--mod-link-color);
}

.content span.keyword, .content a.keyword {
span.keyword, a.keyword {
color: var(--keyword-link-color);
}

Expand Down Expand Up @@ -685,9 +685,9 @@ pre, .rustdoc.source .example-wrap {
}

/* Shift "where ..." part of method or fn definition down a line */
.content .method .where,
.content .fn .where,
.content .where.fmt-newline {
.method .where,
.fn .where,
.where.fmt-newline {
display: block;
font-size: 0.875rem;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ input:focus + .slider {
h1, h2, h3, h4 {
color: white;
}
h1.fqn a {
h1 a {
color: #fff;
}
h4 {
Expand Down
8 changes: 3 additions & 5 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,21 +451,19 @@ function loadCss(cssFileName) {
const name = item[0];
const desc = item[1]; // can be null

let klass = shortty;
let path;
if (shortty === "mod") {
path = name + "/index.html";
} else {
path = shortty + "." + name + ".html";
}
const current_page = document.location.href.split("/").pop();
if (path === current_page) {
klass += " current";
}
const link = document.createElement("a");
link.href = path;
link.title = desc;
link.className = klass;
if (path === current_page) {
link.className = "current";
}
link.textContent = name;
const li = document.createElement("li");
li.appendChild(link);
Expand Down
Loading

0 comments on commit 96bcced

Please sign in to comment.