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

Improve crate selection on rustdoc search results page #98855

Conversation

steffahn
Copy link
Member

@steffahn steffahn commented Jul 3, 2022

Improves some problems pointed out in #93240.

In particular the in being serif-font makes sense once this is in a new line, and the font-size is better so the dropdown menu isn’t this huge anymore. This also addresses my concern that the selection moves around horizontally as the search term changes.

The formatting for the #search-settings CSS is not necessary for the title, because h1 has the same CSS, too, anyways.

Currently on nightly:
Screenshot_20220703_200911
Screenshot_20220703_200924

After this PR: (outdated, see below)
Screenshot_20220703_201333

Screenshot_20220703_200829


With my latest changes added, I'd say this PR can close #93240 entirely. See #98855 (comment) below to see renderings of the current status.

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 3, 2022
@rustbot
Copy link
Collaborator

rustbot commented Jul 3, 2022

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @Folyd, @jsha

@rust-highfive
Copy link
Collaborator

r? @jsha

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 3, 2022
@steffahn steffahn force-pushed the improve_rustdoc_search_results_page_crates_selection branch 2 times, most recently from 6a8b87f to 7e24601 Compare July 3, 2022 19:17
@GuillaumeGomez
Copy link
Member

I uploaded an online version of this change here. I'm personally not a big fan of putting the "in X" part in its own line but let's see what others think about it.

cc @jsha @Manishearth

@steffahn
Copy link
Member Author

steffahn commented Jul 5, 2022

The thing you uploaded only has a single crate, so the list doesn’t show up in the first place. It did however remind me that in that case, the <br/> probably shouldn’t appear in the HTML (even though it doesn’t appear to get rendered as a new line anyway), so after re-inspecting the logic in the JS, I’ve moved the line break into the crates variable to make it conditional like that.

@steffahn steffahn force-pushed the improve_rustdoc_search_results_page_crates_selection branch from 7e24601 to 2a19120 Compare July 5, 2022 09:40
@GuillaumeGomez
Copy link
Member

Didn't even pay attention to that, sorry. Fixed it.

@jsha
Copy link
Contributor

jsha commented Jul 6, 2022

I agree with @GuillaumeGomez that we shouldn't use a second line of vertical space. @steffahn you commented in #93240 that you are indifferent to whether the results page echoes the search query. I think that might be a better solution than using a second line; let's remove the "for search_term" part. Then the dropdown can be on the same line but not move around as you edit your search.

@steffahn
Copy link
Member Author

steffahn commented Jul 6, 2022

Okay, keeping it in the title and removing the search term; making the in part of the title font (but not the selection, that looks weird in bold). I would still like to keep the selection dropdown smaller, if that’s stylistically acceptable. So how about something like this for a look? (I just manually edited this in the browser so far, not implemented it yet into the source files.)

Screenshot_20220706_192234

With a single crate, the thing would just say Results.

@steffahn
Copy link
Member Author

steffahn commented Jul 6, 2022

On second thought, in e.g. the white theme where the dropdown is lower-contrast, keeping matching fonts seems kind-of essential actually. Compare:

Screenshot_20220706_193911

Screenshot_20220706_193924

the second looks better IMO.

@steffahn
Copy link
Member Author

steffahn commented Jul 6, 2022

theme where the dropdown is lower-contrast

Makes me reconsider perhaps also addressing the other point I made in #93240 here, the high contrast in the dark theme currently. Is there any other dropdown-selections in rustdoc that should be taken into consideration for consistency?


I’m also noticing that “all crates” is probably more sensible than “All crates” in this position.

@steffahn
Copy link
Member Author

steffahn commented Jul 6, 2022

I added an implementation of a style along those lines, i.e. as explained in my previous two comments.

Screenshot_20220707_003120
Screenshot_20220707_003155
Screenshot_20220707_003229

Small font size in dropdown:
Screenshot_20220707_003414

As you might be able to tell by looking into the CSS, I had a hard time adapting the color of that arrow to the field; I’m open for suggestions for cleaner approaches if an inline svg like this is not acceptable.

@rustbot
Copy link
Collaborator

rustbot commented Jul 6, 2022

A change occurred in the Ayu theme.

cc @Cldfire

Some changes occurred in HTML/CSS themes.

cc @GuillaumeGomez

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@steffahn steffahn force-pushed the improve_rustdoc_search_results_page_crates_selection branch from d5c0b07 to 0f6a9c9 Compare July 7, 2022 00:03
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member

Just realized that if you don't need to use background-image in all themes, we already have it in rustdoc.css.

@notriddle
Copy link
Contributor

notriddle commented Jul 8, 2022

Potential extreme alternative: use the sidebar?

image

(just a mockup)

@GuillaumeGomez
Copy link
Member

That seems very weird to switch the "focus" from the main content to the sidebar, no?

@steffahn
Copy link
Member Author

steffahn commented Jul 8, 2022

I have yet to find out why the thing has so much more visual padding in the <select> on Firefox than Chrome, and how to avoid this. (I prefer the way it looks on Chrome / that’s what I looked at when changing/choosing the padding in the first place.)

Chrome
Screenshot_20220709_000525

Firefox
Screenshot_20220709_000546

If anyone has an idea, feel free to share it.

@rust-log-analyzer

This comment has been minimized.

@steffahn
Copy link
Member Author

steffahn commented Jul 9, 2022

Some screenshots of the hover effects I’ve added yesterday:
Screenshot_20220709_094014
Screenshot_20220709_094209
Screenshot_20220709_094105
Screenshot_20220709_094142
Screenshot_20220709_093903
Screenshot_20220709_094236

For light and ayu, colors of outline (both with and without focus, respectively) are the same as the settings and help button; the border color without focus is also the same as the outline of the settings menu on all themes, so that’s how I chose the outline color for the dark theme; the blue hover color of the dark theme is the same as the hover color for the radio buttons and the activate switches in the settings menu, admitted there are a lot of slightly different shades of blue, i.e. the searchbar highlight above (if it’s focused) is a different blue, and the active tab below (“In Names”/“In Parameters”/“In Return Types”) has yet-another shade of blue.

@steffahn
Copy link
Member Author

steffahn commented Jul 11, 2022

I’ve disabled the abovementioned failing (still rather new) tests for now1; if it’s okay to have them only come back in a future PR, then this PR should be ready to be reviewed and merged from my end, provided CI passes now 🚀

Footnotes

  1. see the collapsed rust-log-analyzer comment above this one to see the error message it was producing

Resolves all of issue rust-lang#93240

Reproduces a similar change as rust-lang#99086, but with improvements

In particular, this PR inlcludes:
* redesigning the crate-search selector so the background color matches its surroundings
* decrease the font of the dropdown menu to a reaonable size
* add a hover effect
* make the color of the arrow theme-dependent, using a surrounding div, with :after pseudo-element
  that can then be transformed using CSS filters to approximate the desired color
* fix the text "in" to match the title font
* remove the "for xyz" in the "Results for xyz in [All crates]" title when
  searching for search term "xyz"; you can already see what you're searching for
  as it's typed in the search bar!
* in line with rust-lang#99086, handle super-long crate names appropriately without a long <select>
  element escaping the screen area; the improvement is that we also keep the title
  within a single line now; uses some flex layout shenanigans...
* the margins / paddings are adjusted so the selected label of the <select> fits within
  the rest of that title nicely; also some inconsistency in the way that Firefox renders
  a <select> with "appearance: none" (roughly 4px more padding left and right of the text
  than e.g. Chrome) is worked around, and it now produces a result that looks (essentially)
  identical to Chrome
* the color of the help menu and settings menu border in light theme is made to match with
  the color of the corresponding buttons, like they do (match) in the ayu theme
* the casing of "All crates" changes to "all crates"
* the new tests from rust-lang#99086 are temporarily disabled, until they can be adapted later
@steffahn steffahn force-pushed the improve_rustdoc_search_results_page_crates_selection branch from 45bc004 to ac20976 Compare July 11, 2022 00:57
@@ -934,14 +949,35 @@ table,
-webkit-appearance: none;
/* Removes default arrow from firefox */
text-indent: 0.01px;
text-overflow: "";
}
/* cancel stylistic differences in padding
Copy link
Member

Choose a reason for hiding this comment

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

When does it happen? We don't use appearance: none ourselves after all.

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 effectively are, kind-of… I guess… at least with appearance: none it looks the same, IDK about backwards-compatibility with older versions of Firefox where it might’ve been different..?

In any case, what this is supposed to say is that Firefox has some (empirically, 4px) padding in an "unstyled" (i.e. when the native arrow is removed) that Chrome doesn't have. I don't have any other browsers myself ATM to test / compare. Admitted, given that appearance: none is not literally what’s used here, the comment could be clarified.

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 changed the wording a bit now.

I’m not sure about the pros and cons of using the “actual” appearance: none property, I haven’t researched too much what distinguishes this property from those -moz-appearance / -webkit-appearance ones; consequently I kept everything as-is with regards to these properties, just to be safe, e.g. since I haven’t tested other browsers, etc…

"#search-settings .search-results-title",
{"y": 5},
)
// FIXME: Fix and re-enable these tests!
Copy link
Member

Choose a reason for hiding this comment

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

So about the goml format. It's something I wrote to make it easy to write/read. You can see more information about it (with the full list of commands) here.

@GuillaumeGomez
Copy link
Member

We can take a look at the goml tests at the end if you're still stuck. Not really the hard part normally. ;)

Fix oversight duplicate property left in CSS (dark theme).

Improve wording in comment that mentions `appearance: none`
@steffahn steffahn force-pushed the improve_rustdoc_search_results_page_crates_selection branch from 64530d7 to 8b190b4 Compare July 11, 2022 19:55
@steffahn
Copy link
Member Author

We can take a look at the goml tests at the end if you're still stuck. Not really the hard part normally. ;)

Well for one thing, I’d need to get those tests running locally in the first place, otherwise it’s impossible to work with.

It just gives me a completely cryptic error message

Running 66 rustdoc-gui (8 concurrently) ...
ERROR: puppeteer failed when trying to create a new page. Please try again with `--no-sandbox`

I’m also noticing this warning on the npm install browser-ui-test:

npm WARN deprecated puppeteer@3.3.0: Version no longer supported. Upgrade to @latest

I have no idea if that’s related to the problem and if yes how to fix it.

@GuillaumeGomez
Copy link
Member

Ah I see, like that:

x.py test src/test/rustdoc-gui --test-args --no-sandbox

Normally you have the explanations in src/test/rustdoc-gui/README.md. :)

@steffahn
Copy link
Member Author

steffahn commented Jul 11, 2022

W.r.t. rewriting/adapting the tests, they currently (judging by the comments) seem to work with the implicit assumption that the <select> lives in its own line and just test for its size. What’s actually interesting is presumably that its right-hand-side border is positioned within-bounds of, say, the search section, I have no idea how one would write this.

I also don’t know what this compare-elements-position-near-stuff means or what the error message talking about "#search-settings .search-results-title" means, in particular what the "#search-settings .search-results-title" syntax itself means. Looks like two CSS selectors separated by space; IDK how those compose.


In terms of tests, one could perhaps also want to test that #crate-search and #crate-search-div are always (i.e. both in normal cases and when the contents are too long) exactly on top of each other and the same size (or plus one pixel in all directions for the border, I’d have to check that…), so that the dropdown arrow appears in the right position.

@steffahn
Copy link
Member Author

Ah I see, like that:

x.py test src/test/rustdoc-gui --test-args --no-sandbox

Normally you have the explanations in src/test/rustdoc-gui/README.md. :)

Ah, that works… but it gives an unrelated failure of a test that doesn’t appear to fail in CI

/home/frank/forks/rust/src/test/rustdoc-gui/type-declation-overflow.goml type-declation-overflow... FAILED
[ERROR] (line 35) Error: Evaluation failed: property `scrollWidth` (`491`) isn't equal to `492` for selector `.mobile-topbar .location`: for command `assert-property: (".mobile-topbar .location", {"scrollWidth": "492"})`
[ERROR] (line 36) Error: Evaluation failed: property `clientWidth` (`491`) isn't equal to `492` for selector `.mobile-topbar .location`: for command `assert-property: (".mobile-topbar .location", {"clientWidth": "492"})`

oh, well, I guess I can just ignore that problem.

@steffahn
Copy link
Member Author

TBH, I don’t have much more time I can spend on this today. I would highly appreciate if I didn’t have to learn this whole testing infrastructure now, too. This PR is already so much more that I initially wanted to do. Learning new HTML and CSS fundamentals I didn’t know before is enough commitment for my liking, I don’t feel like going too deep into this whole testing framework, too, now.

@GuillaumeGomez
Copy link
Member

I can do this part then.

@bors
Copy link
Contributor

bors commented Jul 16, 2022

☔ The latest upstream changes (presumably #99346) made this pull request unmergeable. Please resolve the merge conflicts.

@GuillaumeGomez
Copy link
Member

I took the commits from here, fixed the conflicts and added the missing GUI tests in #100374.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 11, 2022
…rch_results_page_crates_selection, r=notriddle

Improve crate selection on rustdoc search results page

Take over of rust-lang#98855 (screenshots and explanations are there).

You can test it [here](https://rustdoc.crud.net/imperio/improve_rustdoc_search_results_page_crates_selection/std/index.html?search=test).

cc `@steffahn` `@jsha`
r? `@notriddle`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 11, 2022
…rch_results_page_crates_selection, r=notriddle

Improve crate selection on rustdoc search results page

Take over of rust-lang#98855 (screenshots and explanations are there).

You can test it [here](https://rustdoc.crud.net/imperio/improve_rustdoc_search_results_page_crates_selection/std/index.html?search=test).

cc ``@steffahn`` ``@jsha``
r? ``@notriddle``
@steffahn
Copy link
Member Author

steffahn commented Jul 6, 2023

Looks like at some point Firefox must have changed, at least my Firefox browser no longer shows the differences that used to be compensated with the

/* cancel stylistic differences in padding in firefox
for "appearance: none"-style (or equivalent) <select>s */
@-moz-document url-prefix() {
	#crate-search {
		padding-left: 0px; /* == 4px - 4px */
		padding-right: 19px; /* == 23px - 4px */
	}
}

part, hence that can (and should) probably be removed. I’ll need to look into this more, and create an appropriate new issue and PR if this is really the case. (Makes me wonder whether there are good ways to do something like “display a website for a bunch of different versions of Firefox” in order to confirm that there really was a change at some version throughout the last year, and I’m not the one that changed a factor.

@GuillaumeGomez
Copy link
Member

I was wondering the same thing a few days ago. Don't hesitate to send a PR in any case!

As for checking on different firefox versions, I remember that websites allow it, but don't remember the name. ^^'

@steffahn steffahn deleted the improve_rustdoc_search_results_page_crates_selection branch July 18, 2023 18:01
@steffahn
Copy link
Member Author

I didn’t find any websites easily. I’ll just ignore the urge to conclusively “prove” something in Firefox has changed, and just go with the observation that both on my PC and phone, the current Firefox seems to be displaying it differently than intended and removing the special case workaround CSS code seems like the way to fix it. So I’ll just open a PR tomorrow. :-)

@GuillaumeGomez
Copy link
Member

Perfect, thanks!

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 20, 2023
…ctor-padding, r=GuillaumeGomez

Remove outdated Firefox-specific CSS for search's crate selector appearance

Remove adjustments that used to be necessary for search's crate selector appearance (padding) to look identical on Firefox. New versions of Firefox appear to have changed behavior to agree with Chrome.

As briefly discussed in rust-lang#98855 (comment)

r? `@GuillaumeGomez`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 20, 2023
…ctor-padding, r=GuillaumeGomez

Remove outdated Firefox-specific CSS for search's crate selector appearance

Remove adjustments that used to be necessary for search's crate selector appearance (padding) to look identical on Firefox. New versions of Firefox appear to have changed behavior to agree with Chrome.

As briefly discussed in rust-lang#98855 (comment)

r? ``@GuillaumeGomez``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustdoc new crate filter location visually unpolished
8 participants