2017-09-12 06:24:04 +02:00
|
|
|
import React from "react";
|
|
|
|
import * as icons from "constants/icons";
|
|
|
|
|
|
|
|
export default class Icon extends React.PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
icon: React.PropTypes.string.isRequired,
|
|
|
|
fixed: React.PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
fixed: false,
|
|
|
|
};
|
|
|
|
|
2017-09-22 23:46:11 +02:00
|
|
|
getIconClass() {
|
|
|
|
const { icon } = this.props;
|
|
|
|
|
|
|
|
return icon.startsWith("icon-") ? icon : "icon-" + icon;
|
|
|
|
}
|
2017-09-12 06:24:04 +02:00
|
|
|
|
2017-09-22 23:46:11 +02:00
|
|
|
getIconTitle() {
|
2017-09-12 06:24:04 +02:00
|
|
|
switch (this.props.icon) {
|
|
|
|
case icons.FEATURED:
|
2017-09-22 23:46:11 +02:00
|
|
|
return __("Watch this and earn rewards.");
|
2017-09-12 06:24:04 +02:00
|
|
|
case icons.LOCAL:
|
2017-09-22 23:46:11 +02:00
|
|
|
return __("You have a copy of this file.");
|
2017-09-12 06:24:04 +02:00
|
|
|
default:
|
2017-09-22 23:46:11 +02:00
|
|
|
return "";
|
2017-09-12 06:24:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-09-22 23:46:11 +02:00
|
|
|
const className = this.getIconClass(),
|
|
|
|
title = this.getIconTitle();
|
2017-09-12 06:24:04 +02:00
|
|
|
|
|
|
|
const spanClassName =
|
2017-09-22 23:46:11 +02:00
|
|
|
"icon " + className + (this.props.fixed ? " icon-fixed-width " : "");
|
2017-09-12 06:24:04 +02:00
|
|
|
|
|
|
|
return <span className={spanClassName} title={title} />;
|
|
|
|
}
|
|
|
|
}
|