@textback/notification-widget
Version:
TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
56 lines (51 loc) • 2.5 kB
JavaScript
import Button from './index.js';
import icon from '../../icons/icon_facebook.svg';
import iconCircle from '../../icons/icon_facebook_circle.svg';
import constants from '../../../sdk/utils/constants.js';
class FacebookButton extends Button {
render() {
super.render();
const link = this.element.querySelector('a');
link.addEventListener('click', (event) => {
event.preventDefault();
this.channelAPI.subscribe();
});
}
get template() {
if (this.config.type === constants.WIDGET_TYPE_API_CALL) {
return `
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
<tb-notification-button__text>${this.text('facebook')}</tb-notification-button__text>
</a>
<p class="tb-notification-button__tip">
${this.text('facebookTip')}
</p>
`;
} else if(this.config.markUp.style === 'gradient') {
return `
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
<tb-notification-button__text>${this.text('facebook')}</tb-notification-button__text>
</a>
`;
} else if (this.config.markUp.style !== 'square') {
return `
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
<tb-notification-button__icon>${(this.config.markUp.style === 'rounded' ? icon : iconCircle )}</tb-notification-button__icon>
<tb-notification-button__text>${this.text('facebook')}</tb-notification-button__text>
</a>
`;
} else {
return `
<div class="tb-notification-button__inner">
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
<a target="_blank" href="https://m.me/${this.config.id}?ref=${this.deepLink}">
<tb-notification-button__text>${this.text('facebookExtended')}</tb-notification-button__text>
</a>
</div>
`;
}
}
};
module.exports = FacebookButton;