UNPKG

@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.52 kB
import Button from './index.js'; import icon from '../../icons/icon_tg.svg'; import iconCircle from '../../icons/icon_tg_circle.svg'; import constants from '../../../sdk/utils/constants.js'; class TelegramButton 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://telegram.me/${this.config.id}?start=${this.deepLink}"> <tb-notification-button__icon>${icon}</tb-notification-button__icon> <tb-notification-button__text>${this.text('telegram')}</tb-notification-button__text> </a> <p class="tb-notification-button__tip"> ${this.text('telegramTip')} </p> `; } else if(this.config.markUp.style === 'gradient') { return ` <a target="_blank" href="https://telegram.me/${this.config.id}?start=${this.deepLink}"> <tb-notification-button__icon>${icon}</tb-notification-button__icon> <tb-notification-button__text>${this.text('telegram')}</tb-notification-button__text> </a> `; } else if (this.config.markUp.style !== 'square') { return ` <a target="_blank" href="https://telegram.me/${this.config.id}?start=${this.deepLink}"> <tb-notification-button__icon>${ (this.config.markUp.style === 'rounded' ? icon : iconCircle) }</tb-notification-button__icon> <tb-notification-button__text>${this.text('telegram')}</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://telegram.me/${this.config.id}?start=${this.deepLink}"> <tb-notification-button__text>${this.text('telegramExtended')}</tb-notification-button__text> </a> </div> `; } } }; module.exports = TelegramButton;