expand Icon component and use it in HelpIcon, .is-icon class is redundant

This commit is contained in:
Florian Scholdei
2019-09-19 07:23:04 +02:00
parent 6d923ee45b
commit 28621916d2
4 changed files with 22 additions and 20 deletions

View File

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