-
Notifications
You must be signed in to change notification settings - Fork 6k
JDK-8273034: Make javadoc navigation collapsible on small displays #5360
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
Conversation
👋 Welcome back hannesw! A progress list of the required criteria for merging this PR into |
Webrevs
|
I haven't looked at the code yet. I've only seen the sample documentation on my laptop and my initial reaction was: Oh boy, does it look good! Both primary and secondary navigation is at your fingertips (no pun intended). A few remarks.
|
Thanks for the feedback, Pavel! Both of the issues you spotted are very valid. I spent some time on both of them, but gave up for the time being since I didn't find a quick solution. Regarding the menu collapsing when resizing the browser (only when changing browser width btw), avoiding this would have required either duplication of hard-coded values between the CSS and script files, or adding more complexity to the script than seemed reasonable to me. I haven't looked at how Bootstrap solves this particular problem, but I guess they are willing to go the extra mile since this is part of their core purpose. In the pursuit of simplicity and maintainability, I thought the closing behaviour was acceptable. Regarding the same color being used for active and inactive links in the navigation bar, I tried to find a faded-out color for the inactive links, but it turned out that with the particular blue background any color but white is considered to break accessibility rules. We might want to file an separate issue for this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor comments/questions
addListToNav(listContents, tree); | ||
}; | ||
if (nested) { | ||
tree.add(HtmlTree.LI(HtmlTree.P(label)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the HtmlTree.P
necessary/useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is necessary, at least I haven't found an alternative solution.
The <li>
element we are creating here contains the main label as well as a nested list of links. The <li>
elements of the nested list are sized and padded via CSS. In order to apply similar size and padding to the main label it needs to be contained in an element with block display.
I realize the use of <p>
instead of <div>
may seem a bit strange as the label does not really represent a paragraph. I think I chose it because it had more useful default sizing rules. However, I could easily switch to using a <div>
instead.
tree.add(li); | ||
addListToNav(listContents, tree); | ||
if (nested) { | ||
Content li = HtmlTree.LI(HtmlTree.P(contents.detailLabel)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto: Is the HtmlTree.P necessary/useful?
@@ -291,6 +291,35 @@ function doSearch(request, response) { | |||
response(result); | |||
} | |||
$(function() { | |||
var expanded = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include standard/recurring discussion on testing JavaScript
ul.sub-nav-list-small li p { | ||
margin: 5px 0; | ||
} | ||
div#navbar-sub-list { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to us:
The use of standard id's in the stylesheet should be documented in the upcoming new spec document
@@ -807,34 +807,113 @@ table.striped > tbody > tr > th { | |||
font-weight: normal; | |||
} | |||
/** | |||
* Tweak font sizes and paddings for small screens. | |||
* Tweak style for small screens. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comment, for discussion ...
There's a growing set of absolute values in the stylesheet. At what point should we generate the .css file from a template and a separate list of definitions?
HtmlTree ulNavSummaryRight = new HtmlTree(TagName.UL).setStyle(HtmlStyle.subNavListSmall); | ||
addSummaryLinks(ulNavSummaryRight, true); | ||
addDetailLinks(ulNavSummaryRight, true); | ||
navDiv.add(ulNavSummaryRight); | ||
tree.add(navDiv); | ||
|
||
HtmlTree subDiv = new HtmlTree(TagName.DIV).setStyle(HtmlStyle.subNav); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have some factory methods for HtmlTree.DIV
@hns This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 263 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit 1d44014.
Your commit was automatically rebased without conflicts. |
Please review a change to add a collapsible "hamburger" navigation bar to javadoc pages for small screens. The collapsible navbar is activated when the browser width is below 920px, which is the point where the normal navigation bar starts to wrap for some javadoc pages.
The feature is implemented using CSS and JavaScript techniques employed by popular frameworks and has been successfully tested on several browsers and platforms, including various Android and iOS devices as well as IE and Edge browsers on Windows 10.
Sample documentation generated with this change is provided at the URL below. For testing, please review it on a mobile phone or tablet, or using the device emulation features provided with the developer tools of many desktop browsers.
http://cr.openjdk.java.net/~hannesw/8273034/api.00/index.html
One peculiarity of this change is that the sub-navigation links are rendered separately for the normal and the mobile navbar. The reason for this is that the links are structured differently (flat list vs nested lists) and reside in different containers.
On the CSS side, apart from the collapsible navbar I overhauled the styles for the search input, especially the small reset "X" button. The positioning of the reset button is now simpler and more robust by using
absolute
instead ofrelative
position, and doesn't require moving the search input and label to the right anymore.The collapsible menu uses the
aria-controls
,aria-expanded
attributes as described in the following wiki page:https://www.w3.org/WAI/GL/wiki/Using_the_WAI-ARIA_aria-expanded_state_to_mark_expandable_and_collapsible_regions
Furthermore, the
aria-label
attribute is used to provide a human-readable lable for the button.https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5360/head:pull/5360
$ git checkout pull/5360
Update a local copy of the PR:
$ git checkout pull/5360
$ git pull https://git.openjdk.java.net/jdk pull/5360/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5360
View PR using the GUI difftool:
$ git pr show -t 5360
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5360.diff