Experimenting with the ShareButton

This commit is contained in:
Pieter Vander Vennet 2020-11-22 03:50:09 +01:00
parent e10f9b61e2
commit 2d25393962
7 changed files with 61 additions and 23 deletions

View file

@ -15,7 +15,7 @@ export default class ShareButton extends UIElement{
}
InnerRender(): string {
return `<button type="button" id="${this.id}">${this._embedded.Render()}</button>`
return `<button type="button" class="share-button" id="${this.id}">${this._embedded.Render()}</button>`
}
protected InnerUpdate(htmlElement: HTMLElement) {

View file

@ -10,6 +10,8 @@ import Locale from "../UI/i18n/Locale";
import {ImageUploadFlow} from "./Image/ImageUploadFlow";
import {Translation} from "./i18n/Translation";
import State from "../State";
import ShareButton from "./ShareButton";
import Svg from "../Svg";
export class SubstitutedTranslation extends UIElement {
private readonly tags: UIEventSource<any>;
@ -196,25 +198,21 @@ export default class SpecialVisualizations {
}
],
constr: (tagSource: UIEventSource<any>, args) => {
if (navigator.share) {
return new FixedUiElement("Share").onClick(() => {
let name = tagSource["name"]
let title= State.state.layoutToUse.data.title.txt
if(name === undefined){
name = title
}else{
name = `${name} (${title})`
}
navigator.share({
url: args[0] ?? window.location.href,
title: name,
text: State.state.layoutToUse.data.shortDescription.txt
})
})
if (window.navigator.share) {
const title = State.state.layoutToUse.data.title.txt;
let name = tagSource.data.name;
if(name){
name += `${name} (${title})`
}else{
name = title;
}
return new ShareButton(Svg.share_svg(), {
title: name,
url: args[0] ?? window.location.href,
text: State.state.layoutToUse.data.shortDescription.txt
})
} else {
return new FixedUiElement("")
return new Combine(["<button type='button' class='share-button' style='background:red;'>", Svg.share_svg() ,"</button>"])
}
}