Skip to content

Commit

Permalink
Rollup merge of #131417 - GuillaumeGomez:mobile-methods-left-margin, …
Browse files Browse the repository at this point in the history
…r=notriddle

Fix methods alignment on mobile

I realized that on mobile, the methods are not aligned the same depending if they have documentation or not:

| before | after |
|-|-|
| ![Screenshot from 2024-10-08 20-40-22](https://github.com/user-attachments/assets/d31ba5e1-cf84-431f-9b2b-9962bc5a0365) | ![image](https://github.com/user-attachments/assets/ffde2161-bfcb-4462-8c5b-88538e61b366) |

r? `@notriddle`
  • Loading branch information
matthiaskrgr authored Oct 9, 2024
2 parents 50f7e80 + 5e6033e commit 47344c3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,7 @@ in src-script.js and main.js
}

/* Position of the "[-]" element. */
details.toggle:not(.top-doc) > summary {
details.toggle:not(.top-doc) > summary, .impl-items > section {
margin-left: 10px;
}
.impl-items > details.toggle > summary:not(.hideme)::before,
Expand Down
19 changes: 19 additions & 0 deletions tests/rustdoc-gui/methods-left-margin.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This test is to ensure that methods are correctly aligned on the left side.

go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"

// First we ensure that we have methods with and without documentation.
assert: ".impl-items > details.method-toggle > summary > section.method"
assert: ".impl-items > section.method"

// Checking on desktop.
set-window-size: (900, 600)
wait-for-size: ("body", {"width": 900})
store-position: (".impl-items section.method", {"x": x})
assert-position: (".impl-items section.method", {"x": |x|}, ALL)

// Checking on mobile.
set-window-size: (600, 600)
wait-for-size: ("body", {"width": 600})
store-position: (".impl-items section.method", {"x": x})
assert-position: (".impl-items section.method", {"x": |x|}, ALL)
5 changes: 3 additions & 2 deletions tests/rustdoc-gui/notable-trait.goml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ call-function: ("check-notable-tooltip-position", {

// Checking on mobile now.
set-window-size: (650, 600)
wait-for-size: ("body", {"width": 650})
call-function: ("check-notable-tooltip-position-complete", {
"x": 15,
"i_x": 293,
"x": 25,
"i_x": 303,
"popover_x": 0,
})

Expand Down

0 comments on commit 47344c3

Please sign in to comment.