Skip to content

Commit

Permalink
auto merge of #14878 : vtsatskin/rust/rustdoc-sidebar-click-targets, …
Browse files Browse the repository at this point in the history
…r=alexcrichton

There was feedback gathered by @bjz which request for larger click targets in the rustdoc sidebar. Here's my attempt at that.

My only concern with this patch is the removal of `<br>` between sidebar links. This may break formatting for text-only viewers of this documentation. If there is a large enough demographic of people that will be affected, perhaps we can try switching the structure of each sidebar block sidebar to an `<ol>` with each item as a `<li>`. 

* Change links to display:block for click larger targets
* Remove linebreaks due to extra space
* Adjust margins so that element spacing stays the same
* Sidebar item hover background colour chosen from `<pre>` styling
  • Loading branch information
bors committed Jun 14, 2014
2 parents 1cde9d8 + 0188beb commit 2c6caad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/render.rs
Expand Up @@ -2001,7 +2001,7 @@ impl<'a> fmt::Show for Sidebar<'a> {
let class = if cur.name.get_ref() == item &&
short == curty { "current" } else { "" };
try!(write!(w, "<a class='{ty} {class}' href='{href}{path}'>\
{name}</a><br/>",
{name}</a>",
ty = short,
class = class,
href = if curty == "mod" {"../"} else {""},
Expand Down
12 changes: 8 additions & 4 deletions src/librustdoc/html/static/main.css
Expand Up @@ -154,25 +154,29 @@ nav.sub {

.block {
padding: 0 10px;
margin-bottom: 10px;
margin-bottom: 14px;
}
.block h2 {
margin-top: 0;
margin-bottom: 8px;
text-align: center;
}

.block a {
display: inline-block;
display: block;
text-overflow: ellipsis;
overflow: hidden;
line-height: 15px;
padding-left: 5px;
padding-bottom: 6px;
padding: 7px 5px;
font-size: 14px;
font-weight: 300;
transition: border 500ms ease-out;
}

.block a:hover {
background: #F5F5F5;
}

.content {
padding: 15px 0;
}
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/html/static/main.js
Expand Up @@ -647,7 +647,6 @@
}
div.append($('<a>', {'href': '../' + crates[i] + '/index.html',
'class': klass}).text(crates[i]));
div.append($('<br>'));
}
sidebar.append(div);
}
Expand Down

0 comments on commit 2c6caad

Please sign in to comment.