2024-05-23 15:17:28 +00:00
|
|
|
// SPDX-FileCopyrightText: 2024 Mehdi Benadel <https://mehdibenadel.com>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2024-05-23 15:09:58 +00:00
|
|
|
import { html } from 'lit'
|
2024-05-23 00:26:38 +00:00
|
|
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
|
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js'
|
2024-06-13 14:36:16 +00:00
|
|
|
import { helpButtonSVG } from '../../videowatch/buttons'
|
2024-05-23 00:26:38 +00:00
|
|
|
import { Task } from '@lit/task'
|
|
|
|
import { localizedHelpUrl } from '../../../utils/help'
|
2024-05-23 12:41:11 +00:00
|
|
|
import { ptTr } from '../directives/translation'
|
2024-06-05 13:56:03 +00:00
|
|
|
import type { DirectiveResult } from 'lit/directive'
|
2024-05-23 15:09:58 +00:00
|
|
|
import { LivechatElement } from './livechat'
|
2024-05-23 00:26:38 +00:00
|
|
|
|
2024-05-23 13:52:12 +00:00
|
|
|
@customElement('livechat-help-button')
|
2024-05-23 15:09:58 +00:00
|
|
|
export class HelpButtonElement extends LivechatElement {
|
2024-05-23 00:26:38 +00:00
|
|
|
@property({ attribute: false })
|
|
|
|
public buttonTitle: string | DirectiveResult = ptTr(LOC_ONLINE_HELP)
|
|
|
|
|
|
|
|
@property({ attribute: false })
|
2024-09-09 16:47:21 +00:00
|
|
|
public page = ''
|
2024-05-23 00:26:38 +00:00
|
|
|
|
|
|
|
@state()
|
|
|
|
public url: URL = new URL('https://lmddgtfy.net/')
|
|
|
|
|
2024-05-23 20:52:39 +00:00
|
|
|
private readonly _asyncTaskRender = new Task(this, {
|
2024-06-12 14:26:35 +00:00
|
|
|
task: async () => {
|
|
|
|
this.url = new URL(
|
|
|
|
await localizedHelpUrl(this.ptOptions, { page: this.page })
|
|
|
|
)
|
2024-05-23 00:26:38 +00:00
|
|
|
},
|
2024-06-12 14:26:35 +00:00
|
|
|
args: () => []
|
2024-05-23 20:52:39 +00:00
|
|
|
})
|
2024-05-23 00:26:38 +00:00
|
|
|
|
2024-05-23 20:52:39 +00:00
|
|
|
protected override render = (): unknown => {
|
2024-05-23 00:26:38 +00:00
|
|
|
return this._asyncTaskRender.render({
|
|
|
|
complete: () => html`<a
|
|
|
|
href="${this.url.href}"
|
|
|
|
target=_blank
|
|
|
|
title="${this.buttonTitle}"
|
|
|
|
class="orange-button peertube-button-link"
|
|
|
|
>${unsafeHTML(helpButtonSVG())}</a>`
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|