Mailspring/app/internal_packages/composer-templates/lib/template-status-bar.jsx

38 lines
882 B
React
Raw Normal View History

import { React, PropTypes } from 'mailspring-exports';
class TemplateStatusBar extends React.Component {
static displayName = 'TemplateStatusBar';
static propTypes = {
2017-09-27 02:33:08 +08:00
draft: PropTypes.object.isRequired,
};
shouldComponentUpdate(nextProps) {
2017-09-27 02:33:08 +08:00
return this._usingTemplate(nextProps) !== this._usingTemplate(this.props);
}
2017-09-27 02:33:08 +08:00
_usingTemplate({ draft }) {
return draft && draft.body.search(/<code[^>]*class="var[^>]*>/i) > 0;
}
render() {
if (this._usingTemplate(this.props)) {
return (
<div className="template-status-bar">
2017-09-27 02:33:08 +08:00
Press &quot;tab&quot; to quickly move between the blanks - highlighting will not be
visible to recipients.
</div>
);
}
2016-10-18 08:59:33 +08:00
return <div />;
}
}
TemplateStatusBar.containerStyles = {
textAlign: 'center',
width: 580,
margin: 'auto',
};
export default TemplateStatusBar;