glass-app-manager
Version:
Informatica's Glass Framework CLI for bootstrapping
46 lines (37 loc) • 1.12 kB
JavaScript
// @flow
import * as React from "react";
import classNames from "classnames";
import IconButton from "../button/IconButton";
type Props = {
/**
* Any string or node to render inside of the pill.
*/
children: React.Node,
/**
* A close callback handlers to call when the pill
* is closed.
*/
onClose: () => void,
/**
* Set true when using the pill with a menu.
*/
hasMenu?: boolean,
/**
* Additional selectors to append to the pill.
*/
className?: string,
};
const Pill = React.forwardRef(({ onClose, className, children, hasMenu, ...rest}: Props, ref) => {
return (
<div className={classNames("pill", className)} {...rest} ref={ref}>
<span className="pill__label">{children}</span>
{hasMenu ? <i className="pill__menu" /> : null}
{onClose ? (
<IconButton onClick={onClose}>
<i className="pill__dismiss" />
</IconButton>
) : null}
</div>
);
});
export default Pill;