Skip to content

Commit 17da7b7

Browse files
committed
fix: improve rendering of types
1 parent 435cccd commit 17da7b7

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/common-elements/fields.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ export const TypePrefix = styled(FieldLabel)`
1818
`;
1919

2020
export const TypeName = styled(FieldLabel)`
21-
color: ${props => transparentizeHex(props.theme.colors.text, 0.4)};
21+
color: ${props => transparentizeHex(props.theme.colors.text, 0.8)};
22+
`;
23+
export const TypeTitle = styled(FieldLabel)`
24+
color: ${props => transparentizeHex(props.theme.colors.text, 0.5)};
2225
`;
2326

2427
export const TypeFormat = TypeName;
@@ -29,7 +32,7 @@ export const RequiredLabel = styled(FieldLabel)`
2932
font-weight: bold;
3033
`;
3134

32-
export const CircularLabel = styled(FieldLabel)`
35+
export const RecursiveLabel = styled(FieldLabel)`
3336
color: #dd9900;
3437
font-size: 13px;
3538
`;

src/components/Fields/FieldDetails.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import { EnumValues } from './EnumValues';
66
import { FieldDetail } from './FieldDetail';
77
import { ConstraintsView } from './FieldContstraints';
88
import {
9-
CircularLabel,
9+
RecursiveLabel,
1010
NullableLabel,
1111
PatternLabel,
1212
RequiredLabel,
1313
TypeFormat,
1414
TypeName,
15+
TypeTitle,
1516
TypePrefix,
1617
} from '../../common-elements/fields';
1718

@@ -34,11 +35,12 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
3435
{schema.format}>
3536
</TypeFormat>
3637
)}
38+
{schema.title && <TypeTitle> ({schema.title}) </TypeTitle>}
3739
<ConstraintsView constraints={schema.constraints} />
3840
{schema.nullable && <NullableLabel> Nullable </NullableLabel>}
3941
{schema.pattern && <PatternLabel>{schema.pattern}</PatternLabel>}
4042
{required && <RequiredLabel> Required </RequiredLabel>}
41-
{schema.isCircular && <CircularLabel> Circular </CircularLabel>}
43+
{schema.isCircular && <RecursiveLabel> Recursive </RecursiveLabel>}
4244
</div>
4345
{deprecated && (
4446
<div>

src/components/Schema/Schema.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import { observer } from 'mobx-react';
33

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

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

@@ -28,7 +28,8 @@ export class Schema extends React.Component<Partial<SchemaProps>> {
2828
return (
2929
<div>
3030
<TypeName>{schema.displayType}</TypeName>
31-
<CircularLabel> Circular </CircularLabel>
31+
{schema.title && <TypeTitle> {schema.title} </TypeTitle>}
32+
<RecursiveLabel> Recursive </RecursiveLabel>
3233
</div>
3334
);
3435
}

src/services/models/Schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class SchemaModel {
100100
this.pattern = schema.pattern;
101101

102102
this.constraints = humanizeConstraints(schema);
103-
this.displayType = this.title === '' ? this.type : `${this.title} (${this.type})`;
103+
this.displayType = this.type;
104104
this.isPrimitive = isPrimitiveType(schema);
105105
this.default = schema.default;
106106
this.readOnly = !!schema.readOnly;

0 commit comments

Comments
 (0)