reskin documentation

This commit is contained in:
Ray Ventura 2019-06-25 20:49:41 -07:00
parent 8df116284f
commit a60a222bfc
12 changed files with 28 additions and 65 deletions

View File

@ -12,7 +12,7 @@ export const PropertiesTableCaption = styled.caption`
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};
border-bottom: 1px solid #e3e8ee; border-top: 1px solid #e3e8ee;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
padding: 10px 10px 10px 0; padding: 10px 10px 10px 0;
@ -55,7 +55,7 @@ export const PropertyCell = styled.td<{ kind?: string }>`
} }
tr.expanded & { tr.expanded & {
border-bottom: none; border-top: none;
} }
`; `;
@ -68,7 +68,8 @@ export const PropertyNameCell = styled(PropertyCell)`
line-height: 20px; line-height: 20px;
white-space: nowrap; white-space: nowrap;
font-size: 0.929em; font-size: 0.929em;
font-family: ${props => props.theme.typography.headings.fontFamily}; font-weight: bold;
font-family: Courier,monospace;
&.deprecated { &.deprecated {
${deprecatedCss}; ${deprecatedCss};
@ -80,13 +81,13 @@ export const PropertyNameCell = styled(PropertyCell)`
`; `;
export const PropertyDetailsCell = styled.td` export const PropertyDetailsCell = styled.td`
border-bottom: 1px solid #e3e8ee; border-top: 1px solid #e3e8ee;
padding: 10px 0; padding: 10px 0;
width: ${props => props.theme.schema.defaultDetailsWidth}; width: ${props => props.theme.schema.defaultDetailsWidth};
box-sizing: border-box; box-sizing: border-box;
tr.expanded & { tr.expanded & {
border-bottom: none; border-top: none;
} }
`; `;
@ -126,6 +127,10 @@ export const PropertiesTable = styled.table`
border-spacing: 0; border-spacing: 0;
width: 100%; width: 100%;
tr:first-child td {
border-top: none;
}
> tr { > tr {
vertical-align: middle; vertical-align: middle;
} }

View File

@ -18,6 +18,8 @@ export const ClickablePropertyNameCell = styled(PropertyNameCell)`
export const FieldLabel = styled.span` export const FieldLabel = styled.span`
vertical-align: middle; vertical-align: middle;
text-transform: uppercase;
font-family: ${({ theme }) => theme.typography.headings.fontFamily};
font-size: ${({ theme }) => theme.typography.code.fontSize}; font-size: ${({ theme }) => theme.typography.code.fontSize};
line-height: 20px; line-height: 20px;
`; `;

View File

@ -15,7 +15,7 @@ export const MiddlePanel = styled.div`
export const Section = styled.div.attrs(props => ({ export const Section = styled.div.attrs(props => ({
[SECTION_ATTR]: props.id, [SECTION_ATTR]: props.id,
})) <{ underlined?: boolean }>` })) <{ underlined?: boolean }>`
padding: 0 0 ${props => props.theme.spacing.sectionVertical}px 0; padding: 20px 0 ${props => props.theme.spacing.sectionVertical}px 0;
border-bottom: 1px solid #e3e8ee; border-bottom: 1px solid #e3e8ee;
&:last-child { &:last-child {
min-height: calc(100vh + 1px); min-height: calc(100vh + 1px);

View File

@ -1,5 +1,4 @@
import * as React from 'react'; import * as React from 'react';
import { ShelfIcon } from '../../common-elements';
import { OperationModel } from '../../services'; import { OperationModel } from '../../services';
import { Markdown } from '../Markdown/Markdown'; import { Markdown } from '../Markdown/Markdown';
import { OptionsContext } from '../OptionsProvider'; import { OptionsContext } from '../OptionsProvider';
@ -48,16 +47,9 @@ export class Endpoint extends React.Component<EndpointProps, EndpointState> {
<OptionsContext.Consumer> <OptionsContext.Consumer>
{options => ( {options => (
<OperationEndpointWrap> <OperationEndpointWrap>
<EndpointInfo onClick={this.toggle} expanded={expanded} inverted={inverted}> <EndpointInfo expanded={expanded} inverted={inverted}>
<HttpVerb type={operation.httpVerb}> {operation.httpVerb}</HttpVerb>{' '} <HttpVerb type={operation.httpVerb}> {operation.httpVerb}</HttpVerb>{' '}
<ServerRelativeURL>{operation.path}</ServerRelativeURL> <ServerRelativeURL>{operation.path}</ServerRelativeURL>
<ShelfIcon
float={'right'}
color={inverted ? 'black' : 'white'}
size={'20px'}
direction={expanded ? 'up' : 'down'}
style={{ marginRight: '-25px' }}
/>
</EndpointInfo> </EndpointInfo>
<ServersOverlay expanded={expanded}> <ServersOverlay expanded={expanded}>
{operation.servers.map(server => ( {operation.servers.map(server => (

View File

@ -3,7 +3,7 @@ import styled from '../../styled-components';
export const OperationEndpointWrap = styled.div` export const OperationEndpointWrap = styled.div`
cursor: pointer; cursor: pointer;
position: relative; position: relative;
margin-bottom: 5px; margin: 60px 0px 0px 0px;
`; `;
export const ServerRelativeURL = styled.span` export const ServerRelativeURL = styled.span`
@ -17,8 +17,7 @@ export const ServerRelativeURL = styled.span`
export const EndpointInfo = styled.div<{ expanded?: boolean; inverted?: boolean }>` export const EndpointInfo = styled.div<{ expanded?: boolean; inverted?: boolean }>`
padding: 10px 30px 10px ${props => (props.inverted ? '10px' : '20px')}; padding: 10px 30px 10px ${props => (props.inverted ? '10px' : '20px')};
border-radius: ${props => (props.inverted ? '0' : '4px 4px 0 0')}; border-radius: ${props => (props.inverted ? '0' : '4px 4px 0 0')};
background-color: ${props => background-color: #3c4257;
props.inverted ? 'transparent' : props.theme.codeSample.backgroundColor};
display: flex; display: flex;
white-space: nowrap; white-space: nowrap;
align-items: center; align-items: center;
@ -36,10 +35,9 @@ export const EndpointInfo = styled.div<{ expanded?: boolean; inverted?: boolean
export const HttpVerb = styled.span.attrs((props: { type: string }) => ({ export const HttpVerb = styled.span.attrs((props: { type: string }) => ({
className: `http-verb ${props.type}`, className: `http-verb ${props.type}`,
}))<{ type: string }>` })) <{ type: string }>`
font-size: 0.929em; font-size: 0.929em;
line-height: 20px; line-height: 20px;
background-color: ${(props: any) => props.theme.colors.http[props.type] || '#999999'};
color: #ffffff; color: #ffffff;
padding: 3px 10px; padding: 3px 10px;
text-transform: uppercase; text-transform: uppercase;

View File

@ -4,7 +4,7 @@ import { OperationModel, RedocNormalizedOptions } from '../../services';
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'; import { Tab, TabList, TabPanel, Tabs } from '../../common-elements';
import { OptionsContext } from '../OptionsProvider'; import { OptionsContext } from '../OptionsProvider';
export interface RequestSamplesProps { export interface RequestSamplesProps {
@ -24,15 +24,10 @@ export class RequestSamples extends React.Component<RequestSamplesProps> {
const samples = operation.codeSamples; const samples = operation.codeSamples;
const hasSamples = hasBodySample || samples.length > 0; const hasSamples = hasBodySample || samples.length > 0;
const hideTabList = const hideTabList = true;
samples.length + (hasBodySample ? 1 : 0) === 1
? this.context.hideSingleRequestSampleTab
: false;
return ( return (
(hasSamples && ( (hasSamples && (
<div> <div>
<RightPanelHeader> Request samples </RightPanelHeader>
<Tabs defaultIndex={0}> <Tabs defaultIndex={0}>
<TabList hidden={hideTabList}> <TabList hidden={hideTabList}>
{hasBodySample && <Tab key="payload"> Payload </Tab>} {hasBodySample && <Tab key="payload"> Payload </Tab>}

View File

@ -3,7 +3,7 @@ import * as React from 'react';
import { OperationModel } from '../../services/models'; import { OperationModel } from '../../services/models';
import { RightPanelHeader, Tab, TabList, TabPanel, Tabs } from '../../common-elements'; import { Tab, TabList, TabPanel, Tabs } from '../../common-elements';
import { PayloadSamples } from '../PayloadSamples/PayloadSamples'; import { PayloadSamples } from '../PayloadSamples/PayloadSamples';
export interface ResponseSamplesProps { export interface ResponseSamplesProps {
@ -23,8 +23,6 @@ export class ResponseSamples extends React.Component<ResponseSamplesProps> {
return ( return (
(responses.length > 0 && ( (responses.length > 0 && (
<div> <div>
<RightPanelHeader> Response samples </RightPanelHeader>
<Tabs defaultIndex={0}> <Tabs defaultIndex={0}>
<TabList> <TabList>
{responses.map(response => ( {responses.map(response => (

View File

@ -3,7 +3,7 @@ import * as React from 'react';
import { ResponseModel } from '../../services/models'; import { ResponseModel } from '../../services/models';
import { ResponseDetails } from './ResponseDetails'; import { ResponseDetails } from './ResponseDetails';
import { ResponseDetailsWrap, StyledResponseTitle } from './styled.elements'; import { ResponseDetailsWrap } from './styled.elements';
@observer @observer
export class ResponseView extends React.Component<{ response: ResponseModel }> { export class ResponseView extends React.Component<{ response: ResponseModel }> {
@ -12,7 +12,7 @@ export class ResponseView extends React.Component<{ response: ResponseModel }> {
}; };
render() { render() {
const { headers, type, summary, description, code, expanded, content } = this.props.response; const { headers, description, expanded, content } = this.props.response;
const mimes = const mimes =
content === undefined ? [] : content.mediaTypes.filter(mime => mime.schema !== undefined); content === undefined ? [] : content.mediaTypes.filter(mime => mime.schema !== undefined);
@ -20,14 +20,6 @@ export class ResponseView extends React.Component<{ response: ResponseModel }> {
return ( return (
<div> <div>
<StyledResponseTitle
onClick={this.toggle}
type={type}
empty={empty}
title={summary || ''}
code={code}
opened={expanded}
/>
{expanded && {expanded &&
!empty && ( !empty && (
<ResponseDetailsWrap> <ResponseDetailsWrap>

View File

@ -1,6 +1,5 @@
import * as React from 'react'; import * as React from 'react';
import { ShelfIcon } from '../../common-elements';
import { Markdown } from '../Markdown/Markdown'; import { Markdown } from '../Markdown/Markdown';
export interface ResponseTitleProps { export interface ResponseTitleProps {
@ -15,17 +14,9 @@ export interface ResponseTitleProps {
export class ResponseTitle extends React.PureComponent<ResponseTitleProps> { export class ResponseTitle extends React.PureComponent<ResponseTitleProps> {
render() { render() {
const { title, type, empty, code, opened, className, onClick } = this.props; const { title, empty, code, className, onClick } = this.props;
return ( return (
<div className={className} onClick={(!empty && onClick) || undefined}> <div className={className} onClick={(!empty && onClick) || undefined}>
{!empty && (
<ShelfIcon
size={'1.5em'}
color={type}
direction={opened ? 'up' : 'down'}
float={'left'}
/>
)}
<strong>{code} </strong> <strong>{code} </strong>
<Markdown compact={true} inline={true} source={title} /> <Markdown compact={true} inline={true} source={title} />
</div> </div>

View File

@ -1,16 +1,7 @@
import * as React from 'react'; import * as React from 'react';
import { ResponseModel } from '../../services/models'; import { ResponseModel } from '../../services/models';
import styled from '../../styled-components';
import { ResponseView } from './Response'; import { ResponseView } from './Response';
const ResponsesHeader = styled.h3`
font-size: 18px;
padding: 0.2em 0;
margin: 3em 0 1.1em;
color: #253137;
font-weight: normal;
`;
export interface ResponseListProps { export interface ResponseListProps {
responses: ResponseModel[]; responses: ResponseModel[];
} }
@ -25,7 +16,6 @@ export class ResponsesList extends React.PureComponent<ResponseListProps> {
return ( return (
<div> <div>
<ResponsesHeader> Responses </ResponsesHeader>
{responses.map(response => { {responses.map(response => {
return <ResponseView key={response.code} response={response} />; return <ResponseView key={response.code} response={response} />;
})} })}

View File

@ -26,7 +26,7 @@ export class ResponseModel {
infoOrRef: Referenced<OpenAPIResponse>, infoOrRef: Referenced<OpenAPIResponse>,
options: RedocNormalizedOptions, options: RedocNormalizedOptions,
) { ) {
this.expanded = options.expandResponses === 'all' || options.expandResponses[code]; this.expanded = true;
const info = parser.deref(infoOrRef); const info = parser.deref(infoOrRef);
parser.exitRef(infoOrRef); parser.exitRef(infoOrRef);

View File

@ -4,7 +4,7 @@ const defaultTheme: ThemeInterface = {
spacing: { spacing: {
unit: 5, unit: 5,
sectionHorizontal: ({ spacing }) => spacing.unit * 8, sectionHorizontal: ({ spacing }) => spacing.unit * 8,
sectionVertical: ({ spacing }) => spacing.unit * 8, sectionVertical: ({ spacing }) => spacing.unit * 20,
}, },
breakpoints: { breakpoints: {
small: '50rem', small: '50rem',
@ -81,7 +81,7 @@ const defaultTheme: ThemeInterface = {
typeNameColor: theme => theme.colors.text.secondary, typeNameColor: theme => theme.colors.text.secondary,
typeTitleColor: theme => theme.schema.typeNameColor, typeTitleColor: theme => theme.schema.typeNameColor,
requireLabelColor: theme => theme.colors.error.main, requireLabelColor: theme => theme.colors.error.main,
labelsTextSize: '0.9em', labelsTextSize: '0.7em',
nestingSpacing: '1em', nestingSpacing: '1em',
nestedBackground: '#ffffff', nestedBackground: '#ffffff',
arrow: { arrow: {
@ -90,7 +90,7 @@ const defaultTheme: ThemeInterface = {
}, },
}, },
typography: { typography: {
fontSize: '16px', fontSize: '14px',
lineHeight: '1.6em', lineHeight: '1.6em',
fontWeightRegular: '400', fontWeightRegular: '400',
fontWeightBold: '600', fontWeightBold: '600',
@ -144,7 +144,7 @@ const defaultTheme: ThemeInterface = {
textColor: '#ffffff', textColor: '#ffffff',
}, },
codeSample: { codeSample: {
backgroundColor: ({ rightPanel }) => darken(0.1, rightPanel.backgroundColor), backgroundColor: '#4f566b',
}, },
}; };