Skip to content

Commit 0504ad4

Browse files
committed
fix: dropdown fixes related to object description
1 parent 7883fad commit 0504ad4

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

src/components/ObjectDescription/ObjectDescription.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import * as React from 'react';
22

3-
import { DarkRightPanel, MiddlePanel, Row, Section } from '../../common-elements';
3+
import { DarkRightPanel, MiddlePanel, MimeLabel, Row, Section } from '../../common-elements';
44
import { MediaTypeModel, OpenAPIParser, RedocNormalizedOptions } from '../../services';
55
import styled from '../../styled-components';
66
import { OpenAPIMediaType } from '../../types';
7+
import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
78
import { MediaTypeSamples } from '../PayloadSamples/MediaTypeSamples';
9+
import { InvertedSimpleDropdown } from '../PayloadSamples/styled.elements';
810
import { Schema } from '../Schema';
911

1012
export interface ObjectDescriptionProps {
@@ -64,13 +66,17 @@ export class ObjectDescription extends React.PureComponent<ObjectDescriptionProp
6466
</MiddlePanel>
6567
<DarkRightPanel>
6668
<MediaSamplesWrap>
67-
<MediaTypeSamples mediaType={this.mediaModel} />
69+
<MediaTypeSamples renderDropdown={this.renderDropdown} mediaType={this.mediaModel} />
6870
</MediaSamplesWrap>
6971
</DarkRightPanel>
7072
</Row>
7173
</Section>
7274
);
7375
}
76+
77+
private renderDropdown = props => {
78+
return <DropdownOrLabel Label={MimeLabel} Dropdown={InvertedSimpleDropdown} {...props} />;
79+
};
7480
}
7581

7682
const MediaSamplesWrap = styled.div`

src/components/PayloadSamples/MediaTypeSamples.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as React from 'react';
22

3+
import styled from '../../styled-components';
4+
35
import { DropdownProps } from '../../common-elements';
46
import { MediaTypeModel } from '../../services/models';
57
import { Markdown } from '../Markdown/Markdown';
@@ -48,7 +50,7 @@ export class MediaTypeSamples extends React.Component<PayloadSamplesProps, Media
4850
const description = example.description;
4951

5052
return (
51-
<>
53+
<SamplesWrapper>
5254
<DropdownWrapper>
5355
<DropdownLabel>Example</DropdownLabel>
5456
{this.props.renderDropdown({
@@ -61,16 +63,20 @@ export class MediaTypeSamples extends React.Component<PayloadSamplesProps, Media
6163
{description && <Markdown source={description} />}
6264
<Example example={example} mimeType={mimeType} />
6365
</div>
64-
</>
66+
</SamplesWrapper>
6567
);
6668
} else {
6769
const example = examples[examplesNames[0]];
6870
return (
69-
<div>
71+
<SamplesWrapper>
7072
{example.description && <Markdown source={example.description} />}
7173
<Example example={example} mimeType={mimeType} />
72-
</div>
74+
</SamplesWrapper>
7375
);
7476
}
7577
}
7678
}
79+
80+
const SamplesWrapper = styled.div`
81+
margin-top: 15px;
82+
`;

src/components/PayloadSamples/PayloadSamples.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import { observer } from 'mobx-react';
22
import * as React from 'react';
33
import { MediaTypeSamples } from './MediaTypeSamples';
44

5-
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
6-
7-
import styled from '../../../src/styled-components';
85
import { MediaContentModel } from '../../services/models';
96
import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
7+
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
108
import { InvertedSimpleDropdown, MimeLabel } from './styled.elements';
119

1210
export interface PayloadSamplesProps {
@@ -24,13 +22,11 @@ export class PayloadSamples extends React.Component<PayloadSamplesProps> {
2422
return (
2523
<MediaTypesSwitch content={mimeContent} renderDropdown={this.renderDropdown} withLabel={true}>
2624
{mediaType => (
27-
<SamplesWrapper>
28-
<MediaTypeSamples
29-
key="samples"
30-
mediaType={mediaType}
31-
renderDropdown={this.renderDropdown}
32-
/>
33-
</SamplesWrapper>
25+
<MediaTypeSamples
26+
key="samples"
27+
mediaType={mediaType}
28+
renderDropdown={this.renderDropdown}
29+
/>
3430
)}
3531
</MediaTypesSwitch>
3632
);
@@ -40,7 +36,3 @@ export class PayloadSamples extends React.Component<PayloadSamplesProps> {
4036
return <DropdownOrLabel Label={MimeLabel} Dropdown={InvertedSimpleDropdown} {...props} />;
4137
};
4238
}
43-
44-
const SamplesWrapper = styled.div`
45-
margin-top: 15px;
46-
`;

src/components/PayloadSamples/styled.elements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const InvertedSimpleDropdown = styled(StyledDropdown)`
5353
}
5454
.Dropdown-menu {
5555
margin: 0;
56-
margin-top: 10px;
56+
margin-top: 2px;
5757
}
5858
`;
5959

0 commit comments

Comments
 (0)