add an option for menu toggle

This commit is contained in:
leoliu 2019-07-11 17:25:13 +08:00
parent 65ccebd9e2
commit 2f80394e3c
3 changed files with 10 additions and 3 deletions

View File

@ -53,7 +53,7 @@ export class Redoc extends React.Component<RedocProps> {
/> />
)) || )) ||
null} null}
<SideMenu menu={menu} /> <SideMenu menu={menu} menuToggle={options.menuToggle} />
</StickyResponsiveSidebar> </StickyResponsiveSidebar>
<ApiContentWrap className="api-content"> <ApiContentWrap className="api-content">
<ApiInfo store={store} /> <ApiInfo store={store} />

View File

@ -8,7 +8,11 @@ import { PerfectScrollbarWrap } from '../../common-elements/perfect-scrollbar';
import { RedocAttribution } from './styled.elements'; import { RedocAttribution } from './styled.elements';
@observer @observer
export class SideMenu extends React.Component<{ menu: MenuStore; className?: string }> { export class SideMenu extends React.Component<{
menu: MenuStore;
menuToggle?: boolean;
className?: string;
}> {
private _updateScroll?: () => void; private _updateScroll?: () => void;
render() { render() {
@ -32,7 +36,7 @@ export class SideMenu extends React.Component<{ menu: MenuStore; className?: str
} }
activate = (item: IMenuItem) => { activate = (item: IMenuItem) => {
if (item && item.active) { if (item && item.active && this.props.menuToggle) {
return item.expanded ? item.collapse() : item.expand(); return item.expanded ? item.collapse() : item.expand();
} }

View File

@ -22,6 +22,7 @@ export interface RedocRawOptions {
onlyRequiredInSamples?: boolean | string; onlyRequiredInSamples?: boolean | string;
showExtensions?: boolean | string | string[]; showExtensions?: boolean | string | string[];
hideSingleRequestSampleTab?: boolean | string; hideSingleRequestSampleTab?: boolean | string;
menuToggle?: boolean | string;
unstable_ignoreMimeParameters?: boolean; unstable_ignoreMimeParameters?: boolean;
@ -125,6 +126,7 @@ export class RedocNormalizedOptions {
onlyRequiredInSamples: boolean; onlyRequiredInSamples: boolean;
showExtensions: boolean | string[]; showExtensions: boolean | string[];
hideSingleRequestSampleTab: boolean; hideSingleRequestSampleTab: boolean;
menuToggle: boolean;
/* tslint:disable-next-line */ /* tslint:disable-next-line */
unstable_ignoreMimeParameters: boolean; unstable_ignoreMimeParameters: boolean;
@ -156,6 +158,7 @@ export class RedocNormalizedOptions {
this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples); this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples);
this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions); this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions);
this.hideSingleRequestSampleTab = argValueToBoolean(raw.hideSingleRequestSampleTab); this.hideSingleRequestSampleTab = argValueToBoolean(raw.hideSingleRequestSampleTab);
this.menuToggle = argValueToBoolean(raw.menuToggle);
this.unstable_ignoreMimeParameters = argValueToBoolean(raw.unstable_ignoreMimeParameters); this.unstable_ignoreMimeParameters = argValueToBoolean(raw.unstable_ignoreMimeParameters);