Skip to content
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

Merged
merged 6 commits into from
Sep 5, 2017
Merged

Conversation

flarnie
Copy link
Contributor

@flarnie flarnie commented Sep 2, 2017

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';

  • removed the non-functional inline JS
  • changed a couple of 'h2' to 'h3' (this made the styles look correct)
  • changed 'block' tags to 'section' and added wrapper divs (this made it render correctly)

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.

**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
@flarnie
Copy link
Contributor Author

flarnie commented Sep 2, 2017

screen shot 2017-09-01 at 4 37 34 pm

@flarnie flarnie changed the title Gatsby [docs update] fix tabs on 'installation' page Sep 2, 2017
@bvaughn bvaughn self-assigned this Sep 5, 2017
Copy link
Contributor

@bvaughn bvaughn left a 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.

/>
);
const Docs = ({data, location}) => {
console.log('location is ', location);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops ^

Copy link
Contributor Author

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

const Docs = ({data, location}) => {
console.log('location is ', location);
if (location.pathname === '/docs/installation.html') {
console.log('about to render InstallationPage');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops ^

);
const Docs = ({data, location}) => {
console.log('location is ', location);
if (location.pathname === '/docs/installation.html') {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

flarnie and others added 3 commits September 5, 2017 10:31
**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
Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bvaughn bvaughn merged commit 3a52e71 into facebook:gatsby Sep 5, 2017
display('target', nextTab);
}
}
window.keyToggle = keyToggle;
Copy link
Contributor

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,
)}
Copy link
Contributor

@bvaughn bvaughn Sep 6, 2017

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - good to know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants