Vulcan/packages/example-customization/lib/components/CustomNewsletter.jsx

32 lines
1.1 KiB
React
Raw Normal View History

/*
The original Newsletter components is defined using an
ES6 class, so we use the "class foo extends bar" syntax
to extend it. This way, we can simply redefine the
render method to change it, while preserving
all of the class's other methods (other render
functions, event handlers, etc.).
*/
2017-03-23 16:27:59 +09:00
import { Components, getRawComponent, replaceComponent }from 'meteor/vulcan:core';
import React, { PropTypes, Component } from 'react';
import { FormattedMessage /*, intlShape */ } from 'react-intl';
class CustomNewsletter extends getRawComponent('Newsletter') {
render() {
// console.log(this.renderButton); <-- exists
2016-06-19 16:25:19 +09:00
return this.state.showBanner
? (
<div className="newsletter">
2016-06-19 16:25:19 +09:00
<h4 className="newsletter-tagline"><FormattedMessage id="newsletter.subscribe_prompt"/></h4>
{this.props.currentUser ? this.renderButton() : this.renderForm()}
<a onClick={this.dismissBanner} className="newsletter-close"><Components.Icon name="close"/></a>
</div>
2016-06-19 16:25:19 +09:00
) : null;
}
}
replaceComponent('Newsletter', CustomNewsletter);