Skip to content

Commit

Permalink
fix: improve rendering of types
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Dec 7, 2017
1 parent 435cccd commit 17da7b7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/common-elements/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export const TypePrefix = styled(FieldLabel)`
`;

export const TypeName = styled(FieldLabel)`
color: ${props => transparentizeHex(props.theme.colors.text, 0.4)};
color: ${props => transparentizeHex(props.theme.colors.text, 0.8)};
`;
export const TypeTitle = styled(FieldLabel)`
color: ${props => transparentizeHex(props.theme.colors.text, 0.5)};
`;

export const TypeFormat = TypeName;
Expand All @@ -29,7 +32,7 @@ export const RequiredLabel = styled(FieldLabel)`
font-weight: bold;
`;

export const CircularLabel = styled(FieldLabel)`
export const RecursiveLabel = styled(FieldLabel)`
color: #dd9900;
font-size: 13px;
`;
Expand Down
6 changes: 4 additions & 2 deletions src/components/Fields/FieldDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { EnumValues } from './EnumValues';
import { FieldDetail } from './FieldDetail';
import { ConstraintsView } from './FieldContstraints';
import {
CircularLabel,
RecursiveLabel,
NullableLabel,
PatternLabel,
RequiredLabel,
TypeFormat,
TypeName,
TypeTitle,
TypePrefix,
} from '../../common-elements/fields';

Expand All @@ -34,11 +35,12 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
{schema.format}>
</TypeFormat>
)}
{schema.title && <TypeTitle> ({schema.title}) </TypeTitle>}
<ConstraintsView constraints={schema.constraints} />
{schema.nullable && <NullableLabel> Nullable </NullableLabel>}
{schema.pattern && <PatternLabel>{schema.pattern}</PatternLabel>}
{required && <RequiredLabel> Required </RequiredLabel>}
{schema.isCircular && <CircularLabel> Circular </CircularLabel>}
{schema.isCircular && <RecursiveLabel> Recursive </RecursiveLabel>}
</div>
{deprecated && (
<div>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Schema/Schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { observer } from 'mobx-react';

import { FieldDetails } from '../Fields/FieldDetails';
import { TypeName, CircularLabel } from '../../common-elements/fields';
import { RecursiveLabel, TypeName, TypeTitle } from '../../common-elements/fields';

import { SchemaModel } from '../../services/models';

Expand All @@ -28,7 +28,8 @@ export class Schema extends React.Component<Partial<SchemaProps>> {
return (
<div>
<TypeName>{schema.displayType}</TypeName>
<CircularLabel> Circular </CircularLabel>
{schema.title && <TypeTitle> {schema.title} </TypeTitle>}
<RecursiveLabel> Recursive </RecursiveLabel>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/models/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class SchemaModel {
this.pattern = schema.pattern;

this.constraints = humanizeConstraints(schema);
this.displayType = this.title === '' ? this.type : `${this.title} (${this.type})`;
this.displayType = this.type;
this.isPrimitive = isPrimitiveType(schema);
this.default = schema.default;
this.readOnly = !!schema.readOnly;
Expand Down

0 comments on commit 17da7b7

Please sign in to comment.