feat(options): list color themes

This commit is contained in:
Elian Doran 2025-05-11 20:43:19 +03:00
parent ca467fcd7a
commit 224b7f4826
No known key found for this signature in database
2 changed files with 31 additions and 0 deletions

View File

@ -55,6 +55,7 @@ const TPL = /*html*/`
</div>
`;
// TODO: Deduplicate
interface Theme {
title: string;
val: string;

View File

@ -1,15 +1,45 @@
import type { OptionMap } from "@triliumnext/commons";
import OptionsWidget from "../options_widget";
import server from "../../../../services/server";
// TODO: Deduplicate
interface Theme {
title: string;
val: string;
}
type Response = Theme[];
const TPL = /*html*/`\
<div class="options-section">
<h4>Color theme</h4>
<div class="form-group row">
<div class="col-md-6">
<label for="color-theme">Color scheme</label>
<select id="color-theme" class="theme-select form-select"></select>
</div>
</div>
</div>
`;
export default class CodeTheme extends OptionsWidget {
private $themeSelect!: JQuery<HTMLElement>;
doRender() {
this.$widget = $(TPL);
this.$themeSelect = this.$widget.find(".theme-select");
}
async optionsLoaded(options: OptionMap) {
const themes = await server.get<Response>("options/codenote-themes");
this.$themeSelect.empty();
for (const theme of themes) {
const option = $("<option>").attr("value", theme.val).text(theme.title);
this.$themeSelect.append(option);
}
}
}