Skip to content

Commit 77b1556

Browse files
Make "copy code" button the same size as the "copy path" button
1 parent 228d528 commit 77b1556

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

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

+11-23
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,8 @@ xmlns="http://www.w3.org/2000/svg" aria-label="Copy to clipboard">\
2424
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"/>\
2525
<path d="M4 19h6v2H4zM12 11H4v2h8zM4 17h4v-2H4zM15 15v-3l-4.5 4.5L15 21v-3l8.027-.032L23 15z"/>\
2626
</svg>');
27-
--clipboard-image-big: url('data:image/svg+xml,<svg width="22" height="23" viewBox="0 0 24 25" \
28-
xmlns="http://www.w3.org/2000/svg" aria-label="Copy to clipboard">\
29-
<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 \
30-
0110 0a3.323 3.323 0 013.333 3.333h5C19.245 3.333 20 4.09 20 5v8.333h-2V9H2v14h16v-3zM3 \
31-
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 \
32-
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"/>\
33-
<path d="M4 19h6v2H4zM12 11H4v2h8zM4 17h4v-2H4zM15 15v-3l-4.5 4.5L15 21v-3l8.027-.032L23 15z"/>\
34-
</svg>');
27+
--copy-path-height: 34px;
28+
--copy-path-width: 33px;
3529
/* Checkmark <https://www.svgrepo.com/svg/335033/checkmark> */
3630
--checkmark-image: url('data:image/svg+xml,<svg viewBox="-1 -1 23 23" \
3731
xmlns="http://www.w3.org/2000/svg" fill="black" height="18px">\
@@ -1406,9 +1400,9 @@ documentation. */
14061400
z-index: 1;
14071401
}
14081402
a.test-arrow {
1409-
padding: 5px 10px 5px 10px;
1403+
padding: 5px 7px;
14101404
border-radius: 5px;
1411-
font-size: 1.375rem;
1405+
font-size: 1rem;
14121406
color: var(--test-arrow-color);
14131407
background-color: var(--test-arrow-background-color);
14141408
}
@@ -1420,36 +1414,32 @@ a.test-arrow:hover {
14201414
display: flex;
14211415
}
14221416
.example-wrap:hover > .test-arrow {
1423-
padding: 3px 10px;
1417+
padding: 2px 7px;
14241418
}
14251419
.example-wrap:hover > .test-arrow, .example-wrap:hover > .button-holder {
14261420
visibility: visible;
14271421
}
14281422
.example-wrap .button-holder .copy-button {
14291423
color: var(--copy-path-button-color);
14301424
background: var(--main-background-color);
1431-
height: 43px;
1432-
width: 40px;
1425+
height: var(--copy-path-height);
1426+
width: var(--copy-path-width);
14331427
margin-left: 5px;
14341428
padding: 2px 0 0 4px;
14351429
border: 0;
14361430
cursor: pointer;
14371431
border-radius: 5px;
14381432
}
1439-
.example-wrap .button-holder .copy-button.clicked {
1440-
padding-top: 4px;
1441-
}
14421433
.example-wrap .button-holder .copy-button::before {
14431434
filter: var(--copy-path-img-filter);
1444-
content: var(--clipboard-image-big);
1445-
width: 23px;
1446-
height: 22px;
1435+
content: var(--clipboard-image);
14471436
}
14481437
.example-wrap .button-holder .copy-button:hover::before {
14491438
filter: var(--copy-path-img-hover-filter);
14501439
}
14511440
.example-wrap .button-holder .copy-button.clicked::before {
14521441
content: var(--checkmark-image);
1442+
padding-right: 5px;
14531443
}
14541444

14551445
.code-attribute {
@@ -1698,8 +1688,8 @@ a.tooltip:hover::after {
16981688
#copy-path {
16991689
color: var(--copy-path-button-color);
17001690
background: var(--main-background-color);
1701-
height: 34px;
1702-
width: 33px;
1691+
height: var(--copy-path-height);
1692+
width: var(--copy-path-width);
17031693
margin-left: 10px;
17041694
padding: 0;
17051695
padding-left: 2px;
@@ -1709,8 +1699,6 @@ a.tooltip:hover::after {
17091699
#copy-path::before {
17101700
filter: var(--copy-path-img-filter);
17111701
content: var(--clipboard-image);
1712-
width: 19px;
1713-
height: 18px;
17141702
}
17151703
#copy-path:hover::before {
17161704
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

0 commit comments

Comments
 (0)