@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.38 kB
JavaScript
import Button from "./index.js";
import icon from "../../icons/icon_max.svg";
import iconCircle from "../../icons/icon_max_circle.svg";
import constants from "../../../sdk/utils/constants.js";
class MaxButton 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://max.ru/${this.config.id}?start=${this.deepLink}">
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
<tb-notification-button__text>${this.text("max")}</tb-notification-button__text>
</a>
<p class="tb-notification-button__tip">
${this.text("maxTip")}
</p>
`;
} else if (this.config.markUp.style === "gradient") {
return `
<a target="_blank" href="https://max.ru/${this.config.id}?start=${this.deepLink}">
<tb-notification-button__icon>${icon}</tb-notification-button__icon>
<tb-notification-button__text>${this.text("max")}</tb-notification-button__text>
</a>
`;
} else if (this.config.markUp.style !== "square") {
return `
<a target="_blank" href="https://max.ru/${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("max")}</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://max.ru/${this.config.id}?start=${this.deepLink}">
<tb-notification-button__text>${this.text("maxExtended")}</tb-notification-button__text>
</a>
</div>
`;
}
}
}
module.exports = MaxButton;