Skip to content

Commit 38c8bc5

Browse files
Unify run button display with "copy code" button and with mdbook buttons
1 parent 1ddedba commit 38c8bc5

File tree

3 files changed

+23
-42
lines changed

3 files changed

+23
-42
lines changed

src/librustdoc/html/markdown.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
304304
Some(format!(
305305
"<a class=\"test-arrow\" \
306306
target=\"_blank\" \
307-
href=\"{url}?code={test_escaped}{channel}&amp;edition={edition}\">Run</a>",
307+
title=\"Run code\" \
308+
href=\"{url}?code={test_escaped}{channel}&amp;edition={edition}\"></a>",
308309
))
309310
});
310311

src/librustdoc/html/static/css/noscript.css

-8
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ nav.sub {
104104
--code-highlight-doc-comment-color: #4d4d4c;
105105
--src-line-numbers-span-color: #c67e2d;
106106
--src-line-number-highlighted-background-color: #fdffd3;
107-
--test-arrow-color: #f5f5f5;
108-
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
109-
--test-arrow-hover-color: #f5f5f5;
110-
--test-arrow-hover-background-color: rgb(78, 139, 202);
111107
--target-background-color: #fdffd3;
112108
--target-border-color: #ad7c37;
113109
--kbd-color: #000;
@@ -210,10 +206,6 @@ nav.sub {
210206
--code-highlight-doc-comment-color: #8ca375;
211207
--src-line-numbers-span-color: #3b91e2;
212208
--src-line-number-highlighted-background-color: #0a042f;
213-
--test-arrow-color: #dedede;
214-
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
215-
--test-arrow-hover-color: #dedede;
216-
--test-arrow-hover-background-color: #4e8bca;
217209
--target-background-color: #494a3d;
218210
--target-border-color: #bb7410;
219211
--kbd-color: #000;

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

+21-33
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ details:not(.toggle) summary {
353353
margin-bottom: .6em;
354354
}
355355

356-
code, pre, a.test-arrow, .code-header {
356+
code, pre, .code-header {
357357
font-family: "Source Code Pro", monospace;
358358
}
359359
.docblock code, .docblock-short code {
@@ -946,8 +946,8 @@ because of the `[-]` element which would overlap with it. */
946946
.main-heading a:hover,
947947
.example-wrap .rust a:hover,
948948
.all-items a:hover,
949-
.docblock a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover:not(.doc-anchor),
950-
.docblock-short a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover,
949+
.docblock a:not(.scrape-help):not(.tooltip):hover:not(.doc-anchor),
950+
.docblock-short a:not(.scrape-help):not(.tooltip):hover,
951951
.item-info a {
952952
text-decoration: underline;
953953
}
@@ -1461,22 +1461,17 @@ documentation. */
14611461
z-index: 1;
14621462
}
14631463
a.test-arrow {
1464-
padding: 5px 7px;
1465-
border-radius: var(--button-border-radius);
1466-
font-size: 1rem;
1467-
color: var(--test-arrow-color);
1468-
background-color: var(--test-arrow-background-color);
1464+
height: var(--copy-path-height);
1465+
padding: 6px 4px 0 11px;
14691466
}
1470-
a.test-arrow:hover {
1471-
color: var(--test-arrow-hover-color);
1472-
background-color: var(--test-arrow-hover-background-color);
1467+
a.test-arrow::before {
1468+
content: url('data:image/svg+xml,<svg viewBox="0 0 20 20" width="18" height="20" \
1469+
xmlns="http://www.w3.org/2000/svg"><path d="M0 0l18 10-18 10z"/></svg>');
14731470
}
14741471
.example-wrap .button-holder {
14751472
display: flex;
14761473
}
1477-
.example-wrap:hover > .test-arrow {
1478-
padding: 2px 7px;
1479-
}
1474+
14801475
/*
14811476
On iPad, the ":hover" state sticks around, making things work not greatly. Do work around
14821477
it, we move it into this media query. More information can be found at:
@@ -1486,29 +1481,34 @@ However, using `@media (hover: hover)` makes this rule never to be applied in GU
14861481
instead, we check that it's not a "finger" cursor.
14871482
*/
14881483
@media not (pointer: coarse) {
1489-
.example-wrap:hover > .test-arrow, .example-wrap:hover > .button-holder {
1484+
.example-wrap:hover > a.test-arrow, .example-wrap:hover > .button-holder {
14901485
visibility: visible;
14911486
}
14921487
}
14931488
.example-wrap .button-holder.keep-visible {
14941489
visibility: visible;
14951490
}
1496-
.example-wrap .button-holder .copy-button {
1497-
color: var(--copy-path-button-color);
1491+
.example-wrap .button-holder .copy-button, .example-wrap .test-arrow {
14981492
background: var(--main-background-color);
1493+
cursor: pointer;
1494+
border-radius: var(--button-border-radius);
14991495
height: var(--copy-path-height);
15001496
width: var(--copy-path-width);
1497+
}
1498+
.example-wrap .button-holder .copy-button {
15011499
margin-left: var(--button-left-margin);
15021500
padding: 2px 0 0 4px;
15031501
border: 0;
1504-
cursor: pointer;
1505-
border-radius: var(--button-border-radius);
15061502
}
1507-
.example-wrap .button-holder .copy-button::before {
1503+
.example-wrap .button-holder .copy-button::before,
1504+
.example-wrap .test-arrow::before {
15081505
filter: var(--copy-path-img-filter);
1506+
}
1507+
.example-wrap .button-holder .copy-button::before {
15091508
content: var(--clipboard-image);
15101509
}
1511-
.example-wrap .button-holder .copy-button:hover::before {
1510+
.example-wrap .button-holder .copy-button:hover::before,
1511+
.example-wrap .test-arrow:hover::before {
15121512
filter: var(--copy-path-img-hover-filter);
15131513
}
15141514
.example-wrap .button-holder .copy-button.clicked::before {
@@ -2552,10 +2552,6 @@ by default.
25522552
--code-highlight-doc-comment-color: #4d4d4c;
25532553
--src-line-numbers-span-color: #c67e2d;
25542554
--src-line-number-highlighted-background-color: #fdffd3;
2555-
--test-arrow-color: #f5f5f5;
2556-
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
2557-
--test-arrow-hover-color: #f5f5f5;
2558-
--test-arrow-hover-background-color: rgb(78, 139, 202);
25592555
--target-background-color: #fdffd3;
25602556
--target-border-color: #ad7c37;
25612557
--kbd-color: #000;
@@ -2658,10 +2654,6 @@ by default.
26582654
--code-highlight-doc-comment-color: #8ca375;
26592655
--src-line-numbers-span-color: #3b91e2;
26602656
--src-line-number-highlighted-background-color: #0a042f;
2661-
--test-arrow-color: #dedede;
2662-
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
2663-
--test-arrow-hover-color: #dedede;
2664-
--test-arrow-hover-background-color: #4e8bca;
26652657
--target-background-color: #494a3d;
26662658
--target-border-color: #bb7410;
26672659
--kbd-color: #000;
@@ -2771,10 +2763,6 @@ Original by Dempfi (https://github.com/dempfi/ayu)
27712763
--code-highlight-doc-comment-color: #a1ac88;
27722764
--src-line-numbers-span-color: #5c6773;
27732765
--src-line-number-highlighted-background-color: rgba(255, 236, 164, 0.06);
2774-
--test-arrow-color: #788797;
2775-
--test-arrow-background-color: rgba(57, 175, 215, 0.09);
2776-
--test-arrow-hover-color: #c5c5c5;
2777-
--test-arrow-hover-background-color: rgba(57, 175, 215, 0.368);
27782766
--target-background-color: rgba(255, 236, 164, 0.06);
27792767
--target-border-color: rgba(255, 180, 76, 0.85);
27802768
--kbd-color: #c5c5c5;

0 commit comments

Comments
 (0)