Skip to content

Conversation

EmileTrotignon
Copy link
Collaborator

There are now a lot of bars in odoc, which can be side, search or absent or present.

This fixes weird css interactions in with some combinations in that were merged before we had a chance to fix them in the sidebar pr.

@@ -1253,7 +1274,7 @@ td.def-doc *:first-child {
}
.odoc-toc {
position: unset;
max-height: unset;
max-height: unset !important;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it would be better to have the same priority on both the rule setting the max-height and the one inside the media block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

/* When a search bar is present, we need the sticky sidebar to be a bit lower,
   so `top` is higher  */

.odoc-search + * + .odoc-tocs .odoc-toc {
  --toc-top: calc(var(--search-bar-height) + 2 * var(--search-padding-top));
  max-height: calc(100vh - 2 * var(--toc-top));
  top: var(--toc-top)
}

Here is it, the high priority is built in the rule.

@EmileTrotignon EmileTrotignon added the no changelog This pull request does not need a changelog entry label Jul 11, 2024
@EmileTrotignon
Copy link
Collaborator Author

In the presence of a global sidebar the layouts are the following :

large screens:
image
image

medium screens:
image
image

small screens:
image
image

@EmileTrotignon
Copy link
Collaborator Author

The screenshot are produced with the "final fixes" (a1af33c) commit

@jonludlam
Copy link
Member

Isn't the use of !important usually considered to be an anti-pattern?

@panglesd
Copy link
Collaborator

Yes, it is an antipattern. I think it would be better to give a specific class to body when the search bar is present rather than relying on some brittle rule (.odoc-search + * + .odoc-tocs .odoc-toc) and antipattern (!important).

@EmileTrotignon
Copy link
Collaborator Author

Yes, it is an antipattern. I think it would be better to give a specific class to body when the search bar is present rather than relying on some brittle rule (.odoc-search + * + .odoc-tocs .odoc-toc) and antipattern (!important).

I think the solution you mention is the right one, but I am not sure this should be part of this PR. The brittle rule is present since 2.4.

This is done by simplifying some rules, and by augmenting the specificity of the other via nesting.
Comment on lines 1260 to 1263
.odoc-toc {
position: unset;
max-height: unset;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this rule doing in another one? Am I too old and this is valid?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it is valid, and quite cool: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting/Using_CSS_nesting
Thanks for teaching me that!

However, caniuse reports only 82% of used browser with full support. Since this was not used before, is it really worth introducing it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was used before, the whole media rule was nested.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Media queries are not CSS nesting... They have 98% support on caniuse.

.odoc-tocs {
&:has(> .odoc-search:focus-within) {
/* This is the same as when there is no focus on the search bar, this is
just to prevent the full screen rule from changing anything. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you mean with "fullscreen rule"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I meant the large screen/default rule

Copy link
Collaborator

@panglesd panglesd Jul 15, 2024

Choose a reason for hiding this comment

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

Suggested change
just to prevent the full screen rule from changing anything. */
just to prevent the default "wide layout" rule from changing anything. */

Copy link
Collaborator

@panglesd panglesd left a comment

Choose a reason for hiding this comment

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

This indeed fixes interaction between search and sidebars.

@panglesd panglesd merged commit 24bf460 into ocaml:master Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog This pull request does not need a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants