Skip to content

Commit 2c6caad

Browse files
committed
auto merge of #14878 : vtsatskin/rust/rustdoc-sidebar-click-targets, 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
2 parents 1cde9d8 + 0188beb commit 2c6caad

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/librustdoc/html/render.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ impl<'a> fmt::Show for Sidebar<'a> {
20012001
let class = if cur.name.get_ref() == item &&
20022002
short == curty { "current" } else { "" };
20032003
try!(write!(w, "<a class='{ty} {class}' href='{href}{path}'>\
2004-
{name}</a><br/>",
2004+
{name}</a>",
20052005
ty = short,
20062006
class = class,
20072007
href = if curty == "mod" {"../"} else {""},

src/librustdoc/html/static/main.css

+8-4
Original file line numberDiff line numberDiff line change
@@ -154,25 +154,29 @@ nav.sub {
154154

155155
.block {
156156
padding: 0 10px;
157-
margin-bottom: 10px;
157+
margin-bottom: 14px;
158158
}
159159
.block h2 {
160160
margin-top: 0;
161+
margin-bottom: 8px;
161162
text-align: center;
162163
}
163164

164165
.block a {
165-
display: inline-block;
166+
display: block;
166167
text-overflow: ellipsis;
167168
overflow: hidden;
168169
line-height: 15px;
169-
padding-left: 5px;
170-
padding-bottom: 6px;
170+
padding: 7px 5px;
171171
font-size: 14px;
172172
font-weight: 300;
173173
transition: border 500ms ease-out;
174174
}
175175

176+
.block a:hover {
177+
background: #F5F5F5;
178+
}
179+
176180
.content {
177181
padding: 15px 0;
178182
}

src/librustdoc/html/static/main.js

-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@
647647
}
648648
div.append($('<a>', {'href': '../' + crates[i] + '/index.html',
649649
'class': klass}).text(crates[i]));
650-
div.append($('<br>'));
651650
}
652651
sidebar.append(div);
653652
}

0 commit comments

Comments
 (0)