forked from FooSoft/yomichan
-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy paththeme-registry.js
More file actions
64 lines (61 loc) · 1.91 KB
/
Copy paththeme-registry.js
File metadata and controls
64 lines (61 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (C) 2024-2026 Yomitan Authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* Theme registry — single source of truth for available theme modes.
* Adding a theme: add entry here, create CSS file, add to settings enum.
*/
export const themes = [
{
id: 'classic',
label: 'Classic',
css: null, /* base CSS is classic; no override file needed */
},
{
id: 'minimal',
label: 'Minimal',
css: '/css/theme-minimal.css',
},
{
id: 'eink',
label: 'E-Ink',
css: '/css/theme-eink.css',
constraints: {
disableShadow: true,
},
},
];
/**
* @param {string} themeId
* @returns {{id: string, label: string, css: string | null, constraints?: {disableShadow?: boolean}} | undefined}
*/
export function getThemeById(themeId) {
return themes.find((t) => t.id === themeId);
}
/**
* Populates a <select> element with theme options from the registry.
* @param {HTMLSelectElement|null} select
*/
export function populateThemeModeSelect(select) {
if (!select) { return; }
select.innerHTML = '';
for (const theme of themes) {
const option = document.createElement('option');
option.value = theme.id;
option.textContent = theme.label;
select.appendChild(option);
}
}