lbry-desktop/ui/js/component/icon/view.jsx

41 lines
913 B
React
Raw Normal View History

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-22 23:46:11 +02:00
getIconTitle() {
switch (this.props.icon) {
case icons.FEATURED:
2017-09-22 23:46:11 +02:00
return __("Watch this and earn rewards.");
case icons.LOCAL:
2017-09-22 23:46:11 +02:00
return __("You have a copy of this file.");
default:
2017-09-22 23:46:11 +02:00
return "";
}
}
render() {
2017-09-22 23:46:11 +02:00
const className = this.getIconClass(),
title = this.getIconTitle();
const spanClassName =
2017-09-22 23:46:11 +02:00
"icon " + className + (this.props.fixed ? " icon-fixed-width " : "");
return <span className={spanClassName} title={title} />;
}
}