Unify run button display with "copy code" button and with mdbook buttons

This commit is contained in:
Guillaume Gomez 2024-07-30 15:23:44 +02:00
parent 29e924841f
commit a282e520b2
3 changed files with 23 additions and 42 deletions

View File

@ -304,7 +304,8 @@ fn next(&mut self) -> Option<Self::Item> {
Some(format!( Some(format!(
"<a class=\"test-arrow\" \ "<a class=\"test-arrow\" \
target=\"_blank\" \ target=\"_blank\" \
href=\"{url}?code={test_escaped}{channel}&amp;edition={edition}\">Run</a>", title=\"Run code\" \
href=\"{url}?code={test_escaped}{channel}&amp;edition={edition}\"></a>",
)) ))
}); });

View File

@ -104,10 +104,6 @@ nav.sub {
--code-highlight-doc-comment-color: #4d4d4c; --code-highlight-doc-comment-color: #4d4d4c;
--src-line-numbers-span-color: #c67e2d; --src-line-numbers-span-color: #c67e2d;
--src-line-number-highlighted-background-color: #fdffd3; --src-line-number-highlighted-background-color: #fdffd3;
--test-arrow-color: #f5f5f5;
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
--test-arrow-hover-color: #f5f5f5;
--test-arrow-hover-background-color: rgb(78, 139, 202);
--target-background-color: #fdffd3; --target-background-color: #fdffd3;
--target-border-color: #ad7c37; --target-border-color: #ad7c37;
--kbd-color: #000; --kbd-color: #000;
@ -210,10 +206,6 @@ nav.sub {
--code-highlight-doc-comment-color: #8ca375; --code-highlight-doc-comment-color: #8ca375;
--src-line-numbers-span-color: #3b91e2; --src-line-numbers-span-color: #3b91e2;
--src-line-number-highlighted-background-color: #0a042f; --src-line-number-highlighted-background-color: #0a042f;
--test-arrow-color: #dedede;
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
--test-arrow-hover-color: #dedede;
--test-arrow-hover-background-color: #4e8bca;
--target-background-color: #494a3d; --target-background-color: #494a3d;
--target-border-color: #bb7410; --target-border-color: #bb7410;
--kbd-color: #000; --kbd-color: #000;

View File

@ -353,7 +353,7 @@ details:not(.toggle) summary {
margin-bottom: .6em; margin-bottom: .6em;
} }
code, pre, a.test-arrow, .code-header { code, pre, .code-header {
font-family: "Source Code Pro", monospace; font-family: "Source Code Pro", monospace;
} }
.docblock code, .docblock-short code { .docblock code, .docblock-short code {
@ -946,8 +946,8 @@ because of the `[-]` element which would overlap with it. */
.main-heading a:hover, .main-heading a:hover,
.example-wrap .rust a:hover, .example-wrap .rust a:hover,
.all-items a:hover, .all-items a:hover,
.docblock a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover:not(.doc-anchor), .docblock a:not(.scrape-help):not(.tooltip):hover:not(.doc-anchor),
.docblock-short a:not(.test-arrow):not(.scrape-help):not(.tooltip):hover, .docblock-short a:not(.scrape-help):not(.tooltip):hover,
.item-info a { .item-info a {
text-decoration: underline; text-decoration: underline;
} }
@ -1461,22 +1461,17 @@ documentation. */
z-index: 1; z-index: 1;
} }
a.test-arrow { a.test-arrow {
padding: 5px 7px; height: var(--copy-path-height);
border-radius: var(--button-border-radius); padding: 6px 4px 0 11px;
font-size: 1rem;
color: var(--test-arrow-color);
background-color: var(--test-arrow-background-color);
} }
a.test-arrow:hover { a.test-arrow::before {
color: var(--test-arrow-hover-color); content: url('data:image/svg+xml,<svg viewBox="0 0 20 20" width="18" height="20" \
background-color: var(--test-arrow-hover-background-color); xmlns="http://www.w3.org/2000/svg"><path d="M0 0l18 10-18 10z"/></svg>');
} }
.example-wrap .button-holder { .example-wrap .button-holder {
display: flex; display: flex;
} }
.example-wrap:hover > .test-arrow {
padding: 2px 7px;
}
/* /*
On iPad, the ":hover" state sticks around, making things work not greatly. Do work around On iPad, the ":hover" state sticks around, making things work not greatly. Do work around
it, we move it into this media query. More information can be found at: 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
instead, we check that it's not a "finger" cursor. instead, we check that it's not a "finger" cursor.
*/ */
@media not (pointer: coarse) { @media not (pointer: coarse) {
.example-wrap:hover > .test-arrow, .example-wrap:hover > .button-holder { .example-wrap:hover > a.test-arrow, .example-wrap:hover > .button-holder {
visibility: visible; visibility: visible;
} }
} }
.example-wrap .button-holder.keep-visible { .example-wrap .button-holder.keep-visible {
visibility: visible; visibility: visible;
} }
.example-wrap .button-holder .copy-button { .example-wrap .button-holder .copy-button, .example-wrap .test-arrow {
color: var(--copy-path-button-color);
background: var(--main-background-color); background: var(--main-background-color);
cursor: pointer;
border-radius: var(--button-border-radius);
height: var(--copy-path-height); height: var(--copy-path-height);
width: var(--copy-path-width); width: var(--copy-path-width);
}
.example-wrap .button-holder .copy-button {
margin-left: var(--button-left-margin); margin-left: var(--button-left-margin);
padding: 2px 0 0 4px; padding: 2px 0 0 4px;
border: 0; border: 0;
cursor: pointer; }
border-radius: var(--button-border-radius); .example-wrap .button-holder .copy-button::before,
.example-wrap .test-arrow::before {
filter: var(--copy-path-img-filter);
} }
.example-wrap .button-holder .copy-button::before { .example-wrap .button-holder .copy-button::before {
filter: var(--copy-path-img-filter);
content: var(--clipboard-image); content: var(--clipboard-image);
} }
.example-wrap .button-holder .copy-button:hover::before { .example-wrap .button-holder .copy-button:hover::before,
.example-wrap .test-arrow:hover::before {
filter: var(--copy-path-img-hover-filter); filter: var(--copy-path-img-hover-filter);
} }
.example-wrap .button-holder .copy-button.clicked::before { .example-wrap .button-holder .copy-button.clicked::before {
@ -2552,10 +2552,6 @@ by default.
--code-highlight-doc-comment-color: #4d4d4c; --code-highlight-doc-comment-color: #4d4d4c;
--src-line-numbers-span-color: #c67e2d; --src-line-numbers-span-color: #c67e2d;
--src-line-number-highlighted-background-color: #fdffd3; --src-line-number-highlighted-background-color: #fdffd3;
--test-arrow-color: #f5f5f5;
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
--test-arrow-hover-color: #f5f5f5;
--test-arrow-hover-background-color: rgb(78, 139, 202);
--target-background-color: #fdffd3; --target-background-color: #fdffd3;
--target-border-color: #ad7c37; --target-border-color: #ad7c37;
--kbd-color: #000; --kbd-color: #000;
@ -2658,10 +2654,6 @@ by default.
--code-highlight-doc-comment-color: #8ca375; --code-highlight-doc-comment-color: #8ca375;
--src-line-numbers-span-color: #3b91e2; --src-line-numbers-span-color: #3b91e2;
--src-line-number-highlighted-background-color: #0a042f; --src-line-number-highlighted-background-color: #0a042f;
--test-arrow-color: #dedede;
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
--test-arrow-hover-color: #dedede;
--test-arrow-hover-background-color: #4e8bca;
--target-background-color: #494a3d; --target-background-color: #494a3d;
--target-border-color: #bb7410; --target-border-color: #bb7410;
--kbd-color: #000; --kbd-color: #000;
@ -2771,10 +2763,6 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--code-highlight-doc-comment-color: #a1ac88; --code-highlight-doc-comment-color: #a1ac88;
--src-line-numbers-span-color: #5c6773; --src-line-numbers-span-color: #5c6773;
--src-line-number-highlighted-background-color: rgba(255, 236, 164, 0.06); --src-line-number-highlighted-background-color: rgba(255, 236, 164, 0.06);
--test-arrow-color: #788797;
--test-arrow-background-color: rgba(57, 175, 215, 0.09);
--test-arrow-hover-color: #c5c5c5;
--test-arrow-hover-background-color: rgba(57, 175, 215, 0.368);
--target-background-color: rgba(255, 236, 164, 0.06); --target-background-color: rgba(255, 236, 164, 0.06);
--target-border-color: rgba(255, 180, 76, 0.85); --target-border-color: rgba(255, 180, 76, 0.85);
--kbd-color: #c5c5c5; --kbd-color: #c5c5c5;