Skip to content

Commit 578810b

Browse files
Make "copy code" button the same size as the "copy path" button
1 parent ddaa90f commit 578810b

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

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

+11-23
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,8 @@ xmlns="http://www.w3.org/2000/svg" aria-label="Copy to clipboard">\
2525
2s-1.75.755-1.75 1.667c0 .911-.793 1.666-1.75 1.666H4.75C3.793 5.333 3 6.09 3 7z"/>\
2626
<path d="M4 19h6v2H4zM12 11H4v2h8zM4 17h4v-2H4zM15 15v-3l-4.5 4.5L15 21v-3l8.027-.032L23 15z"/>\
2727
</svg>');
28-
--clipboard-image-big: url('data:image/svg+xml,<svg width="22" height="23" viewBox="0 0 24 25" \
29-
xmlns="http://www.w3.org/2000/svg" aria-label="Copy to clipboard">\
30-
<path d="M18 20h2v3c0 1-1 2-2 2H2c-.998 0-2-1-2-2V5c0-.911.755-1.667 1.667-1.667h5A3.323 3.323 0 \
31-
0110 0a3.323 3.323 0 013.333 3.333h5C19.245 3.333 20 4.09 20 5v8.333h-2V9H2v14h16v-3zM3 \
32-
7h14c0-.911-.793-1.667-1.75-1.667H13.5c-.957 0-1.75-.755-1.75-1.666C11.75 2.755 10.957 2 10 \
33-
2s-1.75.755-1.75 1.667c0 .911-.793 1.666-1.75 1.666H4.75C3.793 5.333 3 6.09 3 7z"/>\
34-
<path d="M4 19h6v2H4zM12 11H4v2h8zM4 17h4v-2H4zM15 15v-3l-4.5 4.5L15 21v-3l8.027-.032L23 15z"/>\
35-
</svg>');
28+
--copy-path-height: 34px;
29+
--copy-path-width: 33px;
3630
/* Checkmark <https://www.svgrepo.com/svg/335033/checkmark> */
3731
--checkmark-image: url('data:image/svg+xml,<svg viewBox="-1 -1 23 23" \
3832
xmlns="http://www.w3.org/2000/svg" fill="black" height="18px">\
@@ -1453,9 +1447,9 @@ documentation. */
14531447
z-index: 1;
14541448
}
14551449
a.test-arrow {
1456-
padding: 5px 10px 5px 10px;
1450+
padding: 5px 7px;
14571451
border-radius: 5px;
1458-
font-size: 1.375rem;
1452+
font-size: 1rem;
14591453
color: var(--test-arrow-color);
14601454
background-color: var(--test-arrow-background-color);
14611455
}
@@ -1467,36 +1461,32 @@ a.test-arrow:hover {
14671461
display: flex;
14681462
}
14691463
.example-wrap:hover > .test-arrow {
1470-
padding: 3px 10px;
1464+
padding: 2px 7px;
14711465
}
14721466
.example-wrap:hover > .test-arrow, .example-wrap:hover > .button-holder {
14731467
visibility: visible;
14741468
}
14751469
.example-wrap .button-holder .copy-button {
14761470
color: var(--copy-path-button-color);
14771471
background: var(--main-background-color);
1478-
height: 43px;
1479-
width: 40px;
1472+
height: var(--copy-path-height);
1473+
width: var(--copy-path-width);
14801474
margin-left: 5px;
14811475
padding: 2px 0 0 4px;
14821476
border: 0;
14831477
cursor: pointer;
14841478
border-radius: 5px;
14851479
}
1486-
.example-wrap .button-holder .copy-button.clicked {
1487-
padding-top: 4px;
1488-
}
14891480
.example-wrap .button-holder .copy-button::before {
14901481
filter: var(--copy-path-img-filter);
1491-
content: var(--clipboard-image-big);
1492-
width: 23px;
1493-
height: 22px;
1482+
content: var(--clipboard-image);
14941483
}
14951484
.example-wrap .button-holder .copy-button:hover::before {
14961485
filter: var(--copy-path-img-hover-filter);
14971486
}
14981487
.example-wrap .button-holder .copy-button.clicked::before {
14991488
content: var(--checkmark-image);
1489+
padding-right: 5px;
15001490
}
15011491

15021492
.code-attribute {
@@ -1745,8 +1735,8 @@ a.tooltip:hover::after {
17451735
#copy-path {
17461736
color: var(--copy-path-button-color);
17471737
background: var(--main-background-color);
1748-
height: 34px;
1749-
width: 33px;
1738+
height: var(--copy-path-height);
1739+
width: var(--copy-path-width);
17501740
margin-left: 10px;
17511741
padding: 0;
17521742
padding-left: 2px;
@@ -1756,8 +1746,6 @@ a.tooltip:hover::after {
17561746
#copy-path::before {
17571747
filter: var(--copy-path-img-filter);
17581748
content: var(--clipboard-image);
1759-
width: 19px;
1760-
height: 18px;
17611749
}
17621750
#copy-path:hover::before {
17631751
filter: var(--copy-path-img-hover-filter);

tests/rustdoc-gui/copy-code.goml

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ define-function: (
1414
assert-css: (".example-wrap .copy-button", { "visibility": "visible" })
1515
move-cursor-to: ".search-input"
1616
assert-css: (".example-wrap .copy-button", { "visibility": "hidden" })
17+
// Checking that the copy button has the same size as the "copy path" button.
18+
compare-elements-size: (
19+
"#copy-path",
20+
".example-wrap:nth-of-type(1) .copy-button",
21+
["height", "width"],
22+
)
1723
},
1824
)
1925

tests/rustdoc-gui/run-on-hover.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ define-function: (
1717
"visibility": "visible",
1818
"color": |color|,
1919
"background-color": |background|,
20-
"font-size": "22px",
20+
"font-size": "16px",
2121
"border-radius": "5px",
2222
})
2323
move-cursor-to: ".test-arrow"
2424
assert-css: (".test-arrow:hover", {
2525
"visibility": "visible",
2626
"color": |hover_color|,
2727
"background-color": |hover_background|,
28-
"font-size": "22px",
28+
"font-size": "16px",
2929
"border-radius": "5px",
3030
})
3131
},

0 commit comments

Comments
 (0)