Skip to content

[WIP] Start transforming documentation toggles into pure css ones#83355

Closed
GuillaumeGomez wants to merge 1 commit intorust-lang:masterfrom
GuillaumeGomez:pure-css-toggles
Closed

[WIP] Start transforming documentation toggles into pure css ones#83355
GuillaumeGomez wants to merge 1 commit intorust-lang:masterfrom
GuillaumeGomez:pure-css-toggles

Conversation

@GuillaumeGomez
Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez commented Mar 21, 2021

This is a first draft of #83332. I precise: this is a work in progress. However, with this we can already see what it'll look like after. I precise: even if incomplete, this is working.

For now, this PR switched the doc blocks toggles for the following parts:

  • item doc block (the one at the top)
  • methods doc blocks

Some explanations on how it works: I used a trick based on checkbox. I hide the checkbox and only print its label, so when you click on the label, you check/uncheck the checkbox. Now, that also brings some downsides too:

  • Positioning the label would be tricky without a parent so I had to add a div to wrap the function and its documentation. However, I see that as a positive point because we're finally "merging" the items and their documentation.
  • It makes the DOM heavier because we have to add a div, a label and an input for each item with documentation.

The advantages now:

  • It'll be much simpler to handle showing/hiding documentation since it'll be handled 100% with CSS. No more JS for this (except for toggling all toggles at once, this one will remain).
  • A lot less of weird JS that we had.
  • No more DOM manipulation when we arrive on a page to add the toggles (meaning better performance!).
  • It'll finally be possible to hide/show documentation even without JS.

There are some small display differences too because currently we use width on the -/+ sign to make the whole a big larger.

Before:

Screenshot from 2021-03-21 22-37-59

After:

Screenshot from 2021-03-21 22-38-03

If this seems to be the right way to go, I'll clean up this PR (and finish to remove the remaining JS toggles) so we can finally have toggles 100% non-JS. \o/

r? @Manishearth

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-ui Area: Rustdoc UI (generated HTML) 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.

8 participants