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

Transform help popup into a pocket menu #98297

Merged
merged 3 commits into from
Jun 26, 2022

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jun 20, 2022

Just like we moved the settings menu into a "pocket menu", it's doing the same to the help popup.

You can test it here and here is a screenshot:

Screenshot from 2022-06-20 20-58-29

r? @jsha

@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) A-rustdoc-js Area: Rustdoc's JS front-end labels Jun 20, 2022
@rust-highfive
Copy link
Collaborator

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez,@Folyd,@jsha

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 20, 2022
@jsha
Copy link
Contributor

jsha commented Jun 20, 2022

Why is it so wide? This is wider than the current help menu, and wider than the settings menu. It seems like keeping it similar width as the settings menu (it doesn't have to be exact) would increase harmony between the two.

@GuillaumeGomez
Copy link
Member Author

Making it the same width would require a lot of height so instead I limited its width to 600px. I updated the screenshot and the demo so you can take a look to see if it's more acceptable this way. :)

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Fixed eslint errors.

@notriddle
Copy link
Contributor

I don't think it makes sense for borders inside the help popup to be darker than the borders around it.

image

I also notice, in Firefox, that I can't select text to copy from it. That's not good.

@GuillaumeGomez
Copy link
Member Author

Nice, great catch! I'll fix it tomorrow. :)

src/librustdoc/html/static/css/rustdoc.css Outdated Show resolved Hide resolved
src/librustdoc/html/static/js/main.js Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member Author

I updated the demo. The blur and style are now correctly handled.

@GuillaumeGomez
Copy link
Member Author

I also extended the GUI test to ensure that all borders have the same color.

@notriddle
Copy link
Contributor

How to get both Settings and Help opened at once (at least in Firefox)

image

  1. First, click the Help button.
  2. Press Ctrl+L, making the address bar active. Alternatively, click it.
  3. Click the Settings button.
  4. Help and Settings are now both open at once, in violation of accepted UX guidelines for modal views like popovers.

How to fix it

Instead of solving this in an ad-hoc way by tying Help and Settings close together, I recommend some principled code reuse between these two popovers.

  1. Create a global, mutable variable in main.js for the CURRENTLY_OPENED_POPOVER. Set it to null initially.

  2. Instead of having two different functions for hiding the Help and Settings, write one function to hideCurrentPopover. Something like this:

    function hideCurrentPopover() {
        if (!CURRENTLY_OPENED_POPOVER) { return; }
        CURRENTLY_OPENED_POPOVER.style.display = 'none';
        CURRENTLY_OPENED_POPOVER = null;
    }
    
  3. When opening one of these two popovers, assign the popover DIV to the variable. You might even write a single function that just takes care of hiding and showing a popover:

    function togglePopoverByID(id) {
        const already_open = CURRENTLY_OPENED_POPOVER && CURRENTLY_OPENED_POPOVER.id === id;
        hideCurrentPopover();
        if (!already_open) {
            CURRENTLY_OPENED_POPOVER = document.getElementByID(id);
            CURRENTLY_OPENED_POPOVER.style.display = 'block';
        }
    }
    
  4. Get rid of most of the #help-button and #settings-button selectors in CSS. Use classes instead.

@GuillaumeGomez
Copy link
Member Author

It would be much simpler to just hide the other popover elements. Good idea! That will allow me to remove a function too.

@GuillaumeGomez
Copy link
Member Author

So instead of setting a JS global variable, I simply hide all popovers before showing a new one. Much simpler this way. :)

As for the CSS, what would you simplify?

Copy link
Contributor

@notriddle notriddle left a comment

Choose a reason for hiding this comment

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

This is probably going to be the last set of critiques. A lot of rustdoc's CSS seems overly complicated, but doing a comprehensive cleanup should be a separate PR.

I think the way you wrote the window.hidePopoverMenus function is good. Better than using a global variable. Thanks!

src/librustdoc/html/static/css/rustdoc.css Outdated Show resolved Hide resolved
@@ -1387,7 +1396,7 @@ pre.rust {
#copy-path {
height: 34px;
}
#settings-menu > a, #help-button, #copy-path {
#settings-menu > a, #help-button > button, #copy-path {
Copy link
Contributor

Choose a reason for hiding this comment

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

This selector is pretty complicated. Could it be a utility class instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just in case: it's not one selector but three different selectors on which we apply the same rules. If it was what you understood, I'm not sure to understand how simpler it could be though...

@GuillaumeGomez
Copy link
Member Author

This is probably going to be the last set of critiques. A lot of rustdoc's CSS seems overly complicated, but doing a comprehensive cleanup should be a separate PR.

You're right, but we're maybe not thinking about the same thing. 😆 I have two cleanups in mind:

  • I think some rules in rustdoc are not used anymore, I need to check that at some point.
  • The themes could be simplified a lot by setting CSS variables instead of reimplementing the rules. I plan to do it as well. I added a reminder to not forget once again.

@GuillaumeGomez
Copy link
Member Author

I simplified the CSS rule as @notriddle suggested.

compiler-errors added a commit to compiler-errors/rust that referenced this pull request Jun 25, 2022
…notriddle

Transform help popup into a pocket menu

Just like we moved the settings menu into a "pocket menu", it's doing the same to the help popup.

You can test it [here](https://rustdoc.crud.net/imperio/help-pocket-menu/doc/foo/index.html) and here is a screenshot:

![Screenshot from 2022-06-20 20-58-29](https://user-images.githubusercontent.com/3050060/174663718-538e9d11-3bf9-48b2-8909-f9bfe75af135.png)

r? ``@jsha``
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 25, 2022
…notriddle

Transform help popup into a pocket menu

Just like we moved the settings menu into a "pocket menu", it's doing the same to the help popup.

You can test it [here](https://rustdoc.crud.net/imperio/help-pocket-menu/doc/foo/index.html) and here is a screenshot:

![Screenshot from 2022-06-20 20-58-29](https://user-images.githubusercontent.com/3050060/174663718-538e9d11-3bf9-48b2-8909-f9bfe75af135.png)

r? ```@jsha```
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 25, 2022
…notriddle

Transform help popup into a pocket menu

Just like we moved the settings menu into a "pocket menu", it's doing the same to the help popup.

You can test it [here](https://rustdoc.crud.net/imperio/help-pocket-menu/doc/foo/index.html) and here is a screenshot:

![Screenshot from 2022-06-20 20-58-29](https://user-images.githubusercontent.com/3050060/174663718-538e9d11-3bf9-48b2-8909-f9bfe75af135.png)

r? ````@jsha````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 25, 2022
…notriddle

Transform help popup into a pocket menu

Just like we moved the settings menu into a "pocket menu", it's doing the same to the help popup.

You can test it [here](https://rustdoc.crud.net/imperio/help-pocket-menu/doc/foo/index.html) and here is a screenshot:

![Screenshot from 2022-06-20 20-58-29](https://user-images.githubusercontent.com/3050060/174663718-538e9d11-3bf9-48b2-8909-f9bfe75af135.png)

r? `````@jsha`````
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 26, 2022
…notriddle

Transform help popup into a pocket menu

Just like we moved the settings menu into a "pocket menu", it's doing the same to the help popup.

You can test it [here](https://rustdoc.crud.net/imperio/help-pocket-menu/doc/foo/index.html) and here is a screenshot:

![Screenshot from 2022-06-20 20-58-29](https://user-images.githubusercontent.com/3050060/174663718-538e9d11-3bf9-48b2-8909-f9bfe75af135.png)

r? ``````@jsha``````
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 26, 2022
…notriddle

Transform help popup into a pocket menu

Just like we moved the settings menu into a "pocket menu", it's doing the same to the help popup.

You can test it [here](https://rustdoc.crud.net/imperio/help-pocket-menu/doc/foo/index.html) and here is a screenshot:

![Screenshot from 2022-06-20 20-58-29](https://user-images.githubusercontent.com/3050060/174663718-538e9d11-3bf9-48b2-8909-f9bfe75af135.png)

r? ```````@jsha```````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 26, 2022
…notriddle

Transform help popup into a pocket menu

Just like we moved the settings menu into a "pocket menu", it's doing the same to the help popup.

You can test it [here](https://rustdoc.crud.net/imperio/help-pocket-menu/doc/foo/index.html) and here is a screenshot:

![Screenshot from 2022-06-20 20-58-29](https://user-images.githubusercontent.com/3050060/174663718-538e9d11-3bf9-48b2-8909-f9bfe75af135.png)

r? ````````@jsha````````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 26, 2022
…notriddle

Transform help popup into a pocket menu

Just like we moved the settings menu into a "pocket menu", it's doing the same to the help popup.

You can test it [here](https://rustdoc.crud.net/imperio/help-pocket-menu/doc/foo/index.html) and here is a screenshot:

![Screenshot from 2022-06-20 20-58-29](https://user-images.githubusercontent.com/3050060/174663718-538e9d11-3bf9-48b2-8909-f9bfe75af135.png)

r? `````````@jsha`````````
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 26, 2022
…askrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#97140 (std: use an event-flag-based thread parker on SOLID)
 - rust-lang#97295 ([rustc_parse] Forbid `let`s in certain places)
 - rust-lang#97743 (make const_err show up in future breakage reports)
 - rust-lang#97908 (Stabilize NonZero* checked operations constness.)
 - rust-lang#98297 (Transform help popup into a pocket menu)
 - rust-lang#98428 (macros: use typed identifiers in diag and subdiag derive)
 - rust-lang#98528 (Respect --color when building rustbuild itself)
 - rust-lang#98535 (Add regression test for generic const in rustdoc)
 - rust-lang#98538 (Add a ui test for issue rust-lang#91883)
 - rust-lang#98540 (Add regression test for rust-lang#87558)
 - rust-lang#98541 (Update `std::alloc::System` doc example code style)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit df26fdf into rust-lang:master Jun 26, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jun 26, 2022
@GuillaumeGomez GuillaumeGomez deleted the help-pocket-menu branch June 26, 2022 21:58
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 1, 2022
…r=jsha

Use CSS variables to handle theming

This is the start for our simplification of theming. Considering how big the diff quickly becomes, I think it's better to do it in multiple parts.

(The 3 first commits come from rust-lang#98297 so once it's merged, they'll disappear).

Normally they shouldn't be any UI changes. You can check it [here](https://rustdoc.crud.net/imperio/css-simplification/doc/foo/index.html).

cc `@notriddle`
r? `@jsha`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-js Area: Rustdoc's JS front-end A-rustdoc-ui Area: Rustdoc UI (generated HTML) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

7 participants