mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 16:46:34 +03:00
fix: dropdown fixes related to object description
This commit is contained in:
parent
7883fad333
commit
0504ad4b76
|
@ -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`
|
||||||
|
|
|
@ -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;
|
||||||
|
`;
|
||||||
|
|
|
@ -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;
|
|
||||||
`;
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ export const InvertedSimpleDropdown = styled(StyledDropdown)`
|
||||||
}
|
}
|
||||||
.Dropdown-menu {
|
.Dropdown-menu {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
margin-top: 10px;
|
margin-top: 2px;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user