Skip to content

rustdoc: clean up .logo-container layout CSS #103990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ img {
overflow: visible;
}

.sub-logo-container {
.sub-logo-container, .logo-container {
/* zero text boxes so that computed line height = image height exactly */
line-height: 0;
}

Expand Down Expand Up @@ -465,10 +466,9 @@ img {
}

.sidebar .logo-container {
display: flex;
margin-top: 10px;
margin-bottom: 10px;
justify-content: center;
text-align: center;
}

.version {
Expand Down Expand Up @@ -1762,10 +1762,6 @@ in storage.js
white-space: nowrap;
}

.mobile-topbar .logo-container {
max-height: 45px;
}

.mobile-topbar .logo-container > img {
max-width: 35px;
max-height: 35px;
Expand Down
21 changes: 21 additions & 0 deletions src/test/rustdoc-gui/huge-logo.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// huge_logo crate has a custom 712x860 logo
// test to ensure the maximum size in the layout works correctly
goto: "file://" + |DOC_PATH| + "/huge_logo/index.html"

size: (1280, 1024)
// offsetWidth = width of sidebar
assert-property: (".sidebar .logo-container", {"offsetWidth": "200", "offsetHeight": 100})
assert-property: (".sidebar .logo-container img", {"offsetWidth": "100", "offsetHeight": 100})

size: (400, 600)
// offset = size + margin
assert-property: (".mobile-topbar .logo-container", {"offsetWidth": "55", "offsetHeight": 45})
assert-property: (".mobile-topbar .logo-container img", {"offsetWidth": "35", "offsetHeight": 35})

goto: "file://" + |DOC_PATH| + "/src/huge_logo/lib.rs.html"

size: (1280, 1024)
assert-property: (".sub-logo-container", {"offsetWidth": "60", "offsetHeight": 60})

size: (400, 600)
assert-property: (".sub-logo-container", {"offsetWidth": "35", "offsetHeight": 35})
2 changes: 2 additions & 0 deletions src/test/rustdoc-gui/search-filter.goml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ click: "#crate-search"
// We select "lib2" option then press enter to change the filter.
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#titles"
Expand All @@ -37,6 +38,7 @@ assert-property: ("#crate-search", {"value": "lib2"})
click: "#crate-search"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#titles"
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/sidebar-source-code.goml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
// Only "another_folder" should be "open" in "lib2".
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
// All other trees should be collapsed.
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 5)
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 6)

// We now switch to mobile mode.
size: (600, 600)
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/source-code-page.goml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ assert: ".source-sidebar-expanded"

// We check that the first entry of the sidebar is collapsed
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
assert-text: ("#source-sidebar details:first-of-type > summary", "implementors")
assert-text: ("#source-sidebar details:first-of-type > summary", "huge_logo")
// We now click on it.
click: "#source-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})
Expand Down
7 changes: 7 additions & 0 deletions src/test/rustdoc-gui/src/huge_logo/Cargo.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "huge_logo"
version = "0.1.0"
8 changes: 8 additions & 0 deletions src/test/rustdoc-gui/src/huge_logo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "huge_logo"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
17 changes: 17 additions & 0 deletions src/test/rustdoc-gui/src/huge_logo/src/lib.rs

Large diffs are not rendered by default.