-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(docs): Fixing doc navigation link issues #2760
fix(docs): Fixing doc navigation link issues #2760
Conversation
💖 Thanks for opening this pull request! 💖 Here is a list of things that will help get it across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
Codecov Report
@@ Coverage Diff @@
## master #2760 +/- ##
=======================================
Coverage 99.74% 99.74%
=======================================
Files 160 160
Lines 2762 2762
=======================================
Hits 2755 2755
Misses 7 7 Continue to review full report at Codecov.
|
@@ -441,7 +441,7 @@ class ComponentExample extends Component { | |||
} | |||
|
|||
return ( | |||
<Visibility once={false} onTopPassed={this.handlePass} onTopPassedReverse={this.handlePass}> |
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 right menu no longer updates as the user scrolls. These handlers enabled that functionality.
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.
Oh! I didn't check that. Thank you for pointing it out. I'll look into it.
And, all your comments make sense to me, I'll fix them.
@@ -52,7 +62,7 @@ class ComponentSidebarSection extends Component { | |||
<Accordion.Content as={Menu.Menu} active={active}> | |||
{_.map(examples, ({ title, path }) => ( | |||
<ComponentSidebarItem | |||
active={activePath === path} | |||
active={activePath === _.kebabCase(path.split('/').join(' '))} |
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 utility function would be used here as well.
|
||
isActiveAccordion = (props = this.props) => | ||
(props.examples || []).findIndex( | ||
item => _.kebabCase(item.path.split('/').join(' ')) === props.activePath, |
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 utility function would be used here.
@@ -68,14 +76,28 @@ class ComponentDoc extends Component { | |||
|
|||
handleSidebarItemClick = (e, { path }) => { | |||
const { history } = this.props | |||
const aPath = _.kebabCase(_.last(path.split('/'))) | |||
const aPath = _.kebabCase(path.split('/').join(' ')) |
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 pull this into a utility function in docs/apps/utils
. Something like createComponentHash()
. It would be ideal to be able to pass an example filename or file path to a single function that knows how to create the hash. This way it can be used everywhere we are constructing the hash.
Also, we need to add redirects from the old hashes to the new hashes. A utility function could be used for transforming the old hashes to the new hashes as well.
@@ -71,7 +71,7 @@ class ComponentExample extends Component { | |||
const { examplePath, location } = this.props | |||
const sourceCode = this.getOriginalSourceCode() | |||
|
|||
this.anchorName = _.kebabCase(_.last(examplePath.split('/'))) | |||
this.anchorName = _.kebabCase(examplePath.split('/').join(' ')) |
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 would be the utility function as well.
this.state = { | ||
activePath, | ||
} | ||
} |
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.
Prefer property initializer for state unless props
are needed to calculate state:
state = {
activePath: _.last((location.hash || '').split('#'))
}
We have some unnecessary duplication in the hash. Let's minimize these in this PR. We can remove the pathname and Current
Proposed
Comparison
|
Regarding unnecessary duplication in the hash, do you want me to rename examplePath property in As we are proposing minimized hash string, we should make sure that there won't be any collisions. And, I'm wondering about redirection utility, I think there is no way to map from old hash to new hash as there is no single source of truth. For ex, old hash is |
I don't quite understand this one. The
We only have duplications when there is an example in more than one section for the same prop. By adding the section (type, state, variation, etc) to the hash we are avoiding any duplicates. Any duplicate examples for the same prop within the same category are true duplicate examples and should be merged.
The old hashes are just the example's filename. We can We will not be able to resolve old and conflicting hashes (e.g. table collapsing) to know which section is correct (e.g. variations or types) but we can resolve all others correctly. Even in the case of conflicting example names, we will still resolve it to the new location, we just will have the wrong section sometimes. Regarding the new hash. We should be able to create |
I don't quite understand this one. The examplePath is set to match the directory structure and should remain as-is. The folder structure, examplePath values, and docgenInfo.json will all remain the same. We'll only use the util function when creating hashes. I might need more info here.
Regarding the new hash. We should be able to create collections/table#variations-collapsing on the first pass without creating /collections/table#collections-table-variations-table-example-collapsing as a prerequisite.
|
Got it, looking forward to it. |
@levithomason I've fixed code review comments and also created necessary utility functions to
|
@levithomason could you please review this PR? |
Apologies for the delay. I've merged master and I am reviewing this now. |
b27f077
to
684082f
Compare
Released in |
Fixed #2737 issue. Please review and let me know your comments.