-
-
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: code block tab #1063
feat: code block tab #1063
Conversation
where it ends - I try using DOCUSAURUS_CODE_TABS to mark the start - Use TAB_TITLE to mark the title of the tab - END_TAB to mark the end of that tab - END_DOCUSAURUS_CODE_TABS to mark the end of the whole code blocks then parse using regex and render accordingly
…e can be reverted 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.
I think this is a fine way to approach the problem. I am definitely ok with having markdown markers that represent the various code tabs like you have. I will comment inline.
v1/lib/core/Doc.js
Outdated
@@ -59,6 +98,8 @@ class Doc extends React.Component { | |||
); | |||
} | |||
|
|||
// const a = this.props.content.split(/(DOCUSAURUS_CODE_TABS)(.*?)(END_DOCUSAURUS_CODE_TABS)/gms) | |||
// console.log(a.length, 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.
Remove these.
@@ -34,12 +34,108 @@ root-of-repo | |||
│ └── static | |||
``` | |||
|
|||
|
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.
Can you add this documentation to https://github.com/facebook/Docusaurus/blob/master/docs/api-doc-markdown.md instead?
|
||
## Codeblocks in multiple languages | ||
|
||
DOCUSAURUS_CODE_TABS |
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 this is a clever way to do this.
@@ -34,12 +34,108 @@ root-of-repo | |||
│ └── static | |||
``` | |||
|
|||
|
|||
## Codeblocks in multiple languages | |||
|
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.
Let's add some wording about what is going on here.
Of course, you are also free to write your own pages. It is strongly suggested that you at least have an index page, but none of the pages provided are mandatory to include in your site. More information on how to use the provided components or include your own can be found [here](api-pages.md). Information on how to link to your different pages in the header navigation bar can be found [here](guides-navigation.md). | ||
|
||
> If you want your page to show up in your navigation header, you will need to update `siteConfig.js` to add to the `headerLinks` element. e.g., `{ page: 'about-slash', label: 'About/' }`, | ||
|
||
## Adding Static Pages | ||
|
||
DOCUSAURUS_CODE_TABS |
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 not sure you need this all this example here if you add the documentation to https://github.com/facebook/Docusaurus/blob/master/docs/api-doc-markdown.md
@@ -44,4 +44,25 @@ window.addEventListener('load', function() { | |||
textEl.textContent = 'Copy'; | |||
}, 2000); | |||
}); | |||
|
|||
// add event listener for all tab | |||
document.querySelectorAll('.nav-link').forEach(function(el) { |
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.
We will need to make sure that this is installed as part of the Docusaurus install process -- e.g., docusaurus-init
I think the test are failing also. Might not be because of CI |
v1/lib/static/css/main.css
Outdated
} | ||
|
||
.nav-tabs::-webkit-scrollbar { | ||
display: none; // Safari and Chrome |
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 guess i should not put comment on 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.
In CSS comments should be /* */
not //
Deploy preview for docusaurus-preview ready! Built with commit 9cb10e2 |
document | ||
.querySelectorAll(`.tab-pane[data-group=${groupId}]`) | ||
.forEach(function(el) { | ||
el.classList.remove('active'); |
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 shouldnt be placed here because not every docusaurus user has this file
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.
@endiliey I suggested that we add it as part of docusaurus-init
. But you might be right, since that is more of a custom file. Could put it in v1/lib/static
maybe?
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.
Hmm yeah I'm confused where to put it actually 😯 I put it there to mimic the code blocks
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.
Should I make something like this? https://gist.github.com/yangshun/55db997ed0f8f4e6527571fc3bee4675 and put all the related css outside of the lib?
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.
put it in v1/lib/static and modify the Head.js to always include 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.
@endiliey @JoelMarcey made the changes:D please review!
39f4e7e
to
070678a
Compare
- Remove comments
070678a
to
261e8e7
Compare
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 currently not well so my review will come late this 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.
Seems like a great feature for me
https://deploy-preview-1063--docusaurus-preview.netlify.com/docs/en/next/doc-markdown#code-tabs
Kinda dislike the syntax to do the tabbing though :(. Is it possible to make it simpler ?. I'm wondering what are the popular syntax are like out there.
I am wondering if END_TAB
is really necessary ? Can we do better ?
I will give the above a try! 💃 |
bc5fc37
to
f17cff3
Compare
f17cff3
to
9cb10e2
Compare
Is this PR ready or still WIP ? LGTM on a glance. Will review after that |
This is ready to go, I believe. |
@endiliey feel free to review. |
We tested it and are waiting for the official release 👍 |
Works like a charm, would be awesome to be part of next release. |
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.
Nice work @fiennyangeln!
Motivation
#103
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
2. Try to click on the tab 3. See if the other code tab changes too or not 4. Try to resize the width of the browser to be abit smaller to see how it looks like if it overflow
Related PRs
Null
Todo