redoc/src/components/Fields/EnumValues.tsx

30 lines
689 B
TypeScript
Raw Normal View History

2017-10-12 00:01:37 +03:00
import * as React from 'react';
import { ExampleValue, FieldLabel } from '../../common-elements/fields';
export interface EnumValuesProps {
values: string[];
type: string;
}
export class EnumValues extends React.PureComponent<EnumValuesProps> {
render() {
const { values, type } = this.props;
2018-01-22 21:30:53 +03:00
if (!values.length) {
return null;
}
2017-10-12 00:01:37 +03:00
return (
<div>
<FieldLabel>
{type === 'array' ? 'Items' : ''} {values.length === 1 ? 'Value' : 'Enum'}:
</FieldLabel>{' '}
2017-10-12 00:01:37 +03:00
{values.map((value, idx) => (
<ExampleValue key={idx}>
{JSON.stringify(value)}
</ExampleValue>
2017-10-12 00:01:37 +03:00
))}
</div>
);
}
}