redoc/src/components/Fields/EnumValues.tsx

26 lines
605 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' : ''} Enum:</FieldLabel>
{values.map((value, idx) => (
<ExampleValue key={idx}>{JSON.stringify(value)} </ExampleValue>
))}
</div>
);
}
}