-
Notifications
You must be signed in to change notification settings - Fork 172
Updating sidebars to use details/summary #789
Conversation
@schalkneethling @jwhitlock Would appreciate you folks having a look. This touched more than I had thought it would and I want to make sure I didn't overlook anything. |
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.
Whoah, that is a lot of changes. Thanks @tkadlec. Some nits, questions, general comments, and required changes.
Note: Not all nits was introduced here but, seeing we are doing all this work, we might as well clean up a bit as well ;)
macros/DocStatusQuickLinks.ejs
Outdated
<li><a href="/<%=env.locale%>/docs/MDN/Doc_status/JavaScript"><%=titleValues['JavaScript']%></a> | ||
<li><a href="/<%=env.locale%>/docs/MDN/Doc_status/Marketplace"><%=titleValues['Marketplace']%></a> | ||
<li><a href="/<%=env.locale%>/docs/MDN/Doc_status/MathML"><%=titleValues['MathML']%></a> | ||
<li><a href="/<%=env.locale%>/docs/MDN/Doc_status/SVG"><%=titleValues['SVG']%></a> |
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.
Missing closing tags for li
tags
@tkadlec I notice that the
|
@tkadlec and that CSS change will be on the Kuma side ;) |
@jwhitlock tells me this gets rid of the links to the overview pages that are linked to from the expandable sections' headings. That's not ideal. I know they never worked right before, but it would be better if we could have that link functional instead:
In that example above, "HTML" is an expandable heading; clicking it makes the elements below appear. What should happen is that there should be a widget you click to expand to show the element names, while allowing clicking the title "HTML" itself to take you to the main HTML reference page. |
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.
Thanks @tkadlec, this is a big one. I'd prefer if it was broken into multiple pull requests, but I understand a side requirement is to all go at once, to simplify the JS / CSS changes and be able to measure impact.
I think @schalkneethling identified most of the required changes, around missing EJS end tags %>
. I think my required changes are:
- HTMLSidebar.ejs:
<%=text['HTML_Elements']%>
- HTMLSidebar.ejs: Missing Global Attributes section
- SVGRef.ejs: add missing closing tag
</details>
.
I just read the code this round, now to integrated testing. I'll see if a change is needed around data-default-state
during that testing.
Update: Added SVGRef to required changes
</ol> | ||
<li class="toggle"> | ||
<details <%=state('Introduction_to_HTML')%>> | ||
<summary><%=text['Introduction_to_HTML']%></summary> |
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.
This drops the link, but it's also the first element in the details list, so 👍
There's a number of times that a section element has an <a>
element in the existing sidebar, that is removed by this change. The translate attribute page has one of these sidebars, and if you hover over "HTML basics" -> "Introduction to HTML", you can see that the browser thinks clicking will go to Learn/HTML/Introduction_to_HTML. However, if you click the item, JavaScript takes over, and the section expands or collapses instead.
I'm not sure of a good way to combine "click here to expand / collapse" and "click here to go to this page". The arrow could be "collapse / expand" and the text could be "go to page", but that seems like a bad UI, making the common action the one with the tiny target.
This list has the pattern "move the summary link to the first item and add 'Overview'", and a few others do as well. This seems like a decent compromise going forward, and other sections should adopt it.
I'm trying to decide if this should be future work, since we're losing some information with this change. And I attached my essay to a line that doesn't need the change.
<li data-default-state="<%=currentPageIsUnder('WebExtensions/API')%>"><a href="<%=baseURL%>WebExtensions/API"><%=text['WebExtensions/API']%></a> | ||
<%-template("WebExtAPISidebar", [])%> | ||
<li class="toggle"> | ||
<details <%=currentPageIsUnder('WebExtensions/API')%>> |
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.
Nit: GitHub hates %>>
. I guess EJS isn't popular enough for a robust syntax highlighter? 😉
The "Whitespace Slurping" ending tag may help appease GitHub and get the desired output:
<details <%=currentPageIsUnder('WebExtensions/API')_%> >
Nope, that seems worse. Maybe it doesn't like HTML escaping into an unquoted context?
<details <%- currentPageIsUnder('WebExtensions/API')_%> >
Nope, syntax highlighting just seems to hate us. No change needed.
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.
All EJS (and Liquid/Jinja2/<insert templating language of choice here>) syntax highlighters I tried can’t properly highlight conditional attributes,
macros/nsprapiref.ejs
Outdated
<li><a href="/<%=locale%>/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Naming_Conventions"><%=text['NSPR Naming Conventions']%></a></li> | ||
<li><a href="/<%=locale%>/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#NSPR_Threads"><%=text['NSPR Threads']%></a> | ||
<ol> | ||
<li><a href="/<%=locale%>/docs/Mozilla/Projects/NSPR/Reference/Introduction_to_NSPR#Thread_Schedoling"><%=text['Thread Scheduling']%></a> |
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.
Existing nit: #Thread_Scheduling, not #Thread_Schedoling
. Although "Schedoling" should be a word...
let links = dom.querySelectorAll('a'); | ||
assert.equal(links[1].textContent, locales[locale].Page_Inspector); | ||
let summaries = dom.querySelectorAll('summary'); | ||
assert.equal(summaries[0].textContent, locales[locale].Core_Tools); |
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.
Weird test, but works after change. The HTML was:
<ol>
<li><a href="#">Core Tools</a>
<ol>
<li><a href="/en-US/docs/Tools/Page_Inspector">Page Inspector</a></li>
and now is:
<ol>
<li class="toggle">
<details>
<summary>Core Tools</summary>
<ol>
<li><a href="/en-US/docs/Tools/Page_Inspector">Page Inspector</a></li>
I think the weirdness around testing sidebars is a symptom of a need for re-implementing them. Future work.
@a2sheppy, if there is a way to make this work, then that would be great. It's not obvious to me that there is. I think most users want to expand / collapse the list, and a smaller number want to go to the other page. Making the title a link to the page makes the largest UI element the minority action, which I think is a bad user experience. My mental model is application menus in macOS, where a menu item is either an item or expands a submenu, never mixed. If you have a UI example where actions are combined with submenus, that would help me wrap my head around your solution. Otherwise, my inclination is to not expand the scope of this PR to "fix this UX problem". If we need to retain the links, my preference is to commit to the model where the first submenu item is the link to the overview menu. The side menu on the
I'm 50/50 on shipping @tkadlec's changes and adding overview items later, or making them part of this change. |
@jwhitlock I think the biggest thing is to not lose the links. I reckon your suggestion of adding another menu entry that links to the overview makes a lot of sense. It would also fix a bug that was opened a while back, complaining about the fact that you have to:
in order to get to the overview pages. +1 |
(In reply to @schalkneethling from #789 (comment))
You can also middle‑click to open the overview page in a new tab. |
@ExE-Boss True, you could also right click and open in a new tab or, command+click. Not an ideal user experience though, that is why I like @jwhitlock's idea. |
…/kumascript into bug/258-moztogglr-reflow
@jwhitlock @schalkneethling @ExE-Boss I'd vote for John's solution, at least for a starting point. Do I wrap that into this PR or do we break it out? |
@schalkneethling Where are you seeing that? It should be taken care of here: mdn/kuma@11b4d07#diff-691645fb32733fcf070299b5bddeb224R56 |
<li><a href="<%=baseURL%>Responsive_Design_Mode"><%=text["Responsive_Design_Mode"]%></a></li> | ||
<li><a href="<%=baseURL%>Tips"><%=text["Tips"]%></a></li> | ||
</ol> | ||
<li class="toggle"> |
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.
The {{ToolsSidebar}}
was converted correctly 👍 as seen on https://developer.mozilla.org/en-US/docs/Tools/Web_Console . There's some local weirdness because the macro has https://developer.mozilla.org
hard-coded into some links, which make them looks like external links in local dev. This should be removed, but it was in the old version, so out-of-scope for this PR.
<li><a href="<%=baseURL%>/Caching_modules"><%=text['Caching_modules']%></a></li> | ||
<li><a href="<%=baseURL%>/Exported_functions"><%=text['Exported_functions']%></a></li> | ||
</ol> | ||
<li class="toggle"> |
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.
The {{WebAssemblySidebar}}
macro was correctly updated, as seen on https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm
<li><a href="/<%=locale%>/docs/Web/API/WebGL_API/Tutorial/Lighting_in_WebGL"><%=text['Lightning']%></a></li> | ||
<li><a href="/<%=locale%>/docs/Web/API/WebGL_API/Tutorial/Animating_textures_in_WebGL"><%=text['Animating_textures']%></a></li> | ||
</ol> | ||
<li class="toggle"> |
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.
The {{WebGLSidebar}}
is converted correctly 👍, as seen on https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL
<li><a href="/<%=locale%>/docs/Web/API/WebRTC_API/Session_lifetime"><%=text['Session_lifetime']%></a></li> | ||
<li><a href="/<%=locale%>/docs/Web/API/WebRTC_API/Using_data_channels"><%=text['Using_data_channels']%></a></li> | ||
</ol> | ||
<li class="toggle"> |
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.
The {{WebRTCSidebar}}
macro is correctly converted 👍, as seen on https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Signaling_and_video_calling ("WebRTC Basics" in the sidebar):
@@ -21,11 +21,12 @@ output += '<li><strong><a href="' + EventHref + '">Events</a></strong></li>'; | |||
|
|||
function buildEventList(name, events, open) { | |||
var openstr = open ? ' data-default-state="open"' : ''; | |||
var result = '<li'+ openstr +'><a href="#"><strong>' + name + '</strong></a><ol>'; | |||
<li class="toggle"><details open><summary>' + title + '</summary><ol></ol> | |||
var result = '<li class="toggle"><details ' + openstr + '><summary>' + name + '</summary><ol>'; |
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.
This isn't valid EJS, starting at <li class="toggle">
inside an EJS <%
block. I think it should be something like:
var openstr = open ? ' open' : '';
var result = '<li class="toggle"><details ' + openstr + '><summary>' + name + '</summary><ol>';
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.
It's valid now, but it should use the open
attribute, not data-default-state="open"
. On https://developer.mozilla.org/en-US/docs/Web/Events/datachannel, the new sidebar (right side) is collapsed:
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.
There are still some missing closing EJS tags in the summary blocks.
'Doc_Status' : 'NSPR Documentation status', | ||
'The_MDN_project' : 'The MDN Project' | ||
|
||
'NSPR' : 'NSPR', |
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.
{{nsprapiref}}
is a big one, and it converted correctly 👍, as seen on https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR/Reference/NSPR_Types:
I've done a live test of each of the changed macros, and these need some fixes:
|
Thanks so much for all the detailed reviews @jwhitlock ☕️ |
@jwhitlock @schalkneethling I've gone through the sidebar's John flagged and tested each of them. Can you take another look when you have time? |
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.
Couple of items to clean up still here, but we are soooo close. Thx @tkadlec
<li><a href="<%=baseURL%>WebExtensions/Examples"><%=text['WebExtensions/Examples']%></a></li> | ||
<li><a href="<%=baseURL%>WebExtensions/What_next_"><%=text['WebExtensions/What_next_']%></a></li> | ||
</ol> | ||
<li class="toggle"> |
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 am still seeing the above problems as mentioned above. I would also suggest that we add some padding inside the grey container.
@schalkneethling Thanks for the review! All of the issues are taken care of in the Kuma PR. The only thing that I need you to double-check is |
All good, after pulling the latest and restarting all the things those issues were gone. I see there are two files with conflicts now though :/ |
Pushed just as your comment appeared for me. :) |
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.
That's an r+ from me. Thanks @tkadlec 🌮
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.
These now work without errors, so I think we're ready to go. However, these changes will require re-rendering every page with the sidebars. Once the kuma style changes ship, the existing sidebars will get ugly until re-rendering. To apply the new sidebars, we'll need to re-render each page that uses them, which takes about 1 second per page (3-5 hours). I think we're going to aim for Thursday, October 4th for merging, deploying, and re-rendering.
Two small fixes we could still get in before Thursday:
open
attribute ineventref.ejs
, to auto-expand the details- Spacing in
jsctypesSidebar
@@ -21,11 +21,12 @@ output += '<li><strong><a href="' + EventHref + '">Events</a></strong></li>'; | |||
|
|||
function buildEventList(name, events, open) { | |||
var openstr = open ? ' data-default-state="open"' : ''; | |||
var result = '<li'+ openstr +'><a href="#"><strong>' + name + '</strong></a><ol>'; | |||
<li class="toggle"><details open><summary>' + title + '</summary><ol></ol> | |||
var result = '<li class="toggle"><details ' + openstr + '><summary>' + name + '</summary><ol>'; |
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.
It's valid now, but it should use the open
attribute, not data-default-state="open"
. On https://developer.mozilla.org/en-US/docs/Web/Events/datachannel, the new sidebar (right side) is collapsed:
|
||
<li data-default-state="<%=state('Introduction')%>"><a href="/<%=locale%>/docs/Mozilla/js-ctypes/Using_js-ctypes"><%=text['Introduction']%></a> | ||
<%-template("ListSubpagesForSidebar", ['/' + locale + '/docs/Mozilla/js-ctypes/Using_js-ctypes', 1])%> | ||
<li class="toggle"> |
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.
This compiles now. On https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/CType, the new sidebar (right side) has more vertical spacing than before. I'm OK with the change, but @schalkneethling may have something to say about it.
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.
Nope, all good. I like the new spacing.
I'll address |
Changes all necessary macro's to start using the
<details>
and<summary>
elements instead of jQuery for the sidebar navigation.Will close https://app.zenhub.com/workspace/o/mdn/sprints/issues/258