fix: dropdown fixes related to object description

This commit is contained in:
Roman Hotsiy 2019-07-29 14:52:51 +03:00
parent 7883fad333
commit 0504ad4b76
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
4 changed files with 25 additions and 21 deletions

View File

@ -1,10 +1,12 @@
import * as React from 'react'; import * as React from 'react';
import { DarkRightPanel, MiddlePanel, Row, Section } from '../../common-elements'; import { DarkRightPanel, MiddlePanel, MimeLabel, Row, Section } from '../../common-elements';
import { MediaTypeModel, OpenAPIParser, RedocNormalizedOptions } from '../../services'; import { MediaTypeModel, OpenAPIParser, RedocNormalizedOptions } from '../../services';
import styled from '../../styled-components'; import styled from '../../styled-components';
import { OpenAPIMediaType } from '../../types'; import { OpenAPIMediaType } from '../../types';
import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
import { MediaTypeSamples } from '../PayloadSamples/MediaTypeSamples'; import { MediaTypeSamples } from '../PayloadSamples/MediaTypeSamples';
import { InvertedSimpleDropdown } from '../PayloadSamples/styled.elements';
import { Schema } from '../Schema'; import { Schema } from '../Schema';
export interface ObjectDescriptionProps { export interface ObjectDescriptionProps {
@ -64,13 +66,17 @@ export class ObjectDescription extends React.PureComponent<ObjectDescriptionProp
</MiddlePanel> </MiddlePanel>
<DarkRightPanel> <DarkRightPanel>
<MediaSamplesWrap> <MediaSamplesWrap>
<MediaTypeSamples mediaType={this.mediaModel} /> <MediaTypeSamples renderDropdown={this.renderDropdown} mediaType={this.mediaModel} />
</MediaSamplesWrap> </MediaSamplesWrap>
</DarkRightPanel> </DarkRightPanel>
</Row> </Row>
</Section> </Section>
); );
} }
private renderDropdown = props => {
return <DropdownOrLabel Label={MimeLabel} Dropdown={InvertedSimpleDropdown} {...props} />;
};
} }
const MediaSamplesWrap = styled.div` const MediaSamplesWrap = styled.div`

View File

@ -1,5 +1,7 @@
import * as React from 'react'; import * as React from 'react';
import styled from '../../styled-components';
import { DropdownProps } from '../../common-elements'; import { DropdownProps } from '../../common-elements';
import { MediaTypeModel } from '../../services/models'; import { MediaTypeModel } from '../../services/models';
import { Markdown } from '../Markdown/Markdown'; import { Markdown } from '../Markdown/Markdown';
@ -48,7 +50,7 @@ export class MediaTypeSamples extends React.Component<PayloadSamplesProps, Media
const description = example.description; const description = example.description;
return ( return (
<> <SamplesWrapper>
<DropdownWrapper> <DropdownWrapper>
<DropdownLabel>Example</DropdownLabel> <DropdownLabel>Example</DropdownLabel>
{this.props.renderDropdown({ {this.props.renderDropdown({
@ -61,16 +63,20 @@ export class MediaTypeSamples extends React.Component<PayloadSamplesProps, Media
{description && <Markdown source={description} />} {description && <Markdown source={description} />}
<Example example={example} mimeType={mimeType} /> <Example example={example} mimeType={mimeType} />
</div> </div>
</> </SamplesWrapper>
); );
} else { } else {
const example = examples[examplesNames[0]]; const example = examples[examplesNames[0]];
return ( return (
<div> <SamplesWrapper>
{example.description && <Markdown source={example.description} />} {example.description && <Markdown source={example.description} />}
<Example example={example} mimeType={mimeType} /> <Example example={example} mimeType={mimeType} />
</div> </SamplesWrapper>
); );
} }
} }
} }
const SamplesWrapper = styled.div`
margin-top: 15px;
`;

View File

@ -2,11 +2,9 @@ import { observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { MediaTypeSamples } from './MediaTypeSamples'; import { MediaTypeSamples } from './MediaTypeSamples';
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
import styled from '../../../src/styled-components';
import { MediaContentModel } from '../../services/models'; import { MediaContentModel } from '../../services/models';
import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel'; import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
import { InvertedSimpleDropdown, MimeLabel } from './styled.elements'; import { InvertedSimpleDropdown, MimeLabel } from './styled.elements';
export interface PayloadSamplesProps { export interface PayloadSamplesProps {
@ -24,13 +22,11 @@ export class PayloadSamples extends React.Component<PayloadSamplesProps> {
return ( return (
<MediaTypesSwitch content={mimeContent} renderDropdown={this.renderDropdown} withLabel={true}> <MediaTypesSwitch content={mimeContent} renderDropdown={this.renderDropdown} withLabel={true}>
{mediaType => ( {mediaType => (
<SamplesWrapper> <MediaTypeSamples
<MediaTypeSamples key="samples"
key="samples" mediaType={mediaType}
mediaType={mediaType} renderDropdown={this.renderDropdown}
renderDropdown={this.renderDropdown} />
/>
</SamplesWrapper>
)} )}
</MediaTypesSwitch> </MediaTypesSwitch>
); );
@ -40,7 +36,3 @@ export class PayloadSamples extends React.Component<PayloadSamplesProps> {
return <DropdownOrLabel Label={MimeLabel} Dropdown={InvertedSimpleDropdown} {...props} />; return <DropdownOrLabel Label={MimeLabel} Dropdown={InvertedSimpleDropdown} {...props} />;
}; };
} }
const SamplesWrapper = styled.div`
margin-top: 15px;
`;

View File

@ -53,7 +53,7 @@ export const InvertedSimpleDropdown = styled(StyledDropdown)`
} }
.Dropdown-menu { .Dropdown-menu {
margin: 0; margin: 0;
margin-top: 10px; margin-top: 2px;
} }
`; `;