2024-03-21 17:29:39 -04:00
|
|
|
import {LitElement, html, nothing} from './lit-all.min.js';
|
2024-03-21 14:25:07 -04:00
|
|
|
import * as tfrpc from '/static/tfrpc.js';
|
|
|
|
|
|
|
|
class TfThemePickerElement extends LitElement {
|
|
|
|
static get properties() {
|
|
|
|
return {
|
|
|
|
selected: {type: String},
|
|
|
|
themes: {type: Array},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.load();
|
|
|
|
}
|
|
|
|
|
|
|
|
async load() {
|
|
|
|
this.themes = await tfrpc.rpc.getThemes();
|
2024-03-21 17:29:39 -04:00
|
|
|
this.selected = await tfrpc.rpc.getTheme();
|
|
|
|
|
|
|
|
let select = this.renderRoot?.querySelector('#theme-select');
|
|
|
|
select.value = this.selected;
|
2024-03-21 14:25:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
changed(event) {
|
|
|
|
this.selected = event.srcElement.value;
|
|
|
|
console.log('selected theme', this.selected);
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return html`
|
2024-03-21 15:10:35 -04:00
|
|
|
<link rel="stylesheet" href="/static/tildefriends-v1.css" />
|
2024-03-21 14:25:07 -04:00
|
|
|
|
|
|
|
<label for="theme">[Not implemented] Choose your theme:</label>
|
|
|
|
|
2024-03-21 15:10:35 -04:00
|
|
|
<select
|
|
|
|
name="theme"
|
2024-03-21 17:29:39 -04:00
|
|
|
id="theme-select"
|
2024-03-21 15:10:35 -04:00
|
|
|
?hidden=${!this.themes?.length}
|
|
|
|
@change=${this.changed}
|
|
|
|
>
|
|
|
|
${(this.themes ?? []).map(
|
2024-03-21 17:29:39 -04:00
|
|
|
(name) => html`<option value=${name}>${name}</option>`
|
2024-03-21 15:10:35 -04:00
|
|
|
)}
|
2024-03-21 14:25:07 -04:00
|
|
|
</select>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
customElements.define('tf-theme-picker', TfThemePickerElement);
|