aboutsummaryrefslogblamecommitdiffstats
path: root/packages/react-docs/src/components/enum.tsx
blob: 37f82f26eb938740786ab61e4ecd6448109a7c38 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                               
 


                                     




                                                      





                                                                                                       

                    



                 
import * as _ from 'lodash';
import * as React from 'react';

import { EnumValue } from '../types';

export interface EnumProps {
    values: EnumValue[];
}

export function Enum(props: EnumProps) {
    const values = _.map(props.values, (value, i) => {
        const defaultValueIfAny = !_.isUndefined(value.defaultValue) ? ` = ${value.defaultValue}` : '';
        return `\n\t${value.name}${defaultValueIfAny},`;
    });
    return (
        <span>
            {`{`}
            {values}
            <br />
            {`}`}
        </span>
    );
}