File size: 1,409 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import { Component } from 'react';
import { bumpStat } from '../rest-client/bump-stat';
// from $wpnc__title-bar-height in boot/sizes.scss
const TITLE_OFFSET = 38;
export class EmptyMessage extends Component {
componentDidMount() {
if ( this.props.showing ) {
bumpStat( 'notes-empty-message', this.props.name + '_shown' );
}
}
componentDidUpdate() {
if ( this.props.showing ) {
bumpStat( 'notes-empty-message', this.props.name + '_shown' );
}
}
handleClick = () => bumpStat( 'notes-empty-message', this.props.name + '_clicked' );
render() {
const { emptyMessage, link, linkMessage } = this.props;
return (
<div
className="wpnc__empty-notes-container"
style={ { height: this.props.height - TITLE_OFFSET + 'px' } }
>
{ link && linkMessage && (
<div className="wpnc__empty-notes">
<h2>{ emptyMessage }</h2>
<p>
<a
href={ link }
target="_blank"
rel="noopener noreferrer"
onClick={ this.handleClick }
>
{ linkMessage }
</a>
</p>
</div>
) }
{ ! link && linkMessage && (
<div className="wpnc__empty-notes">
<h2>{ emptyMessage }</h2>
<p>{ linkMessage }</p>
</div>
) }
{ ! link && ! linkMessage && (
<div className="wpnc__empty-notes">
<h2>{ emptyMessage }</h2>
</div>
) }
</div>
);
}
}
export default EmptyMessage;
|