Fix wrong padding for expanded scraped example

This commit is contained in:
Guillaume Gomez 2024-09-03 00:42:13 +02:00
parent e3af6dc239
commit 55bc638a1d
3 changed files with 28 additions and 2 deletions

View File

@ -789,11 +789,18 @@ both the code example and the line numbers, so we need to remove the radius in t
}
.rustdoc:not(.src) .scraped-example:not(.expanded) .src-line-numbers,
.rustdoc:not(.src) .scraped-example:not(.expanded) .src-line-numbers > pre,
.rustdoc:not(.src) .scraped-example:not(.expanded) pre.rust {
padding-bottom: 0;
/* See above comment, should be the same max-height. */
overflow: auto hidden;
}
.rustdoc:not(.src) .scraped-example .src-line-numbers {
padding-top: 0;
}
.rustdoc:not(.src) .scraped-example.expanded .src-line-numbers {
padding-bottom: 0;
}
.rustdoc:not(.src) .example-wrap pre {
overflow: auto;

View File

@ -29,10 +29,10 @@ assert-property: (".scraped-example-list > .scraped-example .rust", {
// The expand button increases the scrollHeight of the minimized code viewport
store-property: (".scraped-example-list > .scraped-example pre", {"offsetHeight": smallOffsetHeight})
assert-property-false: (".scraped-example-list > .scraped-example .src-line-numbers", {
assert-property: (".scraped-example-list > .scraped-example .src-line-numbers", {
"scrollHeight": |smallOffsetHeight|
}, NEAR)
assert-property-false: (".scraped-example-list > .scraped-example .rust", {
assert-property: (".scraped-example-list > .scraped-example .rust", {
"scrollHeight": |smallOffsetHeight|
}, NEAR)
focus: ".scraped-example-list > .scraped-example .expand"

View File

@ -47,6 +47,25 @@ assert-position: (".scraped-example .scraped-example-title", {
"y": |y| + |height| - |title_height| - 8,
})
// Check that the expand button works and also that line number aligns with code.
move-cursor-to: ".scraped-example .rust"
click: ".scraped-example .button-holder .expand"
wait-for: ".scraped-example.expanded"
// They should have the same y position.
compare-elements-position: (
".scraped-example.expanded .src-line-numbers pre span",
".scraped-example.expanded .rust code",
["y"],
)
// And they should have the same height.
compare-elements-size: (
".scraped-example.expanded .src-line-numbers",
".scraped-example.expanded .rust",
["height"],
)
// Collapse code again.
click: ".scraped-example .button-holder .expand"
// Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed
// correctly.