-
Notifications
You must be signed in to change notification settings - Fork 45.7k
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
[docs update] fix tabs on 'installation' page #10593
Conversation
**what is the change?:** This is an awful hack. It will be improved in the future. - Fork `<MarkdownPage>` to create a custom page for Installation, to support the tab panel interaction - Take the raw JS from `installation` doc file and put it in the new `<InstallationPage>` - Change the `block` tags into `section` tags, and remove dead JS from `installation` doc file. Because that is less gross than leaving `block` tags in place. TODO: - fix styling - make follow-up tasks and issues to properly refactor this **why make this change?:** The tabs were not working, we need to have them a least functional. **test plan:** Manual testing **issue:** Checklist item in wiki - Misc > Properly handle tabbed content on /docs/installation.html
**what is the change?:** - Downgraded some 'h2' elements to 'h3' - Tweaked JS to add a class to the parent's parent instead of just the parent of the content section **why make this change?:** - The default 'h2' styles in the new Gatsby site add extra space and an 'hr' type line at the top, and this didn't look right inside the tabbed content. - The class was supposed to go on the parent of the tabs and their content, and in a previous commit I added an extra wrapper to the content sections. That meant the JS should be updated to find the right place to add the class. **test plan:** Manual testing (flarnie will add screenshots) **issue:** https://github.com/bvaughn/react/wiki/Gatsby-check-list misc > Properly handle tabbed content on /docs/installation.html
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 for fixing this @flarnie! Left a minor change request. Happy to help with it if there's any confusion.
www/src/templates/docs.js
Outdated
/> | ||
); | ||
const Docs = ({data, location}) => { | ||
console.log('location is ', location); |
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.
Whoops ^
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.
:) fixed while you were reviewing
www/src/templates/docs.js
Outdated
const Docs = ({data, location}) => { | ||
console.log('location is ', location); | ||
if (location.pathname === '/docs/installation.html') { | ||
console.log('about to render InstallationPage'); |
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.
Whoops ^
www/src/templates/docs.js
Outdated
); | ||
const Docs = ({data, location}) => { | ||
console.log('location is ', location); | ||
if (location.pathname === '/docs/installation.html') { |
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 works but I think we'd be better off doing this check in gatsby-node
like we do for the Home 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.
Cool - will look into that.
**what is the change?:** - removed `console.log` statements - moved a variable to the correct place, fixing lints - changed a query selector so that loading a page with a hash in the url selects the right tab in the 'installation' docs **why make this change?:** - to get CI passing - to fix hash urls on the 'installation' page **test plan:** - manual testing - `yarn run lint` **issue:** Checklist item - https://github.com/bvaughn/react/wiki/Gatsby-check-list misc > Properly handle tabbed content on /docs/installation.html
**what is the change?:** Instead of adding a fork in the logic in the 'docs' template, we add a special case in the router itself. That way we branch at a place that makes sense in the code. **why make this change?:** To keep the code organized and more maintainable. **test plan:** Manual testing. **issue:** Checklist item on gatsby docs update wiki; https://github.com/bvaughn/react/wiki/Gatsby-check-list misc > Properly handle tabbed content on /docs/installation.html
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!
display('target', nextTab); | ||
} | ||
} | ||
window.keyToggle = keyToggle; |
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.
Whoops! I missed this.
We can't have window
references in code that's auto-executed as part of an import b'c they break the Gatsby build
step. I'll remove this one! 😄
defaultActiveSection={findSectionForPath( | ||
location.pathname, | ||
sectionList, | ||
)} |
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.
Same here as with window
. Should be:
defaultActiveSection={
location != null
? findSectionForPath(location.pathname, sectionList)
: null
}
We also need to pull location
from Gatsby rather than relying on the global.
My bad for overlooking.
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 - good to know!
problem:
The old "installation" page relied on HTML with inline CSS and JS, and the JS doesn't work with our new site infrastructure.
Specifically, there were some tabs which switched the content and they are not working in the new docs site.
We are trying to make minimal changes to the markdown docs files, because we want to minimize merge conflicts and also not interfere with an ongoing i18n project.
solution:
Made minimal changes to the installation docs file in 'docs';
Then we made a hacky custom component and moved the tab JS there, mostly unchanged.
Ideally we do a follow-up pass and completely move the styles and JS out of 'docs/docs/installation.md' and clean this up. But for now it's similar to other work-arounds in place for this docs rewrite.