From 2f80394e3cd821332d68f5247958a1c52ce3d170 Mon Sep 17 00:00:00 2001 From: leoliu Date: Thu, 11 Jul 2019 17:25:13 +0800 Subject: [PATCH] add an option for menu toggle --- src/components/Redoc/Redoc.tsx | 2 +- src/components/SideMenu/SideMenu.tsx | 8 ++++++-- src/services/RedocNormalizedOptions.ts | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/Redoc/Redoc.tsx b/src/components/Redoc/Redoc.tsx index 2b43e77d..f734e689 100644 --- a/src/components/Redoc/Redoc.tsx +++ b/src/components/Redoc/Redoc.tsx @@ -53,7 +53,7 @@ export class Redoc extends React.Component { /> )) || null} - + diff --git a/src/components/SideMenu/SideMenu.tsx b/src/components/SideMenu/SideMenu.tsx index 2ef083d6..47df1557 100644 --- a/src/components/SideMenu/SideMenu.tsx +++ b/src/components/SideMenu/SideMenu.tsx @@ -8,7 +8,11 @@ import { PerfectScrollbarWrap } from '../../common-elements/perfect-scrollbar'; import { RedocAttribution } from './styled.elements'; @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; render() { @@ -32,7 +36,7 @@ export class SideMenu extends React.Component<{ menu: MenuStore; className?: str } activate = (item: IMenuItem) => { - if (item && item.active) { + if (item && item.active && this.props.menuToggle) { return item.expanded ? item.collapse() : item.expand(); } diff --git a/src/services/RedocNormalizedOptions.ts b/src/services/RedocNormalizedOptions.ts index 7c893f1b..c5ef8f95 100644 --- a/src/services/RedocNormalizedOptions.ts +++ b/src/services/RedocNormalizedOptions.ts @@ -22,6 +22,7 @@ export interface RedocRawOptions { onlyRequiredInSamples?: boolean | string; showExtensions?: boolean | string | string[]; hideSingleRequestSampleTab?: boolean | string; + menuToggle?: boolean | string; unstable_ignoreMimeParameters?: boolean; @@ -125,6 +126,7 @@ export class RedocNormalizedOptions { onlyRequiredInSamples: boolean; showExtensions: boolean | string[]; hideSingleRequestSampleTab: boolean; + menuToggle: boolean; /* tslint:disable-next-line */ unstable_ignoreMimeParameters: boolean; @@ -156,6 +158,7 @@ export class RedocNormalizedOptions { this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples); this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions); this.hideSingleRequestSampleTab = argValueToBoolean(raw.hideSingleRequestSampleTab); + this.menuToggle = argValueToBoolean(raw.menuToggle); this.unstable_ignoreMimeParameters = argValueToBoolean(raw.unstable_ignoreMimeParameters);