mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-08 14:14:56 +03:00
Basic implementation finished
This commit is contained in:
parent
b10616c340
commit
0623298d0d
|
@ -21,10 +21,8 @@ const demos = [
|
|||
|
||||
const DEFAULT_SPEC = 'openapi.yaml';
|
||||
|
||||
class DemoApp extends React.Component<
|
||||
{},
|
||||
{ specUrl: string; dropdownOpen: boolean; cors: boolean }
|
||||
> {
|
||||
class DemoApp extends React.Component<{},
|
||||
{ specUrl: string; dropdownOpen: boolean; cors: boolean }> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
|
@ -104,7 +102,7 @@ class DemoApp extends React.Component<
|
|||
height="30px"
|
||||
/>
|
||||
</Heading>
|
||||
<RedocStandalone specUrl={proxiedUrl} options={{ scrollYOffset: 'nav' }} />
|
||||
<RedocStandalone specUrl={proxiedUrl} options={{scrollYOffset: 'nav', disableInfiniteScroll: true}}/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
import {observer} from 'mobx-react';
|
||||
import * as React from 'react';
|
||||
import {IMenuItem, MenuStore} from '../../services';
|
||||
import {ContentItems} from './ContentItems';
|
||||
|
||||
@observer
|
||||
export class SingleContentItem extends React.Component<{
|
||||
menu: MenuStore;
|
||||
}> {
|
||||
|
||||
extractActive(menu: MenuStore): IMenuItem[] {
|
||||
const active = menu.flatItems[menu.activeItemIdx];
|
||||
if (!active) {
|
||||
return [menu.flatItems[0]];
|
||||
}
|
||||
if (active.type !== 'operation') {
|
||||
return [
|
||||
{...active, items: []},
|
||||
];
|
||||
}
|
||||
return [active];
|
||||
}
|
||||
|
||||
render() {
|
||||
const { menu } = this.props;
|
||||
const activeItems = this.extractActive(menu);
|
||||
return (
|
||||
<ContentItems items={activeItems as any} />
|
||||
);
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ import { SideMenu } from '../SideMenu/SideMenu';
|
|||
import { StickyResponsiveSidebar } from '../StickySidebar/StickyResponsiveSidebar';
|
||||
import { ApiContentWrap, BackgroundStub, RedocWrap } from './styled.elements';
|
||||
|
||||
import {SingleContentItem} from '../ContentItems/SingleContentItem';
|
||||
import { SearchBox } from '../SearchBox/SearchBox';
|
||||
import { StoreProvider } from '../StoreBuilder';
|
||||
|
||||
|
@ -57,7 +58,10 @@ export class Redoc extends React.Component<RedocProps> {
|
|||
</StickyResponsiveSidebar>
|
||||
<ApiContentWrap className="api-content">
|
||||
<ApiInfo store={store} />
|
||||
<ContentItems items={menu.items as any} />
|
||||
{options.disableInfiniteScroll
|
||||
? <SingleContentItem menu={menu}/>
|
||||
: <ContentItems items={menu.items as any}/>
|
||||
}
|
||||
</ApiContentWrap>
|
||||
<BackgroundStub />
|
||||
</RedocWrap>
|
||||
|
|
|
@ -18,13 +18,13 @@ export class ScrollService {
|
|||
|
||||
bind() {
|
||||
this._prevOffsetY = this.scrollY();
|
||||
if (this._scrollParent) {
|
||||
if (this._scrollParent && !this.options.disableInfiniteScroll) {
|
||||
this._scrollParent.addEventListener('scroll', this.handleScroll);
|
||||
}
|
||||
}
|
||||
|
||||
dispose() {
|
||||
if (this._scrollParent) {
|
||||
if (this._scrollParent && !this.options.disableInfiniteScroll) {
|
||||
this._scrollParent.removeEventListener('scroll', this.handleScroll);
|
||||
}
|
||||
this._emiter.removeAllListeners(EVENT);
|
||||
|
|
Loading…
Reference in New Issue
Block a user