-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #128339 - GuillaumeGomez:click-code-example, r=notriddle
[rustdoc] Make the buttons remain when code example is clicked Follow-up of #125779. One current issue we have with "run" button and the newly added copy code button is that if you're on mobile devices, you can't use them. I took a look at how `mdbook` is handling it and when you click on a code example, they show the buttons. I think it's a really good idea as if you want to copy the code on your mobile device, you will click on it, showing the buttons. Feature can be tested [here](https://rustdoc.crud.net/imperio/click-code-example/foo/struct.Bar.html). r? `@notriddle`
- Loading branch information
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// This test ensures that code blocks buttons are displayed on hover and when you click on them. | ||
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" | ||
|
||
// First we check we "hover". | ||
move-cursor-to: ".example-wrap" | ||
assert-css: (".example-wrap .copy-button", { "visibility": "visible" }) | ||
move-cursor-to: ".search-input" | ||
assert-css: (".example-wrap .copy-button", { "visibility": "hidden" }) | ||
|
||
// Now we check the click. | ||
assert-count: (".example-wrap:not(:hover) .button-holder.keep-visible", 0) | ||
click: ".example-wrap" | ||
move-cursor-to: ".search-input" | ||
// It should have a new class and be visible. | ||
wait-for-count: (".example-wrap:not(:hover) .button-holder.keep-visible", 1) | ||
wait-for-css: (".example-wrap:not(:hover) .button-holder.keep-visible", { "visibility": "visible" }) | ||
// Clicking again will remove the class. | ||
click: ".example-wrap" | ||
move-cursor-to: ".search-input" | ||
assert-count: (".example-wrap:not(:hover) .button-holder.keep-visible", 0) | ||
assert-css: (".example-wrap .copy-button", { "visibility": "hidden" }) |