2017-11-30 01:03:10 +02:00
|
|
|
const React = require('react');
|
|
|
|
const { connect } = require('react-redux');
|
|
|
|
const { themeStyle } = require('../theme.js');
|
|
|
|
|
|
|
|
class ToolbarButton extends React.Component {
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const theme = themeStyle(this.props.theme);
|
|
|
|
|
2018-06-14 09:52:12 +02:00
|
|
|
const style = Object.assign({}, theme.toolbarStyle);
|
2017-11-30 01:03:10 +02:00
|
|
|
|
2018-06-12 00:47:44 +02:00
|
|
|
const title = this.props.title ? this.props.title : '';
|
|
|
|
const tooltip = this.props.tooltip ? this.props.tooltip : title;
|
|
|
|
|
2017-11-30 01:03:10 +02:00
|
|
|
let icon = null;
|
|
|
|
if (this.props.iconName) {
|
|
|
|
const iconStyle = {
|
2018-06-14 10:02:01 +02:00
|
|
|
fontSize: Math.round(theme.fontSize * 1.5),
|
2017-11-30 01:03:10 +02:00
|
|
|
color: theme.color
|
|
|
|
};
|
2018-06-12 00:47:44 +02:00
|
|
|
if (title) iconStyle.marginRight = 5;
|
2017-11-30 01:03:10 +02:00
|
|
|
icon = <i style={iconStyle} className={"fa " + this.props.iconName}></i>
|
|
|
|
}
|
|
|
|
|
|
|
|
const isEnabled = (!('enabled' in this.props) || this.props.enabled === true);
|
|
|
|
let classes = ['button'];
|
|
|
|
if (!isEnabled) classes.push('disabled');
|
|
|
|
|
|
|
|
const finalStyle = Object.assign({}, style, {
|
|
|
|
opacity: isEnabled ? 1 : 0.4,
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<a
|
|
|
|
className={classes.join(' ')}
|
|
|
|
style={finalStyle}
|
2018-06-12 00:47:44 +02:00
|
|
|
title={tooltip}
|
2017-11-30 01:03:10 +02:00
|
|
|
href="#"
|
|
|
|
onClick={() => { if (isEnabled && this.props.onClick) this.props.onClick() }}
|
|
|
|
>
|
2018-06-12 00:47:44 +02:00
|
|
|
{icon}{title}
|
2017-11-30 01:03:10 +02:00
|
|
|
</a>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ToolbarButton;
|