-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Use an option usePathInSidebar #1805
Conversation
If this option is enabled, it displays a path in the sidebar instead of summary. Usage: ```js <RedocStandalone spec={props.spec} options={{ scrollYOffset:'.navbar', nativeScrollbars: true, usePathInSidebar:true }} ```
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.
Hi @kjhman21 . Thanks for your contribution. Can you rename usePathInSidebar
to sideNavStyle
. It will be enum of summary-only
and path-only
with default value summary-only
. We will add more options in the future.
@AlexVarchuk Thanks for the quick review! Updated as you requested. Please take another look. :) |
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 @kjhman21! It looks great! 💙
I left just a few tiny suggestions. Thanks in advance.
@@ -189,6 +206,7 @@ export class RedocNormalizedOptions { | |||
disableSearch: boolean; | |||
onlyRequiredInSamples: boolean; | |||
showExtensions: boolean | string[]; | |||
sideNavStyle: string; |
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.
But would be awesome to use string enums here: https://www.typescriptlang.org/docs/handbook/enums.html#string-enums
sideNavStyle: string; | |
sideNavStyle: 'summary-only' | 'path-only' |
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.
@RomanHotsiy
Actually, I didn't find string enums in the project. Could you suggest a good location to store enum definition?
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.
Or, just your suggestion is enough?
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, keep it as my suggestion for now. We'll add enums 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.
@RomanHotsiy It looks ugly, so I applied string enums. Please take another look. Thanks!
src/services/models/Operation.ts
Outdated
this.sidebarName = this.name; | ||
if (options.sideNavStyle === 'path-only') this.sidebarName = this.path; |
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.sidebarName = this.name; | |
if (options.sideNavStyle === 'path-only') this.sidebarName = this.path; | |
this.sidebarName = options.sideNavStyle === 'path-only' ? this.path : this.name; |
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.
applied as you suggested.
src/services/MenuStore.ts
Outdated
@@ -16,6 +16,7 @@ export interface IMenuItem { | |||
id: string; | |||
absoluteIdx?: number; | |||
name: string; | |||
sidebarName: string; |
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 would rename it to sidebarLabel
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.
applied as you suggested.
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 @kjhman21. Great job!
@AlexVarchuk merge whenever you're ready.
@RomanHotsiy @Oprysk @AlexVarchuk Thanks for approving this! @AlexVarchuk When can this be merged? I am really excited to use this feature on my project! |
@kjhman21 Sorry for the delay, we are going to release it today! |
What/Why/How?
We found an requirement that we want the path to be shown in the sidebar.
If this option is enabled, it displays a path in the sidebar instead of summary.
Usage:
Reference
Testing
Screenshots (optional)
sideNavStyle == 'summary-only'
sideNavStyle == 'path-only'
Check yourself