import * as React from 'react';
import PropsTypes from './types';

export default class Button extends React.Component<PropsTypes, {}> {
    constructor(props: PropsTypes, {}) {
        super(props);
    }

    static renderButtons(props) {
        if (props) {
            return props.map((item:any, i:number) => {
                return <div className="krax-control is-expanded" key={i}>
                    {item}
                </div>
            })
        }
    }

    public render(): JSX.Element {
        const {fluid} = this.props;

        return (
            <div className={`krax-field has-addons ${!fluid ? 'is-inline-flex' : ''}`}>
                {Button.renderButtons(this.props.children)}
            </div>
        );
    }
}
