Skip to content
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

rustdoc: Fix badge alignment #105509

Closed
Closed
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
3 changes: 3 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,9 @@ table,
.item-left {
padding-right: 1.25rem;
}
.item-left > a, .item-left > span {
vertical-align: middle;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use "middle" or "baseline"? It seems like the latter would work better given that the fonts may be somewhat different.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. They're guaranteed to be different, because Fira Sans is used for the link, while Source Code Serif is used for the badge.

  2. Not a fan of wildcard selectors. It's too tricky to figure out what they're actually supposed to target.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Middle:

Screenshot from 2022-12-10 18-22-10

Baseline:

image

I tend to prefer the "middle" alignment because "baseline" renders weirdly since even though they share the same baseline, they don't have the same height, making it a bit weird for the eye (imo). For "middle", they are vertically aligned which I find more pleasant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well in short, I have a preference for the "middle" alignment but don't have a strong opinion about it so as is preferred.

@notriddle: I updated the selector to make it more specific.

}

.search-results-title {
margin-top: 0;
Expand Down
15 changes: 15 additions & 0 deletions src/test/rustdoc-gui/stab-badge.goml
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
// All stability badges should have rounded corners and colored backgrounds.
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
show-text: true

// Checking the alignment of the badges text with the item name.
assert-css: (
"//*[@class='item-table']//*[@class='item-left module-item']/*[@class='stab deprecated']",
{"padding-top": "2px"},
)
assert-position: (
"//*[@class='item-table']//*[@class='item-left module-item']/*[@class='stab deprecated']",
{"y": 1892},
)
assert-position: (
"//*[@class='item-table']//*[@class='item-left module-item']/*[@class='stab deprecated']/preceding-sibling::a",
{"y": 1894}, // 1892 + 2 because of padding
)

define-function: (
"check-badge",
(theme, background, color),
Expand Down