// @flow
import React from 'react';
import noop from 'lodash/noop';
import classNames from 'classnames';
import X from '../../icon/fill/X16';
// $FlowFixMe this imports from a typescript file
import LabelPill from '../label-pill';
import Avatar from '../avatar';
import './RoundPill.scss';
type Props = {
className?: string,
/** Function to retrieve the image URL associated with a pill */
getPillImageUrl?: (data: { id: string | number, [key: string]: any }) => string,
hasWarning?: boolean,
id?: string | number,
isDisabled?: boolean,
isExternal?: boolean,
isSelected?: boolean,
isValid?: boolean,
onRemove: () => any,
showAvatar?: boolean,
text: string,
};
const RemoveButton = ({ onClick, ...rest }: { onClick: () => any }) => (
);
const RoundPill = ({
getPillImageUrl,
isDisabled = false,
isSelected = false,
hasWarning = false,
isExternal,
isValid = true,
onRemove,
text,
className,
showAvatar = false,
id,
}: Props) => {
const styles = classNames('bdl-RoundPill', className, {
'bdl-RoundPill--selected': isSelected && !isDisabled,
'bdl-RoundPill--disabled': isDisabled,
'bdl-RoundPill--warning': hasWarning,
'bdl-RoundPill--error': !isValid,
});
let pillType;
if (hasWarning) {
pillType = 'warning';
}
if (!isValid) {
pillType = 'error';
}
const handleClickRemove = isDisabled ? noop : onRemove;
const avatar = showAvatar ? (
) : null;
return (
{avatar}
{text}
);
};
export default RoundPill;