redoc/src/components/PayloadSamples/PayloadSamples.tsx

34 lines
1.0 KiB
TypeScript
Raw Normal View History

2017-10-12 00:01:37 +03:00
import { observer } from 'mobx-react';
2018-01-22 21:30:53 +03:00
import * as React from 'react';
import { MediaTypeSamples } from './MediaTypeSamples';
2017-10-12 00:01:37 +03:00
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
import { MediaContentModel } from '../../services/models';
import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
import { InvertedSimpleDropdown, MimeLabel } from './styled.elements';
export interface PayloadSamplesProps {
content: MediaContentModel;
}
@observer
export class PayloadSamples extends React.Component<PayloadSamplesProps> {
render() {
const mimeContent = this.props.content;
2018-01-22 21:30:53 +03:00
if (mimeContent === undefined) {
return null;
}
2017-10-12 00:01:37 +03:00
return (
2018-01-22 21:30:53 +03:00
<MediaTypesSwitch content={mimeContent} renderDropdown={this.renderDropdown}>
2017-10-12 00:01:37 +03:00
{mediaType => <MediaTypeSamples key="samples" mediaType={mediaType} />}
</MediaTypesSwitch>
);
}
2018-01-22 21:30:53 +03:00
private renderDropdown = props => {
return <DropdownOrLabel Label={MimeLabel} Dropdown={InvertedSimpleDropdown} {...props} />;
};
2017-10-12 00:01:37 +03:00
}