More refactoring, stuff kindoff works

This commit is contained in:
Pieter Vander Vennet 2021-06-12 02:58:32 +02:00
parent 62f471df1e
commit 3943100e54
52 changed files with 635 additions and 1010 deletions

View file

@ -1,10 +1,10 @@
import {UIElement} from "../UIElement";
import BaseUIElement from "../BaseUIElement";
export default class ShareButton extends UIElement{
private _embedded: UIElement;
export default class ShareButton extends BaseUIElement{
private _embedded: BaseUIElement;
private _shareData: { text: string; title: string; url: string };
constructor(embedded: UIElement, shareData: {
constructor(embedded: BaseUIElement, shareData: {
text: string,
title: string,
url: string
@ -12,17 +12,17 @@ export default class ShareButton extends UIElement{
super();
this._embedded = embedded;
this._shareData = shareData;
}
InnerRender(): string {
return `<button type="button" class="share-button" id="${this.id}">${this._embedded.Render()}</button>`
this.SetClass("share-button")
}
protected InnerUpdate(htmlElement: HTMLElement) {
const self= this;
htmlElement.addEventListener('click', () => {
protected InnerConstructElement(): HTMLElement {
const e = document.createElement("button")
e.type = "button"
e.appendChild(this._embedded.ConstructElement())
e.addEventListener('click', () => {
if (navigator.share) {
navigator.share(self._shareData).then(() => {
navigator.share(this._shareData).then(() => {
console.log('Thanks for sharing!');
})
.catch(err => {
@ -32,6 +32,9 @@ export default class ShareButton extends UIElement{
console.log('web share not supported');
}
});
return e;
}
}