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