feat: big theme update

This commit is contained in:
Roman Hotsiy 2018-07-19 13:05:53 +03:00
parent c5a352312a
commit 58bddc8811
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
25 changed files with 343 additions and 200 deletions

View File

@ -5,7 +5,7 @@ servers:
- url: //petstore.swagger.io/sandbox - url: //petstore.swagger.io/sandbox
description: Sandbox server description: Sandbox server
info: info:
description: > description: |
This is a sample server Petstore server. This is a sample server Petstore server.
You can find out more about Swagger at You can find out more about Swagger at
@ -58,6 +58,14 @@ info:
All responses have a wildcard same-origin which makes them completely public All responses have a wildcard same-origin which makes them completely public
and accessible to everyone, including any code on any site. and accessible to everyone, including any code on any site.
```json
{
"test": "value",
"test2": "value2"
}
```
# Authentication # Authentication
Petstore offers two forms of authentication: Petstore offers two forms of authentication:

View File

@ -19,10 +19,10 @@ export const StyledDropdown = withProps<DropdownProps>(styled(Dropdown))`
display: inline-block; display: inline-block;
position: relative; position: relative;
width: auto; width: auto;
font-family: ${props => props.theme.headingsFont.family}; font-family: ${props => props.theme.typography.headings.fontFamily};
.Dropdown-control { .Dropdown-control {
font-family: ${props => props.theme.headingsFont.family}; font-family: ${props => props.theme.typography.headings.fontFamily};
position: relative; position: relative;
font-size: .929em; font-size: .929em;
width: 100%; width: 100%;
@ -40,14 +40,14 @@ export const StyledDropdown = withProps<DropdownProps>(styled(Dropdown))`
background: white; background: white;
&:hover { &:hover {
border-color: ${props => props.theme.colors.main}; border-color: ${props => props.theme.colors.primary.main};
color: ${props => props.theme.colors.main}; color: ${props => props.theme.colors.primary.main};
box-shadow: 0px 2px 4px 0px rgba(34, 36, 38, 0.12); box-shadow: 0px 2px 4px 0px rgba(34, 36, 38, 0.12);
} }
} }
.Dropdown-arrow { .Dropdown-arrow {
border-color: ${props => props.theme.colors.main} transparent transparent; border-color: ${props => props.theme.colors.primary.main} transparent transparent;
border-style: solid; border-style: solid;
border-width: 0.35em 0.35em 0; border-width: 0.35em 0.35em 0;
content: ' '; content: ' ';

View File

@ -1,4 +1,4 @@
import { transparentize } from 'polished'; // import { transparentize } from 'polished';
import styled, { extensionsHook, withProps } from '../styled-components'; import styled, { extensionsHook, withProps } from '../styled-components';
import { deprecatedCss } from './mixins'; import { deprecatedCss } from './mixins';
@ -7,11 +7,11 @@ export const PropertiesTableCaption = styled.caption`
text-align: right; text-align: right;
font-size: 0.9em; font-size: 0.9em;
font-weight: normal; font-weight: normal;
color: ${props => transparentize(0.6, props.theme.colors.text)}; color: ${props => props.theme.colors.text.secondary};
`; `;
export const PropertyCell = styled.td` export const PropertyCell = styled.td`
border-left: 1px solid ${props => props.theme.schemaView.linesColor}; border-left: 1px solid ${props => props.theme.schema.linesColor};
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
padding: 10px 10px 10px 0; padding: 10px 10px 10px 0;
@ -29,16 +29,16 @@ export const PropertyCell = styled.td`
to bottom, to bottom,
transparent 0%, transparent 0%,
transparent 22px, transparent 22px,
${props => props.theme.schemaView.linesColor} 22px, ${props => props.theme.schema.linesColor} 22px,
${props => props.theme.schemaView.linesColor} 100% ${props => props.theme.schema.linesColor} 100%
); );
} }
tr.last > & { tr.last > & {
background-image: linear-gradient( background-image: linear-gradient(
to bottom, to bottom,
${props => props.theme.schemaView.linesColor} 0%, ${props => props.theme.schema.linesColor} 0%,
${props => props.theme.schemaView.linesColor} 22px, ${props => props.theme.schema.linesColor} 22px,
transparent 22px, transparent 22px,
transparent 100% transparent 100%
); );
@ -63,7 +63,7 @@ export const PropertyNameCell = withProps<{ kind?: string }>(PropertyCell.extend
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.headingsFont.family}; font-family: ${props => props.theme.typography.headings.fontFamily};
&.deprecated { &.deprecated {
${deprecatedCss}; ${deprecatedCss};
@ -77,7 +77,7 @@ export const PropertyNameCell = withProps<{ kind?: string }>(PropertyCell.extend
export const PropertyDetailsCell = styled.td` export const PropertyDetailsCell = styled.td`
border-bottom: 1px solid #9fb4be; border-bottom: 1px solid #9fb4be;
padding: 10px 0; padding: 10px 0;
width: ${props => props.theme.schemaView.defaultDetailsWidth}; width: ${props => props.theme.schema.defaultDetailsWidth};
box-sizing: border-box; box-sizing: border-box;
tr.expanded & { tr.expanded & {
@ -86,8 +86,8 @@ export const PropertyDetailsCell = styled.td`
`; `;
export const PropertyBullet = styled.span` export const PropertyBullet = styled.span`
color: ${props => props.theme.schemaView.linesColor}; color: ${props => props.theme.schema.linesColor};
font-family: ${props => props.theme.code.fontFamily}; font-family: ${props => props.theme.typography.code.fontFamily};
margin-right: 10px; margin-right: 10px;
&::before { &::before {
@ -96,7 +96,7 @@ export const PropertyBullet = styled.span`
vertical-align: middle; vertical-align: middle;
width: 10px; width: 10px;
height: 1px; height: 1px;
background: ${props => props.theme.schemaView.linesColor}; background: ${props => props.theme.schema.linesColor};
} }
&::after { &::after {
@ -104,19 +104,19 @@ export const PropertyBullet = styled.span`
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
width: 1px; width: 1px;
background: ${props => props.theme.schemaView.linesColor}; background: ${props => props.theme.schema.linesColor};
height: 7px; height: 7px;
} }
`; `;
export const InnerPropertiesWrap = styled.div` export const InnerPropertiesWrap = styled.div`
padding: ${({ theme }) => theme.schemaView.nestingSpacing}; padding: ${({ theme }) => theme.schema.nestingSpacing};
`; `;
export const PropertiesTable = styled.table` export const PropertiesTable = styled.table`
border-collapse: separate; border-collapse: separate;
border-radius: 3px; border-radius: 3px;
font-size: ${props => props.theme.baseFont.size}; font-size: ${props => props.theme.typography.fontSize};
border-spacing: 0; border-spacing: 0;
width: 100%; width: 100%;
@ -137,9 +137,9 @@ export const PropertiesTable = styled.table`
${InnerPropertiesWrap} ${InnerPropertiesWrap}
${InnerPropertiesWrap} ${InnerPropertiesWrap}
${InnerPropertiesWrap} { ${InnerPropertiesWrap} {
margin: ${({ theme }) => theme.schemaView.nestingSpacing}; margin: ${({ theme }) => theme.schema.nestingSpacing};
margin-right: 0; margin-right: 0;
background: #f0f0f0; background: ${({ theme }) => theme.schema.nestedBackground};
} }
& &

View File

@ -1,10 +1,19 @@
import { transparentize } from 'polished'; import { transparentize } from 'polished';
import styled from '../styled-components'; import styled, { extensionsHook } from '../styled-components';
import { PropertyNameCell } from './fields-layout'; import { PropertyNameCell } from './fields-layout';
import { ShelfIcon } from './shelfs';
export const ClickablePropertyNameCell = PropertyNameCell.extend` export const ClickablePropertyNameCell = PropertyNameCell.extend`
cursor: pointer; cursor: pointer;
${ShelfIcon} {
height: ${({ theme }) => theme.schema.arrow.size};
width: ${({ theme }) => theme.schema.arrow.size};
polygon {
fill: ${({ theme }) => theme.schema.arrow.color};
}
}
`; `;
export const FieldLabel = styled.span` export const FieldLabel = styled.span`
@ -14,30 +23,29 @@ export const FieldLabel = styled.span`
`; `;
export const TypePrefix = FieldLabel.extend` export const TypePrefix = FieldLabel.extend`
color: ${props => transparentize(0.2, props.theme.schemaView.typeNameColor)}; color: ${props => transparentize(0.2, props.theme.schema.typeNameColor)};
`; `;
export const TypeName = FieldLabel.extend` export const TypeName = FieldLabel.extend`
color: ${props => props.theme.schemaView.typeNameColor}; color: ${props => props.theme.schema.typeNameColor};
`; `;
export const TypeTitle = FieldLabel.extend` export const TypeTitle = FieldLabel.extend`
color: ${props => props.theme.schemaView.typeTitleColor}; color: ${props => props.theme.schema.typeTitleColor};
`; `;
export const TypeFormat = TypeName; export const TypeFormat = TypeName;
export const RequiredLabel = FieldLabel.withComponent('div').extend` export const RequiredLabel = FieldLabel.withComponent('div').extend`
color: ${props => props.theme.schemaView.requireLabelColor}; color: ${props => props.theme.schema.requireLabelColor};
font-size: 11px; font-size: ${props => props.theme.schema.labelsTextSize};
font-weight: normal; font-weight: normal;
margin-left: 20px; margin-left: 20px;
line-height: 1; line-height: 1;
font-weight: normal;
`; `;
export const RecursiveLabel = FieldLabel.extend` export const RecursiveLabel = FieldLabel.extend`
color: #dd9900; color: ${({ theme }) => theme.colors.warning.main};
font-size: 13px; font-size: 13px;
`; `;
@ -55,27 +63,28 @@ export const PatternLabel = FieldLabel.extend`
} }
`; `;
export const ExampleValue = styled.span` export const ExampleValue = FieldLabel.extend`
font-family: ${props => props.theme.code.fontFamily};
background-color: ${props => transparentize(0.98, props.theme.colors.text)};
border: 1px solid ${props => transparentize(0.85, props.theme.colors.text)};
margin: 0 3px;
padding: 0.4em 0.2em 0.2em;
font-size: 0.8em;
border-radius: 2px; border-radius: 2px;
color: ${props => transparentize(0.1, props.theme.colors.text)}; ${({ theme }) => `
display: inline-block; background-color: ${transparentize(0.85, theme.colors.text.primary)};
min-width: 20px; color: ${transparentize(0.1, theme.colors.text.primary)};
text-align: center;
line-height: 1; margin-left: ${theme.spacing.unit}px;
vertical-align: middle; padding: 0 ${theme.spacing.unit}px;
border: 1px solid ${transparentize(0.9, theme.colors.text.primary)};
}`};
${extensionsHook('ExampleValue')};
`; `;
export const ConstraintItem = FieldLabel.extend` export const ConstraintItem = FieldLabel.extend`
background-color: ${props => transparentize(0.85, props.theme.colors.main)};
color: ${props => transparentize(0.4, props.theme.colors.main)};
margin-right: 6px;
margin-left: 6px;
border-radius: 2px; border-radius: 2px;
padding: 0 4px; ${({ theme }) => `
background-color: ${transparentize(0.85, theme.colors.primary.light)};
color: ${transparentize(0.1, theme.colors.primary.light)};
margin-left: 0 ${theme.spacing.unit}px;
padding: 0 ${theme.spacing.unit}px;
border: 1px solid ${transparentize(0.9, theme.colors.primary.light)};
}`};
${extensionsHook('ConstraintItem')};
`; `;

View File

@ -7,14 +7,14 @@ const headerFontSize = {
}; };
export const headerCommonMixin = level => css` export const headerCommonMixin = level => css`
font-family: ${props => props.theme.headingsFont.family}; font-family: ${props => props.theme.typography.headings.fontFamily};
font-weight: 400; font-weight: 400;
font-size: ${headerFontSize[level]}; font-size: ${headerFontSize[level]};
`; `;
export const H1 = styled.h1` export const H1 = styled.h1`
${headerCommonMixin(1)}; ${headerCommonMixin(1)};
color: ${props => props.theme.colors.main}; color: ${props => props.theme.colors.primary.main};
${extensionsHook('H1')}; ${extensionsHook('H1')};
`; `;

View File

@ -2,7 +2,7 @@ import styled, { media } from '../styled-components';
export const MiddlePanel = styled.div` export const MiddlePanel = styled.div`
width: calc(100% - ${props => props.theme.rightPanel.width}); width: calc(100% - ${props => props.theme.rightPanel.width});
padding: ${props => props.theme.spacingUnit * 2}px; padding: ${props => props.theme.spacing.unit * 8}px;
${media.lessThan('medium')` ${media.lessThan('medium')`
width: 100%; width: 100%;
@ -13,7 +13,7 @@ export const RightPanel = styled.div`
width: ${props => props.theme.rightPanel.width}; width: ${props => props.theme.rightPanel.width};
color: #fafbfc; color: #fafbfc;
background-color: ${props => props.theme.rightPanel.backgroundColor}; background-color: ${props => props.theme.rightPanel.backgroundColor};
padding: ${props => props.theme.spacingUnit * 2}px; padding: ${props => props.theme.spacing.unit * 8}px;
${media.lessThan('medium')` ${media.lessThan('medium')`
width: 100%; width: 100%;

View File

@ -10,7 +10,7 @@ export const OneOfList = styled.ul`
export const OneOfLabel = styled.span` export const OneOfLabel = styled.span`
font-size: 0.9em; font-size: 0.9em;
margin-right: 10px; margin-right: 10px;
color: ${props => props.theme.colors.main}; color: ${props => props.theme.colors.primary.main};
font-family: Montserrat; font-family: Montserrat;
} }
`; `;
@ -20,18 +20,18 @@ export const OneOfButton = withProps<{ active: boolean }>(styled.li)`
margin-right: 10px; margin-right: 10px;
font-size: 0.8em; font-size: 0.8em;
cursor: pointer; cursor: pointer;
border: 1px solid ${props => props.theme.colors.main}; border: 1px solid ${props => props.theme.colors.primary.main};
padding: 2px 10px; padding: 2px 10px;
${props => { ${props => {
if (props.active) { if (props.active) {
return ` return `
color: white; color: white;
background-color: ${props.theme.colors.main}; background-color: ${props.theme.colors.primary.main};
`; `;
} else { } else {
return ` return `
color: ${props.theme.colors.main}; color: ${props.theme.colors.primary.main};
background-color: white; background-color: white;
`; `;
} }
@ -40,7 +40,7 @@ export const OneOfButton = withProps<{ active: boolean }>(styled.li)`
export const ArrayOpenningLabel = styled.div` export const ArrayOpenningLabel = styled.div`
font-size: 0.9em; font-size: 0.9em;
font-family: ${props => props.theme.code.fontFamily}; font-family: ${props => props.theme.typography.code.fontFamily};
&::after { &::after {
content: ' ['; content: ' [';
} }
@ -48,7 +48,7 @@ export const ArrayOpenningLabel = styled.div`
export const ArrayClosingLabel = styled.div` export const ArrayClosingLabel = styled.div`
font-size: 0.9em; font-size: 0.9em;
font-family: ${props => props.theme.code.fontFamily}; font-family: ${props => props.theme.typography.code.fontFamily};
&::after { &::after {
content: ']'; content: ']';
} }

View File

@ -42,7 +42,9 @@ export const ShelfIcon = styled(IntShelfIcon)`
transform: rotateZ(${props => directionMap[props.direction || 'down']}); transform: rotateZ(${props => directionMap[props.direction || 'down']});
polygon { polygon {
fill: ${props => (props.color && props.theme.colors[props.color]) || props.color}; fill: ${props =>
(props.color && props.theme.colors[props.color] && props.theme.colors[props.color].main) ||
props.color};
} }
`; `;
@ -50,8 +52,8 @@ export const Badge = withProps<{ type: string }>(styled.span)`
display: inline-block; display: inline-block;
padding: 0 5px; padding: 0 5px;
margin: 0; margin: 0;
background-color: ${props => props.theme.colors[props.type]}; background-color: ${props => props.theme.colors[props.type].main};
color: white; color: ${props => props.theme.colors[props.type].dark};
font-size: ${props => props.theme.code.fontSize};; font-size: ${props => props.theme.typography.code.fontSize};
vertical-align: text-top; vertical-align: text-top;
`; `;

View File

@ -28,7 +28,7 @@ export const Tabs = styled(ReactTabs)`
font-weight: bold; font-weight: bold;
&.react-tabs__tab--selected { &.react-tabs__tab--selected {
color: ${props => props.theme.colors.text}; color: ${props => props.theme.colors.text.primary};
background: #e2e2e2; background: #e2e2e2;
} }
@ -38,19 +38,19 @@ export const Tabs = styled(ReactTabs)`
} }
&.tab-success { &.tab-success {
color: ${props => props.theme.colors.success}; color: ${props => props.theme.colors.responses.success.color};
} }
&.tab-redirect { &.tab-redirect {
color: ${props => props.theme.colors.redirect}; color: ${props => props.theme.colors.responses.redirect.color};
} }
&.tab-info { &.tab-info {
color: ${props => props.theme.colors.info}; color: ${props => props.theme.colors.responses.info.color};
} }
&.tab-error { &.tab-error {
color: ${props => props.theme.colors.error}; color: ${props => props.theme.colors.responses.error.color};
} }
} }
} }

View File

@ -13,8 +13,8 @@ export const ApiHeader = H1.extend`
`; `;
export const DownloadButton = styled.a` export const DownloadButton = styled.a`
border: 1px solid ${props => props.theme.colors.main}; border: 1px solid ${props => props.theme.colors.primary.main};
color: ${props => props.theme.colors.main}; color: ${props => props.theme.colors.primary.main};
font-weight: normal; font-weight: normal;
margin-left: 0.5em; margin-left: 0.5em;
padding: 4px 8px 4px; padding: 4px 8px 4px;

View File

@ -7,7 +7,7 @@ export const OperationEndpointWrap = styled.div`
`; `;
export const ServerRelativeURL = styled.span` export const ServerRelativeURL = styled.span`
font-family: ${props => props.theme.headingsFont.family}; font-family: ${props => props.theme.typography.headings.fontFamily};
margin-left: 10px; margin-left: 10px;
`; `;
@ -23,10 +23,11 @@ export const EndpointInfo = withProps<{ expanded?: boolean; inverted?: boolean }
border-bottom: ${props => (props.inverted ? '1px solid #ccc' : '0')}; border-bottom: ${props => (props.inverted ? '1px solid #ccc' : '0')};
transition: border-color 0.25s ease; transition: border-color 0.25s ease;
${props => (props.expanded && !props.inverted && 'border-color: #3c4448;') || ''} ${props =>
(props.expanded && !props.inverted && `border-color: ${props.theme.colors.border.dark};`) || ''}
.${ServerRelativeURL} { .${ServerRelativeURL} {
color: ${props => (props.inverted ? props.theme.colors.text : '#ffffff')} color: ${props => (props.inverted ? props.theme.colors.text.primary : '#ffffff')}
} }
`; `;
@ -39,7 +40,7 @@ export const HttpVerb = withProps<{ type: string }>(styled.span).attrs({
color: #ffffff; color: #ffffff;
padding: 3px 10px; padding: 3px 10px;
text-transform: uppercase; text-transform: uppercase;
font-family: ${props => props.theme.headingsFont.family}; font-family: ${props => props.theme.typography.headings.fontFamily};
margin: 0; margin: 0;
`; `;
@ -68,8 +69,8 @@ export const ServerUrl = styled.div`
border: 1px solid #ccc; border: 1px solid #ccc;
background: #fff; background: #fff;
word-break: break-all; word-break: break-all;
color: ${props => props.theme.colors.main}; color: ${props => props.theme.colors.primary.main};
> span { > span {
color: ${props => props.theme.colors.text}; color: ${props => props.theme.colors.text.primary};
} }
`; `;

View File

@ -46,7 +46,7 @@ export class Field extends React.Component<FieldProps> {
> >
<PropertyBullet /> <PropertyBullet />
{name} {name}
<ShelfIcon size={'1.2em'} direction={expanded ? 'down' : 'right'} /> <ShelfIcon direction={expanded ? 'down' : 'right'} />
{required && <RequiredLabel> required </RequiredLabel>} {required && <RequiredLabel> required </RequiredLabel>}
</ClickablePropertyNameCell> </ClickablePropertyNameCell>
) : ( ) : (

View File

@ -5,8 +5,8 @@ export const jsonStyles = css`
display: none; display: none;
} }
font-family: ${props => props.theme.code.fontFamily}; font-family: ${props => props.theme.typography.code.fontFamily};
font-size: ${props => props.theme.code.fontSize}; font-size: ${props => props.theme.typography.code.fontSize};
word-break: break-all; word-break: break-all;
word-wrap: break-word; word-wrap: break-word;

View File

@ -4,23 +4,23 @@ import styled, { css, extensionsHook, withProps } from '../../styled-components'
export const linksCss = css` export const linksCss = css`
a { a {
text-decoration: none; text-decoration: none;
color: ${props => props.theme.links.color}; color: ${props => props.theme.typography.links.color};
&:visited { &:visited {
color: ${props => props.theme.links.visited}; color: ${props => props.theme.typography.links.visited};
} }
&:hover { &:hover {
color: ${props => props.theme.links.hover}; color: ${props => props.theme.typography.links.hover};
} }
} }
`; `;
export const StyledMarkdownBlock = withProps<{ dense?: boolean; inline?: boolean }>(styled.div)` export const StyledMarkdownBlock = withProps<{ dense?: boolean; inline?: boolean }>(styled.div)`
font-family: ${props => props.theme.baseFont.family}; font-family: ${props => props.theme.typography.fontFamily};
font-weight: ${props => props.theme.baseFont.weight}; font-weight: ${props => props.theme.typography.fontWeightRegular};
line-height: ${props => props.theme.baseFont.lineHeight}; line-height: ${props => props.theme.typography.lineHeight};
p { p {
&:last-of-type { &:last-of-type {
@ -42,27 +42,28 @@ export const StyledMarkdownBlock = withProps<{ dense?: boolean; inline?: boolean
h1 { h1 {
${headerCommonMixin(1)}; ${headerCommonMixin(1)};
color: ${props => props.theme.colors.main}; color: ${props => props.theme.colors.primary.main};
margin-top: 0; margin-top: 0;
} }
h2 { h2 {
${headerCommonMixin(2)}; ${headerCommonMixin(2)};
color: ${props => props.theme.colors.text}; color: ${props => props.theme.colors.text.primary};
} }
code { code {
color: ${({ theme }) => theme.colors.code}; color: ${({ theme }) => theme.typography.code.color};
background-color: ${({ theme }) => theme.colors.codeBg}; background-color: ${({ theme }) => theme.typography.code.backgroundColor};
font-family: ${props => props.theme.code.fontFamily};
font-family: ${props => props.theme.typography.code.fontFamily};
border-radius: 2px; border-radius: 2px;
border: 1px solid rgba(38, 50, 56, 0.1); border: 1px solid rgba(38, 50, 56, 0.1);
padding: 0.1em 0.25em 0.2em; padding: 0.1em 0.25em 0.2em;
font-size: ${props => props.theme.code.fontSize}; font-size: ${props => props.theme.typography.code.fontSize};
} }
pre { pre {
font-family: ${props => props.theme.code.fontFamily}; font-family: ${props => props.theme.typography.code.fontFamily};
white-space: pre-wrap; white-space: pre-wrap;
background-color: #263238; background-color: #263238;
color: white; color: white;
@ -75,6 +76,7 @@ export const StyledMarkdownBlock = withProps<{ dense?: boolean; inline?: boolean
code { code {
background-color: transparent; background-color: transparent;
color: white; color: white;
padding: 0;
&:before, &:before,
&:after { &:after {
@ -140,7 +142,7 @@ export const StyledMarkdownBlock = withProps<{ dense?: boolean; inline?: boolean
${linkifyMixin('.share-link')}; ${linkifyMixin('.share-link')};
${extensionsHook('Markdown')};
${linksCss} ${linksCss}
${extensionsHook('Markdown')};
`; `;

View File

@ -36,7 +36,7 @@ export const InvertedSimpleDropdown = StyledDropdown.extend`
`; `;
export const NoSampleLabel = styled.div` export const NoSampleLabel = styled.div`
font-family: ${props => props.theme.code.fontFamily}; font-family: ${props => props.theme.typography.code.fontFamily};
font-size: 12px; font-size: 12px;
color: #ee807f; color: #ee807f;
`; `;

View File

@ -1,19 +1,19 @@
import styled, { media } from '../../styled-components'; import styled, { media } from '../../styled-components';
export const RedocWrap = styled.div` export const RedocWrap = styled.div`
font-family: ${props => props.theme.baseFont.family}; ${({ theme }) => `
font-size: ${props => props.theme.baseFont.size}; font-family: ${theme.typography.fontFamily};
font-weight: ${props => props.theme.baseFont.weight}; font-size: ${theme.typography.fontSize};
line-height: ${props => props.theme.baseFont.lineHeight}; font-weight: ${theme.typography.fontWeightRegular};
color: ${props => props.theme.colors.text}; line-height: ${theme.typography.lineHeight};
color: ${theme.colors.text.primary};
display: flex; display: flex;
position: relative; position: relative;
text-align: left; text-align: left;
-webkit-font-smoothing: ${props => props.theme.baseFont.smoothing}; -webkit-font-smoothing: ${theme.typography.smoothing};
font-smoothing: ${props => props.theme.baseFont.smoothing}; font-smoothing: ${theme.typography.smoothing};
${props => ${(theme.typography.optimizeSpeed && 'text-rendering: optimizeSpeed !important') || ''};
(props.theme.baseFont.optimizeSpeed && 'text-rendering: optimizeSpeed !important') || ''};
tap-highlight-color: rgba(0, 0, 0, 0); tap-highlight-color: rgba(0, 0, 0, 0);
text-size-adjust: 100%; text-size-adjust: 100%;
@ -24,8 +24,9 @@ export const RedocWrap = styled.div`
} }
.redoc-markdown h1 { .redoc-markdown h1 {
padding-top: ${props => props.theme.spacingUnit * 4}px; padding-top: ${theme.spacing.unit * 16}px;
} }
`};
`; `;
export const ApiContentWrap = styled.div` export const ApiContentWrap = styled.div`
@ -40,12 +41,12 @@ export const ApiContentWrap = styled.div`
`; `;
export const BackgroundStub = styled.div` export const BackgroundStub = styled.div`
background: ${props => props.theme.rightPanel.backgroundColor}; background: ${({ theme }) => theme.rightPanel.backgroundColor};
position: absolute; position: absolute;
top: 0; top: 0;
bottom: 0; bottom: 0;
right: 0; right: 0;
width: calc((100% - ${props => props.theme.menu.width}) * 0.4); width: calc((100% - ${({ theme }) => theme.menu.width}) * 0.4);
${media.lessThan('medium')` ${media.lessThan('medium')`
display: none; display: none;
`}; `};

View File

@ -49,7 +49,7 @@ export class RedocStandalone extends React.PureComponent<RedocStandaloneProps> {
!loading ? ( !loading ? (
<Redoc store={store!} /> <Redoc store={store!} />
) : hideLoading ? null : ( ) : hideLoading ? null : (
<Loading color={normalizedOpts.theme.colors.main} /> <Loading color={normalizedOpts.theme.colors.primary.main} />
) )
} }
</StoreProvider> </StoreProvider>

View File

@ -1,4 +1,4 @@
import { transparentize } from 'polished'; // import { transparentize } from 'polished';
import { UnderlinedHeader } from '../../common-elements'; import { UnderlinedHeader } from '../../common-elements';
import styled from '../../styled-components'; import styled from '../../styled-components';
@ -12,8 +12,8 @@ export const StyledResponseTitle = styled(ResponseTitle)`
background-color: #f2f2f2; background-color: #f2f2f2;
cursor: pointer; cursor: pointer;
color: ${props => props.theme.colors[props.type]}; color: ${props => props.theme.colors.responses[props.type].color};
background-color: ${props => transparentize(0.92, props.theme.colors[props.type])}; background-color: ${props => props.theme.colors.responses[props.type].backgroundColor};
${props => ${props =>
(props.empty && (props.empty &&

View File

@ -10,10 +10,11 @@ export const SearchWrap = styled.div`
export const SearchInput = styled.input.attrs({ export const SearchInput = styled.input.attrs({
className: 'search-input', className: 'search-input',
})` })`
width: calc(100% - ${props => props.theme.spacingUnit * 2}px); width: calc(100% - ${props => props.theme.spacing.unit * 8}px);
box-sizing: border-box; box-sizing: border-box;
margin: 0 ${props => props.theme.spacingUnit}px; margin: 0 ${props => props.theme.spacing.unit * 4}px;
padding: 5px ${props => props.theme.spacingUnit / 2}px 5px ${props => props.theme.spacingUnit}px; padding: 5px ${props => props.theme.spacing.unit * 2}px 5px
${props => props.theme.spacing.unit * 4}px;
border: 0; border: 0;
border-bottom: 1px solid #e1e1e1; border-bottom: 1px solid #e1e1e1;
font-weight: bold; font-weight: bold;
@ -38,7 +39,7 @@ export const SearchIcon = styled((props: any) => (
className: 'search-icon', className: 'search-icon',
})` })`
position: absolute; position: absolute;
left: ${props => props.theme.spacingUnit}px; left: ${props => props.theme.spacing.unit * 4}px;
height: 1.8em; height: 1.8em;
width: 0.9em; width: 0.9em;
@ -48,7 +49,7 @@ export const SearchIcon = styled((props: any) => (
`; `;
export const SearchResultsBox = styled.div` export const SearchResultsBox = styled.div`
padding: ${props => props.theme.spacingUnit / 4}px 0; padding: ${props => props.theme.spacing.unit}px 0;
background-color: #ededed; background-color: #ededed;
min-height: 150px; min-height: 150px;
max-height: 250px; max-height: 250px;
@ -80,9 +81,9 @@ export const SearchResultsBox = styled.div`
export const ClearIcon = styled.i` export const ClearIcon = styled.i`
position: absolute; position: absolute;
display: inline-block; display: inline-block;
width: ${props => props.theme.spacingUnit / 2}px; width: ${props => props.theme.spacing.unit * 2}px;
text-align: center; text-align: center;
right: ${props => props.theme.spacingUnit}px; right: ${props => props.theme.spacing.unit * 4}px;
line-height: 2em; line-height: 2em;
vertical-align: middle; vertical-align: middle;
margin-right: 2px; margin-right: 2px;

View File

@ -1,4 +1,4 @@
import { transparentize } from 'polished'; // import { transparentize } from 'polished';
import * as React from 'react'; import * as React from 'react';
import styled from '../../styled-components'; import styled from '../../styled-components';
@ -8,9 +8,9 @@ import { SecurityRequirementModel } from '../../services/models/SecurityRequirem
import { linksCss } from '../Markdown/styled.elements'; import { linksCss } from '../Markdown/styled.elements';
const ScopeName = styled.code` const ScopeName = styled.code`
font-size: ${props => props.theme.code.fontSize}; font-size: ${props => props.theme.typography.code.fontSize};
font-family: ${props => props.theme.code.fontFamily}; font-family: ${props => props.theme.typography.code.fontFamily};
border: 1px solid ${props => transparentize(0.85, props.theme.colors.text)}; border: 1px solid ${({ theme }) => theme.colors.border.dark};
margin: 0 3px; margin: 0 3px;
padding: 0.2em; padding: 0.2em;
display: inline-block; display: inline-block;
@ -60,7 +60,7 @@ export class SecurityRequirement extends React.PureComponent<SecurityRequirement
const AuthHeaderColumn = styled.td``; const AuthHeaderColumn = styled.td``;
const SecuritiesColumn = styled.td` const SecuritiesColumn = styled.td`
width: ${props => props.theme.schemaView.defaultDetailsWidth}; width: ${props => props.theme.schema.defaultDetailsWidth};
`; `;
const AuthHeader = UnderlinedHeader.extend` const AuthHeader = UnderlinedHeader.extend`

View File

@ -1,6 +1,6 @@
import * as classnames from 'classnames'; import * as classnames from 'classnames';
import { deprecatedCss } from '../../common-elements'; import { deprecatedCss, ShelfIcon } from '../../common-elements';
import styled, { css, withProps } from '../../styled-components'; import styled, { css, withProps } from '../../styled-components';
export const OperationBadge = withProps<{ type: string }>(styled.span).attrs({ export const OperationBadge = withProps<{ type: string }>(styled.span).attrs({
@ -8,7 +8,7 @@ export const OperationBadge = withProps<{ type: string }>(styled.span).attrs({
})` })`
width: 26px; width: 26px;
display: inline-block; display: inline-block;
height: ${props => props.theme.code.fontSize};; height: ${props => props.theme.typography.code.fontSize};;
background-color: #333; background-color: #333;
border-radius: 3px; border-radius: 3px;
vertical-align: top; vertical-align: top;
@ -101,17 +101,17 @@ export const menuItemDepth = {
font-size: 0.8em; font-size: 0.8em;
padding-bottom: 0; padding-bottom: 0;
cursor: default; cursor: default;
color: ${props => props.theme.colors.text}; color: ${props => props.theme.colors.text.primary};
`, `,
1: css` 1: css`
font-size: 0.929em; font-size: 0.929em;
text-transform: ${({ theme }) => theme.menu.level1Items.textTransform}; text-transform: ${({ theme }) => theme.menu.level1Items.textTransform};
&:hover { &:hover {
color: ${props => props.theme.colors.main}; color: ${props => props.theme.colors.primary.main};
} }
`, `,
2: css` 2: css`
color: ${props => props.theme.colors.text}; color: ${props => props.theme.colors.text.primary};
`, `,
}; };
@ -128,14 +128,15 @@ export const MenuItemLabel = withProps<{
}), }),
})` })`
cursor: pointer; cursor: pointer;
color: ${props => (props.active ? props.theme.colors.main : props.theme.colors.text)}; color: ${props =>
props.active ? props.theme.colors.primary.main : props.theme.colors.text.primary};
margin: 0; margin: 0;
padding: 12.5px ${props => props.theme.spacingUnit}px; padding: 12.5px ${props => props.theme.spacing.unit * 4}px;
${({ depth, type, theme }) => ${({ depth, type, theme }) =>
(type === 'section' && depth > 1 && 'padding-left: ' + theme.spacingUnit * 2 + 'px;') || ''} (type === 'section' && depth > 1 && 'padding-left: ' + theme.spacing.unit * 8 + 'px;') || ''}
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
font-family: ${props => props.theme.headingsFont.family}; font-family: ${props => props.theme.typography.headings.fontFamily};
${props => menuItemDepth[props.depth]}; ${props => menuItemDepth[props.depth]};
background-color: ${props => (props.active ? menuItemActiveBg(props.depth) : '')}; background-color: ${props => (props.active ? menuItemActiveBg(props.depth) : '')};
@ -144,6 +145,14 @@ export const MenuItemLabel = withProps<{
&:hover { &:hover {
background-color: ${props => menuItemActiveBg(props.depth)}; background-color: ${props => menuItemActiveBg(props.depth)};
} }
${ShelfIcon} {
height: ${({ theme }) => theme.menu.arrow.size};
width: ${({ theme }) => theme.menu.arrow.size};
polygon {
fill: ${({ theme }) => theme.menu.arrow.color};
}
}
`; `;
export const MenuItemTitle = withProps<{ width?: string }>(styled.span)` export const MenuItemTitle = withProps<{ width?: string }>(styled.span)`
@ -156,8 +165,8 @@ export const MenuItemTitle = withProps<{ width?: string }>(styled.span)`
export const RedocAttribution = styled.div` export const RedocAttribution = styled.div`
font-size: 0.8em; font-size: 0.8em;
margin-top: ${({ theme }) => `${theme.spacingUnit / 2}px`}; margin-top: ${({ theme }) => `${theme.spacing.unit * 2}px`};
padding: ${({ theme }) => `0 ${theme.spacingUnit}px`}; padding: ${({ theme }) => `0 ${theme.spacing.unit * 4}px`};
text-align: left; text-align: left;
opacity: 0.7; opacity: 0.7;
@ -165,7 +174,7 @@ export const RedocAttribution = styled.div`
a, a,
a:visited, a:visited,
a:hover { a:hover {
color: ${({ theme }) => theme.colors.text} !important; color: ${({ theme }) => theme.colors.text.primary} !important;
border-top: 1px solid #e1e1e1; border-top: 1px solid #e1e1e1;
padding-top: 10px; padding-top: 10px;
display: block; display: block;

View File

@ -6,8 +6,8 @@ import { SampleControls, SampleControlsWrap } from '../../common-elements';
import { CopyButtonWrapper } from '../../common-elements/CopyButtonWrapper'; import { CopyButtonWrapper } from '../../common-elements/CopyButtonWrapper';
const StyledPre = styled.pre` const StyledPre = styled.pre`
font-family: ${props => props.theme.code.fontFamily}; font-family: ${props => props.theme.typography.code.fontFamily};
font-size: ${props => props.theme.code.fontSize}; font-size: ${props => props.theme.typography.code.fontSize};
overflow-x: auto; overflow-x: auto;
margin: 0; margin: 0;

View File

@ -62,5 +62,5 @@ const ChevronContainer = styled.div`
align-self: center; align-self: center;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
color: ${props => props.theme.colors.main}; color: ${props => props.theme.colors.primary.main};
`; `;

View File

@ -49,7 +49,7 @@ const FloatingButton = styled.div`
outline: none; outline: none;
user-select: none; user-select: none;
background-color: #f2f2f2; background-color: #f2f2f2;
color: ${props => props.theme.colors.main}; color: ${props => props.theme.colors.primary.main};
display: none; display: none;
cursor: pointer; cursor: pointer;
position: fixed; position: fixed;

View File

@ -1,23 +1,66 @@
import { desaturate, lighten, transparentize } from 'polished'; import { darken, desaturate, lighten, readableColor, transparentize } from 'polished';
const defaultTheme: ThemeInterface = { const defaultTheme: ThemeInterface = {
spacingUnit: 20, spacing: {
unit: 5,
},
breakpoints: { breakpoints: {
small: '50rem', small: '50rem',
medium: '85rem', medium: '85rem',
large: '105rem', large: '105rem',
}, },
colors: { colors: {
tonalOffset: 0.3,
primary: {
main: '#32329f', main: '#32329f',
success: '#00aa13', light: ({ colors }) => lighten(colors.tonalOffset, colors.primary.main),
redirect: '#ffa500', dark: ({ colors }) => darken(colors.tonalOffset, colors.primary.main),
error: '#e53935', contrastText: ({ colors }) => readableColor(colors.primary.main),
info: '#87ceeb', },
text: '#263238', success: {
code: '#e53935', main: '#00aa13',
codeBg: 'rgba(38, 50, 56, 0.04)', light: ({ colors }) => lighten(colors.tonalOffset, colors.success.main),
warning: '#f1c400', dark: ({ colors }) => darken(colors.tonalOffset, colors.success.main),
contrastText: ({ colors }) => readableColor(colors.success.main),
},
warning: {
main: '#d4ad03',
light: ({ colors }) => lighten(colors.tonalOffset, colors.warning.main),
dark: ({ colors }) => darken(colors.tonalOffset, colors.warning.main),
contrastText: ({ colors }) => readableColor(colors.warning.main),
},
error: {
main: '#e53935',
light: ({ colors }) => lighten(colors.tonalOffset, colors.error.main),
dark: ({ colors }) => darken(colors.tonalOffset, colors.error.main),
contrastText: ({ colors }) => readableColor(colors.error.main),
},
text: {
primary: '#333333',
secondary: ({ colors }) => lighten(colors.tonalOffset, colors.text.primary),
},
border: {
dark: 'rgba(0,0,0, 0.1)',
light: '#ffffff',
},
responses: {
success: {
color: ({ colors }) => colors.success.main,
backgroundColor: ({ colors }) => transparentize(0.9, colors.success.main),
},
error: {
color: ({ colors }) => colors.error.main,
backgroundColor: ({ colors }) => transparentize(0.9, colors.error.main),
},
redirect: {
color: '#ffa500',
backgroundColor: ({ colors }) => transparentize(0.9, colors.responses.redirect.color),
},
info: {
color: '#87ceeb',
backgroundColor: ({ colors }) => transparentize(0.9, colors.responses.info.color),
},
},
http: { http: {
get: '#6bbd5b', get: '#6bbd5b',
post: '#248fb2', post: '#248fb2',
@ -30,33 +73,50 @@ const defaultTheme: ThemeInterface = {
head: '#c167e4', head: '#c167e4',
}, },
}, },
schemaView: { schema: {
linesColor: theme => lighten(0.25, desaturate(0.35, theme.colors.main)), linesColor: theme =>
lighten(
theme.colors.tonalOffset,
desaturate(theme.colors.tonalOffset, theme.colors.primary.main),
),
defaultDetailsWidth: '75%', defaultDetailsWidth: '75%',
typeNameColor: theme => transparentize(0.2, theme.colors.text), typeNameColor: theme => theme.colors.text.secondary,
typeTitleColor: theme => theme.schemaView.typeNameColor, typeTitleColor: theme => theme.schema.typeNameColor,
requireLabelColor: theme => theme.colors.error, requireLabelColor: theme => theme.colors.error.main,
labelsTextSize: '0.9em',
nestingSpacing: '1em', nestingSpacing: '1em',
nestedBackground: '#fafafa',
arrow: {
size: '1.1em',
color: theme => theme.colors.text.secondary,
}, },
baseFont: { },
size: '14px', typography: {
fontSize: '14px',
lineHeight: '1.5', lineHeight: '1.5',
weight: '400', fontWeightRegular: '400',
family: 'Roboto, sans-serif', fontWeightBold: '600',
fontWeightLight: '300',
fontFamily: 'Roboto, sans-serif',
smoothing: 'antialiased', smoothing: 'antialiased',
optimizeSpeed: true, optimizeSpeed: true,
},
headingsFont: { headings: {
family: 'Montserrat, sans-serif', fontFamily: 'Montserrat, sans-serif',
}, },
code: { code: {
fontSize: '13px', fontSize: '13px',
fontFamily: 'Courier, monospace', fontFamily: 'Courier, monospace',
lineHeight: ({ typography }) => typography.lineHeight,
fontWeight: ({ typography }) => typography.fontWeightRegular,
color: '#e53935',
backgroundColor: 'rgba(38, 50, 56, 0.04)',
}, },
links: { links: {
color: ({ colors }) => colors.main, color: ({ colors }) => colors.primary.main,
visited: ({ colors }) => colors.main, visited: ({ colors }) => colors.primary.main,
hover: ({ colors }) => lighten(0.2, colors.main), hover: ({ colors }) => lighten(0.2, colors.primary.main),
},
}, },
menu: { menu: {
width: '260px', width: '260px',
@ -67,6 +127,10 @@ const defaultTheme: ThemeInterface = {
level1Items: { level1Items: {
textTransform: 'none', textTransform: 'none',
}, },
arrow: {
size: '1.5em',
color: theme => theme.colors.text.primary,
},
}, },
logo: { logo: {
maxHeight: ({ menu }) => menu.width, maxHeight: ({ menu }) => menu.width,
@ -115,23 +179,55 @@ export function resolveTheme(theme: ThemeInterface): ResolvedThemeInterface {
return JSON.parse(JSON.stringify(theme)); return JSON.parse(JSON.stringify(theme));
} }
export interface ColorSetting {
main: string;
light: string;
dark: string;
contrastText: string;
}
export interface HTTPResponseColos {
color: string;
backgroundColor: string;
}
export interface FontSettings {
fontSize: string;
fontWeight: string;
fontFamily: string;
lineHeight: string;
color: string;
}
export interface ResolvedThemeInterface { export interface ResolvedThemeInterface {
spacingUnit: number; spacing: {
unit: number;
};
breakpoints: { breakpoints: {
small: string; small: string;
medium: string; medium: string;
large: string; large: string;
}; };
colors: { colors: {
main: string; tonalOffset: number;
success: string; primary: ColorSetting;
redirect: string; success: ColorSetting;
error: string; warning: ColorSetting;
info: string; error: ColorSetting;
text: string; border: {
code: string; light: string;
codeBg: string; dark: string;
warning: string; };
text: {
primary: string;
secondary: string;
};
responses: {
success: HTTPResponseColos;
error: HTTPResponseColos;
redirect: HTTPResponseColos;
info: HTTPResponseColos;
};
http: { http: {
get: string; get: string;
post: string; post: string;
@ -144,34 +240,44 @@ export interface ResolvedThemeInterface {
head: string; head: string;
}; };
}; };
schemaView: { schema: {
linesColor: string; linesColor: string;
defaultDetailsWidth: string; defaultDetailsWidth: string;
typeNameColor: string; typeNameColor: string;
typeTitleColor: string; typeTitleColor: string;
requireLabelColor: string; requireLabelColor: string;
labelsTextSize: string;
nestingSpacing: string; nestingSpacing: string;
}; nestedBackground: string;
baseFont: { arrow: {
size: string; size: string;
color: string;
};
};
typography: {
fontSize: string;
lineHeight: string; lineHeight: string;
weight: string; fontWeightLight: string;
family: string; fontWeightRegular: string;
fontWeightBold: string;
fontFamily: string;
smoothing: string; smoothing: string;
optimizeSpeed: boolean; optimizeSpeed: boolean;
code: FontSettings & {
backgroundColor: string;
}; };
headingsFont: { headings: {
family: string;
};
code: {
fontSize: string;
fontFamily: string; fontFamily: string;
}; };
links: { links: {
color: string; color: string;
visited: string; visited: string;
hover: string; hover: string;
}; };
};
menu: { menu: {
width: string; width: string;
backgroundColor: string; backgroundColor: string;
@ -181,6 +287,10 @@ export interface ResolvedThemeInterface {
level1Items: { level1Items: {
textTransform: string; textTransform: string;
}; };
arrow: {
size: string;
color: string;
};
}; };
logo: { logo: {
maxHeight: string; maxHeight: string;
@ -188,8 +298,8 @@ export interface ResolvedThemeInterface {
}; };
rightPanel: { rightPanel: {
backgroundColor: string; backgroundColor: string;
width: string;
textColor: string; textColor: string;
width: string;
}; };
extensionsHook?: (name: string, props: any) => string; extensionsHook?: (name: string, props: any) => string;