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

@@ -1,22 +1,24 @@
//@flow
import React from "react";
import injectSheet from "react-jss";
import classNames from "classnames";
import Icon from "./Icon";
type Props = {
classes: any
};
const styles = {
textinfo: {
color: "#98d8f3 !important"
}
textinfo: {
color: "#98d8f3 !important"
}
};
class HelpIcon extends React.Component<Props> {
render() {
const { classes } = this.props;
return <i className={classNames("fa fa-question-circle has-text-info", classes.textinfo)}></i>;
return (
<Icon className={classes.textinfo} name="question-circle" />
);
}
}

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}`)} />;
}
}

View File

@@ -4,7 +4,7 @@ import classNames from "classnames";
type Props = {
className?: string,
color?: string,
color: string,
icon?: string,
label: string,
title?: string,