import classNames from 'classnames';
import React, { PropTypes } from 'react';

const propTypes = {
    icon: PropTypes.string.isRequired,
    size: PropTypes.oneOf(['small', 'large']),
    children: PropTypes.node,
};

const defaultProps = {
    size: 'small',
};

const Icon = props => {
    let icon = props.icon;
    if (!(/^aui-iconfont-/).test(icon)) {
        icon = `aui-iconfont-${icon}`;
    }

    return (
        <span className={classNames('aui-icon', `aui-icon-${props.size}`, icon)}>
            {props.children}
        </span>
    );
};
Icon.propTypes = propTypes;
Icon.defaultProps = defaultProps;

export default Icon;
