-
Notifications
You must be signed in to change notification settings - Fork 326
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
Experimental Header Navigation #3589
base: master
Are you sure you want to change the base?
Experimental Header Navigation #3589
Conversation
@calculuschild We might want a deployment on this one for testing |
Once a deployment is ready, i will suggest some style options, maybe we could even pull something from the codemirror theme chosen. |
My thought is that this is another reason for a unified template for Share and Edit pages— share pages could even have a split panel as well. The left panel would have tabs including the table of contents/outline. |
In case it's not clear: this navigation lives in the BrewRenderer, so exists on both Edit and Share pages. I just realized that I've only posted screen shots from Edit pages, and that might cause some confusion. |
Yeah I know where it is currently in the PR. I am suggesting an alternate future, whether it’s done in this PR or not. It just feels like we already have a hideable sidebar/drawer interface available to us, and we might not need to invent another expanding component. Just my two cents. |
More thoughts on this in this one-person discussion: #2951 |
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.
Overall i would make the requested changes, and following style changes.
const HeaderNavItem = ({ link, text, depth, className })=>{ | ||
return <p> | ||
<a href={`#${link}`} target='_self' className={className}> | ||
{`${'-'.repeat(depth)}${text}`} | ||
</a> | ||
</p>; | ||
}; | ||
|
||
export default HeaderNav; |
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 syntax needs improvement, this is a navigation, so please do implement proper HTML, a <nav>
element, with <ul>
and <li>
, or something like that, maybe even with some classes or attributes.
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.
Perhaps add a border- after pages, or an HR element too.
Also please add a title to this navigation, a simple ## Header Navigation
will suffice, like the title attrb on the button.
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.
Every link should have a class to indicate depth to be able to style this properly, not just the dash option (which i don't particularly like the look of)
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.
Recommended addition/change:
.headerNav {
padding: 25px 30px 5px 10px;
.navIcon {
position:fixed;
top:0px;
padding-top:5px;
&.active {
width:470px;
background:#dadada;
z-index:10;
}
}
&.active {
padding: 25px 10px 5px 10px;
height:100vh;
width:500px;
background:#dadada;
p:has(.pageLink) {
margin-block:10px 5px;
&:after {
content:'';
height:2px;
background:#929292;
display:block;
position:relative;
top:4px;
}
}
&::-webkit-scrollbar {
width: 10px;
}
&::-webkit-scrollbar-corner {
visibility: hidden;
}
&::-webkit-scrollbar-thumb {
background: #929292;
border-radius:5px;
}
}
}
to achieve:
I suspect it's a case of a really long title is causing the element to cover 100% of the viewable width. Some styling like |
I am very concerned that this pulls too many headers. Would adding a pulldown to set the "Max" Header level be practical? This PR has a natural extension to do the same navigation to the editing window. |
I can imagine a future PR could address this, perhaps by providing little Lets get this simpler version deployed first though. |
…mbatte/homebrewery into experimentalHeaderNavigation
I think you can just put the button in the new toolbar, on the far left. Rather than floating as it's own button. |
The error looks to be from picking up the div containing the table's full content. |
|
||
const renderHeaderLinks = ()=>{ | ||
if(!pagesRef.current) return; | ||
const elements = pagesRef.current.querySelectorAll('[id]'); |
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.
Right, we can let CSS do the heavy lifting here:
const elements = pagesRef.current.querySelectorAll('[id]'); | |
const elements = pagesRef.current.querySelectorAll('*:is(h1,h2,h3,h4,h5,h6)[id]'); |
We could even use this to leverage the depth level later.
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 should fix the aforementioned issue.
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.
From my initial testing, the suggested change here does not work - the returned NodeList has a length of 0 when the previous query returned a length of 4.
Also, my initial thought is that the :is()
limits the results to headers only, when id
can exist on any element - like <div class='page' id='p1'>
, for example.
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.
Right, i thought we only wanted headings, but.. right, so the issue here is that any block with id gets caught, with all contents too, including in this case the table
@@ -424,6 +424,7 @@ const EditPage = createClass({ | |||
lang={this.state.brew.lang} | |||
currentEditorPage={this.state.currentEditorPage} | |||
allowPrint={true} | |||
showHeaderNav={true} |
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.
Does this component really need to stretch all the way to up to editPage.jsx and sharePage.jsx files? It seems like we could just assume that the headerNav is always going to present in both pages (not always visible, of course), so we don't need to pass it in as a boolean prop on BrewRenderer-- it could just be included in BrewRenderer unconditionally.
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 could, if we also want it to appear on every other page, like New, Home, Change Log, Welcome...
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 don't really see a problem with that. For something like the changelog, especially, it'd be nice to just have a list of dates/versions. Same deal with FAQ (though it's obviously not very long at this point). The point of the site is to create documents, and I'm not sure we need to say "some documents have these tools, others don't".
If there are pages where navigation by header isn't desired, then we should maybe consider stop making everything out of special-case brews and just make normal pages.
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 agree with G-Ambatte here, FAQ perhaps, but the rest don't need navigation at all, 2 page documents....
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’m not sure why there needs to be a distinction between short and long documents here. For all documents are we going to make the button disappear if it’s shorter than 2 pages? What if it is 10 pages but has no headers?
The goal should be to have a consistent, unified UI as much as possible. If a button exists for one brew, it should be available on all brews. If, for whatever reason, a button really surely doesn’t do anything on a particular brew, then it should still be there but be disabled. That isn’t the case here, though.
This PR adds a button to the BrewRenderer. When clicked, this exposes the header navigation window, which lists all of the elements with IDs in the document.
It generates this information by calling
querySelectorAll('[id]')
to acquire a list of all elements that have anid
attribute, then parsing these for the following conditions:page
- depth: 0; text: 'Page' + page numberh1
throughh6
- depth: heading value, i.e. h1 => 1, h6 => 6; text:innerText
valueinnerText
valueFrom one of the documents in my local install DB:
CLOSED:
OPEN:
HOVERING OVER "PAGE 2: