-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat: add page tabbing #946
Changes from 5 commits
ea200b0
920e73e
5b7511b
fe606f5
b23ce24
c163909
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,34 @@ class DocsLayout extends React.Component { | |
language={metadata.language} | ||
version={metadata.version} | ||
metadata={metadata}> | ||
{ | ||
<script | ||
dangerouslySetInnerHTML={{ | ||
__html: ` | ||
function openConfig(num) { | ||
var i, tabContent, tabLinks; | ||
tabContent = document.getElementsByClassName("tabcontent"); | ||
for (i = 0; i < tabContent.length; i++) { | ||
tabContent[i].style.display = "none"; | ||
} | ||
tabLinks = document.getElementsByClassName("tablinks"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's specificly check if tabLinks exist. There is a chance that |
||
for (i = 0; i < tabLinks.length; i++) { | ||
tabLinks[i].className = tabLinks[i].className.replace(" active", ""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's be more specific and use replace(/ active$/, "") This is to avoid replacing a very special edge case |
||
} | ||
tabContent[num].style.display = "block"; | ||
tabLinks[num].className += " active"; | ||
|
||
rightSideToc=document.getElementsByClassName('toc-headings'); | ||
headings=rightSideToc[0].children; | ||
for(i = 0; i < headings.length; i++){ | ||
headings[i].style.display="none"; | ||
} | ||
headings[num].style.display="block"; | ||
} | ||
`, | ||
}} | ||
/> | ||
} | ||
<div className="docMainWrapper wrapper"> | ||
<DocsSidebar metadata={metadata} /> | ||
<Container className="mainContainer docMainContainer"> | ||
|
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.
In addition, I think it should not be named openConfig since its not related to config, its more related to tabbing. Use intention revealing names
The
num
could be better refactored/changed to the actual id we want to change the class on as well.I find the name not meaningful enough and using number to refer might not be a good idea.
I recommend something like
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 naming part can be changed, but the num part is a bit tougher. The tab content could have an id which can be passed while calling this function. But the id of right side toc cannot be known beforehand unless user explicitly gives each heading in right side toc.
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.
Ok lets do what we can first.