add audio preview

This commit is contained in:
JesmoDev
2024-02-14 21:38:07 +01:00
parent e5d2a8bef9
commit 4ec33cf6a0
2 changed files with 46 additions and 1 deletions

View File

@@ -1,2 +1,3 @@
export * from './input-upload-field-file.element.js';
export * from './input-upload-field.element.js';
export * from './input-upload-field-file.element.js';
export * from './input-upload-field-audio.element.js';

View File

@@ -0,0 +1,44 @@
import { UMB_APP_CONTEXT } from '@umbraco-cms/backoffice/app';
import { html, until, customElement, property, css } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
type FileItem = {
name: string;
src: string;
};
@customElement('umb-input-upload-field-audio')
export class UmbInputUploadFieldAudioElement extends UmbLitElement {
@property({ type: String })
path = '';
#serverUrl = '';
constructor() {
super();
this.consumeContext(UMB_APP_CONTEXT, (instance) => {
this.#serverUrl = instance.getServerUrl();
});
}
render() {
if (!this.path) return html`<uui-loader></uui-loader>`;
return html`<audio controls src=${this.#serverUrl + this.path}></audio>`;
}
static styles = [
css`
audio {
width: 100%;
max-width: 600px;
}
`,
];
}
declare global {
interface HTMLElementTagNameMap {
'umb-input-upload-field-audio': UmbInputUploadFieldAudioElement;
}
}