mirror of
https://github.com/Redocly/redoc.git
synced 2025-06-23 06:03:04 +03:00
78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
import * as PropTypes from 'prop-types';
|
|
import * as React from 'react';
|
|
|
|
import { ThemeProvider } from '../../styled-components';
|
|
import { OptionsProvider } from '../OptionsProvider';
|
|
|
|
import { AppStore } from '../../services';
|
|
|
|
import { ApiLogo } from '../ApiLogo/ApiLogo';
|
|
import { SideMenu } from '../SideMenu/SideMenu';
|
|
import { StickyResponsiveSidebar } from '../StickySidebar/StickyResponsiveSidebar';
|
|
import { ApiContentWrap, BackgroundStub, RedocWrap } from './styled.elements';
|
|
|
|
import { SearchBox } from '../SearchBox/SearchBox';
|
|
import { StoreProvider } from '../StoreBuilder';
|
|
import VirtualizedContent from '../Virtualization/VirtualizedContent';
|
|
import { ApiInfo } from '../ApiInfo/ApiInfo';
|
|
import { ContentItems } from '../ContentItems/ContentItems';
|
|
|
|
export interface RedocProps {
|
|
store: AppStore;
|
|
}
|
|
|
|
export class Redoc extends React.Component<RedocProps> {
|
|
static propTypes = {
|
|
store: PropTypes.instanceOf(AppStore).isRequired,
|
|
};
|
|
|
|
componentDidMount() {
|
|
this.props.store.onDidMount();
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this.props.store.dispose();
|
|
}
|
|
|
|
render() {
|
|
const {
|
|
store: { spec, menu, options, search, marker },
|
|
} = this.props;
|
|
const store = this.props.store;
|
|
return (
|
|
<ThemeProvider theme={options.theme}>
|
|
<StoreProvider value={store}>
|
|
<OptionsProvider value={options}>
|
|
<RedocWrap className="redoc-wrap">
|
|
<StickyResponsiveSidebar menu={menu} className="menu-content">
|
|
<ApiLogo info={spec.info} />
|
|
{(!options.disableSearch && (
|
|
<SearchBox
|
|
search={search!}
|
|
marker={marker}
|
|
getItemById={menu.getItemById}
|
|
onActivate={menu.activateAndScroll}
|
|
/>
|
|
)) ||
|
|
null}
|
|
<SideMenu menu={menu} />
|
|
</StickyResponsiveSidebar>
|
|
<ApiContentWrap className="api-content">
|
|
{options.enableVirtualization ? (
|
|
<VirtualizedContent store={store} menu={menu} />
|
|
) : (
|
|
<>
|
|
<ApiInfo store={store} />
|
|
<ContentItems items={menu.items as any} />
|
|
</>
|
|
)}
|
|
</ApiContentWrap>
|
|
<BackgroundStub />
|
|
</RedocWrap>
|
|
</OptionsProvider>
|
|
</StoreProvider>
|
|
</ThemeProvider>
|
|
);
|
|
}
|
|
}
|