Skip to content

Commit

Permalink
move required label to the left column
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Jan 10, 2018
1 parent bfee3ed commit 9d0f2a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/common-elements/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { transparentizeHex } from '../utils/styled';

export const ClickablePropertyNameCell = PropertyNameCell.extend`
cursor: pointer;
font-weight: bold;
`;

export const FieldLabel = styled.span`
Expand All @@ -26,10 +25,13 @@ export const TypeTitle = styled(FieldLabel)`

export const TypeFormat = TypeName;

export const RequiredLabel = styled(FieldLabel)`
export const RequiredLabel = styled(FieldLabel.withComponent('div'))`
color: #e53935;
font-size: 13px;
font-weight: bold;
font-size: 11px;
font-weight: normal;
margin-left: 20px;
line-height: 1;
font-weight: normal;
`;

export const RecursiveLabel = styled(FieldLabel)`
Expand Down
6 changes: 4 additions & 2 deletions src/components/Fields/Field.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FieldDetails } from './FieldDetails';
import * as React from 'react';

import { ClickablePropertyNameCell } from '../../common-elements/fields';
import { ClickablePropertyNameCell, RequiredLabel } from '../../common-elements/fields';

import {
PropertyBullet,
Expand All @@ -27,7 +27,7 @@ export interface FieldProps {
export class Field extends React.PureComponent<FieldProps> {
render() {
const { className, field, isLast } = this.props;
const { name, expanded, deprecated } = field;
const { name, expanded, deprecated, required } = field;

const paramName = this.props.onClick ? (
<ClickablePropertyNameCell
Expand All @@ -37,11 +37,13 @@ export class Field extends React.PureComponent<FieldProps> {
<PropertyBullet />
{name}
<ShelfIcon size={'1.2em'} direction={expanded ? 'down' : 'right'} />
{required && <RequiredLabel> required </RequiredLabel>}
</ClickablePropertyNameCell>
) : (
<PropertyNameCell className={deprecated ? 'deprecated' : undefined}>
<PropertyBullet />
{name}
{required && <RequiredLabel> required </RequiredLabel>}
</PropertyNameCell>
);
return (
Expand Down
4 changes: 1 addition & 3 deletions src/components/Fields/FieldDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
RecursiveLabel,
NullableLabel,
PatternLabel,
RequiredLabel,
TypeFormat,
TypeName,
TypeTitle,
Expand All @@ -22,7 +21,7 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
render() {
const { showExamples, field, renderDiscriminatorSwitch } = this.props;

const { schema, description, required, example, deprecated } = field;
const { schema, description, example, deprecated } = field;

return (
<div>
Expand All @@ -39,7 +38,6 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
<ConstraintsView constraints={schema.constraints} />
{schema.nullable && <NullableLabel> Nullable </NullableLabel>}
{schema.pattern && <PatternLabel>{schema.pattern}</PatternLabel>}
{required && <RequiredLabel> Required </RequiredLabel>}
{schema.isCircular && <RecursiveLabel> Recursive </RecursiveLabel>}
</div>
{deprecated && (
Expand Down

0 comments on commit 9d0f2a9

Please sign in to comment.