2023-01-19 19:19:06 +02:00
|
|
|
import * as React from 'react';
|
2019-05-06 22:35:29 +02:00
|
|
|
const { connect } = require('react-redux');
|
2023-01-19 19:19:06 +02:00
|
|
|
import { themeStyle } from '@joplin/lib/theme';
|
|
|
|
import { AppState } from '../app.reducer';
|
2019-05-06 22:35:29 +02:00
|
|
|
|
2023-01-19 19:19:06 +02:00
|
|
|
interface Props {
|
|
|
|
tip: string;
|
|
|
|
onClick: Function;
|
|
|
|
themeId: number;
|
|
|
|
style: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
class HelpButtonComponent extends React.Component<Props> {
|
2023-03-06 16:22:01 +02:00
|
|
|
public constructor(props: Props) {
|
2023-01-19 19:19:06 +02:00
|
|
|
super(props);
|
2019-05-06 22:35:29 +02:00
|
|
|
|
|
|
|
this.onClick = this.onClick.bind(this);
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public onClick() {
|
2019-05-06 22:35:29 +02:00
|
|
|
if (this.props.onClick) this.props.onClick();
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public render() {
|
2020-09-15 15:01:07 +02:00
|
|
|
const theme = themeStyle(this.props.themeId);
|
2020-03-14 01:46:14 +02:00
|
|
|
const style = Object.assign({}, this.props.style, { color: theme.color, textDecoration: 'none' });
|
2019-07-29 14:13:23 +02:00
|
|
|
const helpIconStyle = { flex: 0, width: 16, height: 16, marginLeft: 10 };
|
2023-01-19 19:19:06 +02:00
|
|
|
const extraProps: any = {};
|
2019-05-06 22:35:29 +02:00
|
|
|
if (this.props.tip) extraProps['data-tip'] = this.props.tip;
|
2019-07-29 14:13:23 +02:00
|
|
|
return (
|
|
|
|
<a href="#" style={style} onClick={this.onClick} {...extraProps}>
|
|
|
|
<i style={helpIconStyle} className={'fa fa-question-circle'}></i>
|
|
|
|
</a>
|
|
|
|
);
|
2019-05-06 22:35:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-19 19:19:06 +02:00
|
|
|
const mapStateToProps = (state: AppState) => {
|
2019-05-06 22:35:29 +02:00
|
|
|
return {
|
2020-09-15 15:01:07 +02:00
|
|
|
themeId: state.settings.theme,
|
2019-05-06 22:35:29 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const HelpButton = connect(mapStateToProps)(HelpButtonComponent);
|
|
|
|
|
2023-01-19 19:19:06 +02:00
|
|
|
export default HelpButton;
|