mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-08 14:14:56 +03:00
search && collapse
This commit is contained in:
parent
f41965b059
commit
6a8843f23e
|
@ -10,6 +10,18 @@ export const PropertiesTableCaption = styled.caption`
|
||||||
color: ${props => props.theme.colors.text.secondary};
|
color: ${props => props.theme.colors.text.secondary};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const PropertyRow = styled.tr<{ kind?: string }>`
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.hidden,
|
||||||
|
&.hidden > td {
|
||||||
|
overflow: hidden;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
export const PropertyCell = styled.td<{ kind?: string }>`
|
export const PropertyCell = styled.td<{ kind?: string }>`
|
||||||
border-left: 1px solid ${props => props.theme.schema.linesColor};
|
border-left: 1px solid ${props => props.theme.schema.linesColor};
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
|
@ -5,6 +5,9 @@ export const SampleControls = styled.div`
|
||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
transition: opacity 0.3s ease;
|
transition: opacity 0.3s ease;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
position: absolute;
|
||||||
|
right: 30px;
|
||||||
|
z-index: 5;
|
||||||
|
|
||||||
> span {
|
> span {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
PropertyCellWithInner,
|
PropertyCellWithInner,
|
||||||
PropertyDetailsCell,
|
PropertyDetailsCell,
|
||||||
PropertyNameCell,
|
PropertyNameCell,
|
||||||
|
PropertyRow,
|
||||||
} from '../../common-elements/fields-layout';
|
} from '../../common-elements/fields-layout';
|
||||||
|
|
||||||
import { ShelfIcon } from '../../common-elements/';
|
import { ShelfIcon } from '../../common-elements/';
|
||||||
|
@ -27,14 +28,32 @@ export interface FieldProps extends SchemaOptions {
|
||||||
renderDiscriminatorSwitch?: (opts: FieldProps) => JSX.Element;
|
renderDiscriminatorSwitch?: (opts: FieldProps) => JSX.Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface FieldState {
|
||||||
|
expanded?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class Field extends React.Component<FieldProps> {
|
export class Field extends React.Component<FieldProps, FieldState> {
|
||||||
toggle = () => {
|
|
||||||
this.props.field.toggle();
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
expanded: false,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle = () => {
|
||||||
|
this.setState({ expanded: !this.state.expanded });
|
||||||
|
};
|
||||||
|
|
||||||
|
onFocus = () => {
|
||||||
|
this.setState({ expanded: true });
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { className, field, isLast } = this.props;
|
const { className, field, isLast } = this.props;
|
||||||
const { name, expanded, deprecated, required, kind } = field;
|
const { name, deprecated, required, kind } = field;
|
||||||
const withSubSchema = !field.schema.isPrimitive && !field.schema.isCircular;
|
const withSubSchema = !field.schema.isPrimitive && !field.schema.isCircular;
|
||||||
|
|
||||||
const paramName = withSubSchema ? (
|
const paramName = withSubSchema ? (
|
||||||
|
@ -46,7 +65,7 @@ export class Field extends React.Component<FieldProps> {
|
||||||
>
|
>
|
||||||
<PropertyBullet />
|
<PropertyBullet />
|
||||||
{name}
|
{name}
|
||||||
<ShelfIcon direction={expanded ? 'down' : 'right'} />
|
<ShelfIcon direction={this.state.expanded ? 'down' : 'right'} />
|
||||||
{!required && <OptionalLabel> optional </OptionalLabel>}
|
{!required && <OptionalLabel> optional </OptionalLabel>}
|
||||||
</ClickablePropertyNameCell>
|
</ClickablePropertyNameCell>
|
||||||
) : (
|
) : (
|
||||||
|
@ -65,8 +84,8 @@ export class Field extends React.Component<FieldProps> {
|
||||||
<FieldDetails {...this.props} />
|
<FieldDetails {...this.props} />
|
||||||
</PropertyDetailsCell>
|
</PropertyDetailsCell>
|
||||||
</tr>
|
</tr>
|
||||||
{field.expanded && withSubSchema && (
|
{withSubSchema && (
|
||||||
<tr key={field.name + 'inner'}>
|
<PropertyRow className={ this.state.expanded ? 'visible' : 'hidden' } key={field.name + 'inner'} onFocus={ this.onFocus } tabIndex={1} >
|
||||||
<PropertyCellWithInner colSpan={2}>
|
<PropertyCellWithInner colSpan={2}>
|
||||||
<InnerPropertiesWrap>
|
<InnerPropertiesWrap>
|
||||||
<Schema
|
<Schema
|
||||||
|
@ -77,7 +96,7 @@ export class Field extends React.Component<FieldProps> {
|
||||||
/>
|
/>
|
||||||
</InnerPropertiesWrap>
|
</InnerPropertiesWrap>
|
||||||
</PropertyCellWithInner>
|
</PropertyCellWithInner>
|
||||||
</tr>
|
</PropertyRow>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -5,8 +5,12 @@ import styled from '../../styled-components';
|
||||||
import { StyledDropdown } from '../../common-elements';
|
import { StyledDropdown } from '../../common-elements';
|
||||||
|
|
||||||
export const MimeLabel = styled.div`
|
export const MimeLabel = styled.div`
|
||||||
border-bottom: 1px solid #c2c2c2;
|
position: relative;
|
||||||
margin: 0 0 10px 0;
|
top: -35px;
|
||||||
|
left: 132px;
|
||||||
|
margin: 0;
|
||||||
|
font-size: 0.929em;
|
||||||
|
color: #000;
|
||||||
display: block;
|
display: block;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import { Tab, TabList, TabPanel, Tabs, UnderlinedHeader } from '../../common-elements';
|
||||||
import { OperationModel } from '../../services/models';
|
import { OperationModel } from '../../services/models';
|
||||||
import { PayloadSamples } from '../PayloadSamples/PayloadSamples';
|
import { PayloadSamples } from '../PayloadSamples/PayloadSamples';
|
||||||
import { SourceCodeWithCopy } from '../SourceCode/SourceCode';
|
import { SourceCodeWithCopy } from '../SourceCode/SourceCode';
|
||||||
|
|
||||||
import { RightPanelHeader, Tab, TabList, TabPanel, Tabs } from '../../common-elements';
|
|
||||||
|
|
||||||
export interface RequestSamplesProps {
|
export interface RequestSamplesProps {
|
||||||
operation: OperationModel;
|
operation: OperationModel;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +23,7 @@ export class RequestSamples extends React.Component<RequestSamplesProps> {
|
||||||
return (
|
return (
|
||||||
(hasSamples && (
|
(hasSamples && (
|
||||||
<div>
|
<div>
|
||||||
<RightPanelHeader> Request </RightPanelHeader>
|
<UnderlinedHeader key="header"> Request Example: </UnderlinedHeader>
|
||||||
|
|
||||||
{samples.length > 0 ?
|
{samples.length > 0 ?
|
||||||
<Tabs defaultIndex={0}>
|
<Tabs defaultIndex={0}>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user