Add iconStyle + onClick option and story shot for icon component

This commit is contained in:
Florian Scholdei
2020-04-16 12:34:28 +02:00
parent b9acc7c9f6
commit 7a8b1c0c06
4 changed files with 132 additions and 13 deletions

View File

@@ -26,21 +26,30 @@ import classNames from "classnames";
type Props = {
title?: string;
iconStyle: string;
name: string;
color: string;
className?: string;
onClick?: () => void;
};
export default class Icon extends React.Component<Props> {
static defaultProps = {
iconStyle: "fas",
color: "grey-light"
};
render() {
const { title, name, color, className } = this.props;
const { title, iconStyle, name, color, className, onClick } = this.props;
if (title) {
return <i title={title} className={classNames("fas", "fa-fw", "fa-" + name, `has-text-${color}`, className)} />;
return (
<i
title={title}
className={classNames(iconStyle, "fa-fw", "fa-" + name, `has-text-${color}`, className)}
onClick={onClick}
/>
);
}
return <i className={classNames("fas", "fa-" + name, `has-text-${color}`, className)} />;
return <i className={classNames(iconStyle, "fa-" + name, `has-text-${color}`, className)} onClick={onClick} />;
}
}