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: Align search results horizontally for easy scanning #112937

Merged
merged 5 commits into from
Jun 25, 2023
Merged
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,10 @@ so that we can apply CSS-filters to change the arrow color in themes */
color: var(--search-results-grey-color);
}
.search-results .result-name .typename {
display: inline-block;
color: var(--search-results-grey-color);
font-size: 0.875rem;
width: 6rem;
Copy link
Member Author

Choose a reason for hiding this comment

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

I picked this number arbitrarily. Two issues:

  1. It would be nice if it weren't based on eyeballing the layout.

  2. This isn't actually wide enough for "associated constant". If I increase this to 9em, it fits, but then all the other rows have excessive spacing. I see two solutions: one is to shorten the typename to just "constant", the other is to make the spacing somehow adaptive to what the longest typename is. But I'm not sure how to implement that.

Copy link
Member

Choose a reason for hiding this comment

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

What happens when it overflows? Does it wrap and just become a taller row? I think that honestly wouldn't be terrible if that's what happens.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not terrible, but still looks bad IMO:

image

Copy link
Member

Choose a reason for hiding this comment

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

:/ true -- i wonder if vertically center-aligning those rows would help.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we really need to just keep rows a constant height. Variable height rows almost always look a bit off.

Copy link
Member

Choose a reason for hiding this comment

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

Something that could at least make them look better is to make sure both the path/name and short description are aligned the same, to the top or the middle as Michael suggested.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was able to avoid the wrapping by adding a tiny bit extra space.

}

.popover {
Expand Down