feat: support function button custom

This commit is contained in:
Erzbir
2026-08-22 22:38:26 +08:00
parent e0b2e9ff70
commit 7ee2cf1e2d
7 changed files with 317 additions and 249 deletions
+10 -10
View File
@@ -11,7 +11,7 @@
- Terminal 风格的响应式页面布局 - Terminal 风格的响应式页面布局
- 浅色, 深色和跟随系统 3 种外观模式, 页头按钮会显示太阳, 月亮或圆圈图标 - 浅色, 深色和跟随系统 3 种外观模式, 页头按钮会显示太阳, 月亮或圆圈图标
- 12 套内置配色和多套自定义配色 - 12 套内置配色和多套自定义配色
- 可分别控制页头的搜索, 配色选择, 外观切换和像素化按钮 - 可排序的页头功能按钮, 支持搜索, 配色选择, 外观切换, 像素化和自定义功能
- 常规图标和像素图标切换 - 常规图标和像素图标切换
- 内置 JetBrains Mono, Hack 和 Fira Code 字体, 也可使用访客系统字体 - 内置 JetBrains Mono, Hack 和 Fira Code 字体, 也可使用访客系统字体
- 支持多字体 fallback, PostScript Name 本地匹配和高级 `@font-face` 配置 - 支持多字体 fallback, PostScript Name 本地匹配和高级 `@font-face` 配置
@@ -62,16 +62,16 @@
### 页头 ### 页头
| 设置 | 配置名 | 说明 | | 设置 | 配置名 | 说明 |
|---------|---------------------------------------|------------------| |---------|------------------|---------------------|
| Logo 文本 | `header.logo` | 留空时使用 Halo 站点标题 | | Logo 文本 | `header.logo` | 留空时使用 Halo 站点标题 |
| 搜索按钮 | `header.search_button_enable` | 搜索组件插件可用时展示 | | 功能按钮 | `header.buttons` | 按数组顺序展示内置按钮和自定义功能按钮 |
| 配色切换按钮 | `header.color_scheme_switcher_enable` | 展示自动发现的配色列表 |
| 深浅切换按钮 | `header.appearance_switcher_enable` | 在浅色, 深色和跟随系统之间循环 |
| 像素化按钮 | `header.pixel_style_switcher_enable` | 切换像素字体和像素图标 |
搜索, 配色切换, 深浅切换和像素化按钮都可以自定义普通图标与像素风格图标. 深浅切换按钮可分别设置浅色, 深色和 `header.buttons` 默认包含搜索, 外观切换和像素化按钮. 在数组中添加, 删除或拖动条目即可控制按钮的显示与顺序;
跟随系统三种状态的图标. 只设置其中一种自定义图标时, 普通和像素模式都会使用该图标; 两者都留空时才使用主题内置图标. 搜索按钮仅在搜索组件插件可用时展示. 内置按钮可自定义普通和像素风格图标, 留空时使用主题内置图标.
自定义功能按钮需设置按钮名称, `onclick` JavaScript 和图标; 可选的像素风格图标留空时使用普通图标. `onclick` 中可使用
`event` 和 `this`; 代码会在访客点击按钮时执行, 只应填写可信任的 JavaScript.
外观切换顺序为 `浅色 -> 深色 -> 跟随系统`; 图标依次为太阳, 月亮和圆圈. 切换外观模式时会清除访客单独选择的配色, 外观切换顺序为 `浅色 -> 深色 -> 跟随系统`; 图标依次为太阳, 月亮和圆圈. 切换外观模式时会清除访客单独选择的配色,
让浅色和深色模式重新使用主题设置中对应的方案. 让浅色和深色模式重新使用主题设置中对应的方案.
+111 -108
View File
@@ -49,114 +49,117 @@ spec:
name: logo name: logo
value: value:
help: 设置左上角 logo 文本, 不设置默认为 halo 中设置的站点标题 help: 设置左上角 logo 文本, 不设置默认为 halo 中设置的站点标题
- $formkit: checkbox - $formkit: array
name: search_button_enable name: buttons
id: search_button_enable label: 功能按钮
label: 展示搜索按钮 value:
value: true - value: search
help: 搜索组件插件可用时在页头展示搜索按钮 - value: color_scheme
- $formkit: iconify - value: appearance
if: "$get(search_button_enable).value === true" - value: pixel_style
key: search-icon help: 数组顺序即页头按钮顺序; 内置按钮每种建议只添加一次
name: search_icon itemLabels:
label: 搜索按钮图标 - type: "text"
format: svg if: "$value.value !== 'custom'"
help: 留空时使用自定义像素风格图标; 像素图标也未设置时使用内置图标 label: "$value.value"
- $formkit: iconify - type: "text"
if: "$get(search_button_enable).value === true" if: "$value.value === 'custom'"
key: search-pixel-icon label: "$value.options.name"
name: search_pixel_icon children:
label: 搜索按钮像素风格图标 - $formkit: select
format: svg name: value
help: 留空时使用自定义普通图标; 普通图标也未设置时使用内置像素图标 label: 按钮
- $formkit: checkbox validation: "required"
name: color_scheme_switcher_enable options:
id: color_scheme_switcher_enable - label: 搜索
label: 展示配色切换按钮 value: search
value: false - label: 配色切换
help: 在页头展示配色选择下拉框 value: color_scheme
- $formkit: iconify - label: 外观切换
if: "$get(color_scheme_switcher_enable).value === true" value: appearance
key: color-scheme-icon - label: 像素化
name: color_scheme_icon value: pixel_style
label: 配色切换按钮图标 - label: 自定义功能
format: svg value: custom
help: 留空时使用自定义像素风格图标; 像素图标也未设置时使用内置图标 - $formkit: group
- $formkit: iconify if: "$value.value !== 'custom'"
if: "$get(color_scheme_switcher_enable).value === true" name: options
key: color-scheme-pixel-icon key: standard-button-options
name: color_scheme_pixel_icon label: 图标选项
label: 配色切换按钮像素风格图标 children:
format: svg - $formkit: iconify
help: 留空时使用自定义普通图标; 普通图标也未设置时使用内置像素图标 name: iconify
- $formkit: checkbox label: 图标
name: appearance_switcher_enable format: svg
id: appearance_switcher_enable help: 留空时使用主题内置图标
label: 展示深浅切换按钮 - $formkit: iconify
value: true name: pixel_iconify
help: 在页头展示浅色, 深色和跟随系统三态切换按钮 label: 像素风格图标
- $formkit: iconify format: svg
if: "$get(appearance_switcher_enable).value === true" help: 留空时优先使用自定义普通图标, 否则使用主题内置像素图标
key: appearance-light-icon - $formkit: group
name: appearance_light_icon if: "$value.value === appearance"
label: 浅色模式图标 name: options
format: svg key: appearance-button-options
help: 留空时使用自定义像素风格图标; 像素图标也未设置时使用内置图标 label: 外观切换
- $formkit: iconify children:
if: "$get(appearance_switcher_enable).value === true" - $formkit: iconify
key: appearance-light-pixel-icon name: light_iconify
name: appearance_light_pixel_icon label: 浅色模式图标
label: 浅色模式像素风格图标 format: svg
format: svg help: 留空时使用主题内置图标
help: 留空时使用自定义普通图标; 普通图标也未设置时使用内置像素图标 - $formkit: iconify
- $formkit: iconify name: light_pixel_iconify
if: "$get(appearance_switcher_enable).value === true" label: 浅色模式像素风格图标
key: appearance-dark-icon format: svg
name: appearance_dark_icon help: 留空时优先使用自定义普通图标, 否则使用主题内置像素图标
label: 深色模式图标 - $formkit: iconify
format: svg name: dark_iconify
help: 留空时使用自定义像素风格图标; 像素图标也未设置时使用内置图标 label: 深色模式图标
- $formkit: iconify format: svg
if: "$get(appearance_switcher_enable).value === true" help: 留空时使用主题内置图标
key: appearance-dark-pixel-icon - $formkit: iconify
name: appearance_dark_pixel_icon name: dark_pixel_iconify
label: 深色模式像素风格图标 label: 深色模式像素风格图标
format: svg format: svg
help: 留空时使用自定义普通图标; 普通图标也未设置时使用内置像素图标 help: 留空时优先使用自定义普通图标, 否则使用主题内置像素图标
- $formkit: iconify - $formkit: iconify
if: "$get(appearance_switcher_enable).value === true" name: system_iconify
key: appearance-system-icon label: 跟随系统模式图标
name: appearance_system_icon format: svg
label: 跟随系统模式图标 help: 留空时使用主题内置图标
format: svg - $formkit: iconify
help: 留空时使用自定义像素风格图标; 像素图标也未设置时使用内置图标 name: system_pixel_iconify
- $formkit: iconify label: 跟随系统模式像素风格图标
if: "$get(appearance_switcher_enable).value === true" format: svg
key: appearance-system-pixel-icon help: 留空时优先使用自定义普通图标, 否则使用主题内置像素图标
name: appearance_system_pixel_icon - $formkit: group
label: 跟随系统模式像素风格图标 if: "$value.value === custom"
format: svg name: options
help: 留空时使用自定义普通图标; 普通图标也未设置时使用内置像素图标 key: custom-button-options
- $formkit: checkbox label: 自定义功能按钮选项
name: pixel_style_switcher_enable children:
id: pixel_style_switcher_enable - $formkit: text
label: 展示像素化按钮 name: name
value: true label: 按钮名称
help: 在页头展示像素风格切换按钮 validation: "required:trim|length:1,64"
- $formkit: iconify help: 用于按钮的无障碍名称和鼠标提示
if: "$get(pixel_style_switcher_enable).value === true" - $formkit: code
key: pixel-style-icon name: onclick
name: pixel_style_icon label: onclick
label: 像素化按钮图标 language: js
format: svg validation: "required:trim"
help: 留空时使用自定义像素风格图标; 像素图标也未设置时使用内置图标 help: 点击按钮时执行的 JavaScript, 可使用 event 和 this
- $formkit: iconify - $formkit: iconify
if: "$get(pixel_style_switcher_enable).value === true" name: iconify
key: pixel-style-pixel-icon label: 图标
name: pixel_style_pixel_icon format: svg
label: 像素化按钮像素风格图标 validation: "required"
format: svg - $formkit: iconify
help: 留空时使用自定义普通图标; 普通图标也未设置时使用内置像素图标 name: pixel_iconify
label: 像素风格图标
format: svg
help: 留空时使用普通图标
- group: typography - group: typography
label: 字体与排版 label: 字体与排版
formSchema: formSchema:
+65 -62
View File
@@ -57,10 +57,7 @@ function populateColorSchemeMenu(menu) {
} }
} }
export function syncColorSchemePicker() { function syncPicker(picker) {
const picker = document.getElementById("color-scheme-picker");
if (!picker) return;
const storedScheme = getStoredPreference(PREFERENCE_KEYS.colorScheme); const storedScheme = getStoredPreference(PREFERENCE_KEYS.colorScheme);
const options = Array.from(picker.querySelectorAll("[data-color-scheme]")); const options = Array.from(picker.querySelectorAll("[data-color-scheme]"));
const hasStoredOption = storedScheme && options const hasStoredOption = storedScheme && options
@@ -78,7 +75,7 @@ export function syncColorSchemePicker() {
const selectedLabel = selectedScheme === "default" const selectedLabel = selectedScheme === "default"
? "Default" ? "Default"
: selectedScheme; : selectedScheme;
const trigger = picker.querySelector("#color-scheme-trigger"); const trigger = picker.querySelector(".color-scheme-trigger");
if (trigger) { if (trigger) {
const currentLabel = getMessage("currentColorScheme", "Current color scheme"); const currentLabel = getMessage("currentColorScheme", "Current color scheme");
const description = `${currentLabel}: ${selectedLabel}`; const description = `${currentLabel}: ${selectedLabel}`;
@@ -94,9 +91,13 @@ export function syncColorSchemePicker() {
} }
} }
export function syncColorSchemePicker() {
document.querySelectorAll(".color-scheme-picker").forEach(syncPicker);
}
function setColorSchemeMenuOpen(picker, open) { function setColorSchemeMenuOpen(picker, open) {
const trigger = picker.querySelector("#color-scheme-trigger"); const trigger = picker.querySelector(".color-scheme-trigger");
const menu = picker.querySelector("#color-scheme-menu"); const menu = picker.querySelector(".color-scheme-menu");
if (!trigger || !menu) return; if (!trigger || !menu) return;
trigger.setAttribute("aria-expanded", String(open)); trigger.setAttribute("aria-expanded", String(open));
@@ -115,71 +116,73 @@ function focusColorSchemeOption(picker, direction) {
} }
export function registerColorSchemePicker() { export function registerColorSchemePicker() {
const picker = document.getElementById("color-scheme-picker"); if (typeof window.TerminalTheme?.applyColorScheme !== "function") return;
const trigger = picker?.querySelector("#color-scheme-trigger");
const menu = picker?.querySelector("#color-scheme-menu");
if (!picker || !trigger || !menu
|| typeof window.TerminalTheme?.applyColorScheme !== "function") return;
populateColorSchemeMenu(menu); document.querySelectorAll(".color-scheme-picker").forEach(picker => {
syncColorSchemePicker(); const trigger = picker.querySelector(".color-scheme-trigger");
const menu = picker.querySelector(".color-scheme-menu");
if (!trigger || !menu) return;
trigger.addEventListener("click", function () { populateColorSchemeMenu(menu);
const open = trigger.getAttribute("aria-expanded") !== "true"; syncPicker(picker);
setColorSchemeMenuOpen(picker, open);
if (open) focusColorSchemeOption(picker, "first");
});
trigger.addEventListener("keydown", function (event) { trigger.addEventListener("click", function () {
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return; const open = trigger.getAttribute("aria-expanded") !== "true";
event.preventDefault(); setColorSchemeMenuOpen(picker, open);
setColorSchemeMenuOpen(picker, true); if (open) focusColorSchemeOption(picker, "first");
focusColorSchemeOption(picker, event.key === "ArrowUp" ? "last" : "first"); });
});
menu.addEventListener("click", function (event) { trigger.addEventListener("keydown", function (event) {
const option = event.target.closest("[data-color-scheme]"); if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
if (!option || !menu.contains(option)) return;
window.TerminalTheme.applyColorScheme(option.dataset.colorScheme);
syncColorSchemePicker();
setColorSchemeMenuOpen(picker, false);
trigger.focus();
});
menu.addEventListener("keydown", function (event) {
const options = Array.from(menu.querySelectorAll("[data-color-scheme]"));
const currentIndex = options.indexOf(document.activeElement);
if (event.key === "Escape") {
event.preventDefault(); event.preventDefault();
setColorSchemeMenuOpen(picker, true);
focusColorSchemeOption(picker, event.key === "ArrowUp" ? "last" : "first");
});
menu.addEventListener("click", function (event) {
const option = event.target.closest("[data-color-scheme]");
if (!option || !menu.contains(option)) return;
window.TerminalTheme.applyColorScheme(option.dataset.colorScheme);
syncColorSchemePicker();
setColorSchemeMenuOpen(picker, false); setColorSchemeMenuOpen(picker, false);
trigger.focus(); trigger.focus();
return; });
}
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return; menu.addEventListener("keydown", function (event) {
event.preventDefault(); const options = Array.from(menu.querySelectorAll("[data-color-scheme]"));
const currentIndex = options.indexOf(document.activeElement);
let nextIndex = currentIndex; if (event.key === "Escape") {
if (event.key === "Home") nextIndex = 0; event.preventDefault();
if (event.key === "End") nextIndex = options.length - 1; setColorSchemeMenuOpen(picker, false);
if (event.key === "ArrowDown") nextIndex = (currentIndex + 1) % options.length; trigger.focus();
if (event.key === "ArrowUp") { return;
nextIndex = (currentIndex - 1 + options.length) % options.length; }
}
options[nextIndex].focus();
});
picker.addEventListener("focusout", function (event) { if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
if (!picker.contains(event.relatedTarget)) { event.preventDefault();
setColorSchemeMenuOpen(picker, false);
}
});
document.addEventListener("click", function (event) { let nextIndex = currentIndex;
if (!picker.contains(event.target)) { if (event.key === "Home") nextIndex = 0;
setColorSchemeMenuOpen(picker, false); if (event.key === "End") nextIndex = options.length - 1;
} if (event.key === "ArrowDown") nextIndex = (currentIndex + 1) % options.length;
if (event.key === "ArrowUp") {
nextIndex = (currentIndex - 1 + options.length) % options.length;
}
options[nextIndex].focus();
});
picker.addEventListener("focusout", function (event) {
if (!picker.contains(event.relatedTarget)) {
setColorSchemeMenuOpen(picker, false);
}
});
document.addEventListener("click", function (event) {
if (!picker.contains(event.target)) {
setColorSchemeMenuOpen(picker, false);
}
});
}); });
} }
+58 -30
View File
@@ -31,48 +31,75 @@ function syncAppearanceToggle(toggle) {
} }
function registerSearchButton() { function registerSearchButton() {
const searchButton = document.querySelector('[data-header-action="open-search"]'); document.querySelectorAll('[data-header-action="open-search"]').forEach(searchButton => {
if (!searchButton) return; searchButton.addEventListener("click", function () {
if (typeof window.SearchWidget?.open === "function") {
searchButton.addEventListener("click", function () { window.SearchWidget.open();
if (typeof window.SearchWidget?.open === "function") { }
window.SearchWidget.open(); });
}
}); });
} }
function registerAppearanceToggle() { function registerAppearanceToggle() {
const toggle = document.getElementById("appearance-toggle"); if (typeof window.applyTheme !== "function") return;
if (!toggle || typeof window.applyTheme !== "function") return;
syncAppearanceToggle(toggle); document.querySelectorAll(".appearance-toggle").forEach(toggle => {
toggle.addEventListener("click", function () {
const currentMode = getAppearanceMode();
const nextMode = APPEARANCE_MODES[
(APPEARANCE_MODES.indexOf(currentMode) + 1) % APPEARANCE_MODES.length
];
window.applyTheme(nextMode, {clearColorScheme: true});
setStoredPreference(PREFERENCE_KEYS.themeMode, nextMode);
syncAppearanceToggle(toggle); syncAppearanceToggle(toggle);
syncColorSchemePicker();
toggle.addEventListener("click", function () {
const currentMode = getAppearanceMode();
const nextMode = APPEARANCE_MODES[
(APPEARANCE_MODES.indexOf(currentMode) + 1) % APPEARANCE_MODES.length
];
window.applyTheme(nextMode, {clearColorScheme: true});
setStoredPreference(PREFERENCE_KEYS.themeMode, nextMode);
document.querySelectorAll(".appearance-toggle").forEach(syncAppearanceToggle);
syncColorSchemePicker();
});
}); });
} }
function registerPixelToggle() { function registerPixelToggle() {
const pixelToggle = document.getElementById("pixel-toggle"); document.querySelectorAll(".pixel-toggle").forEach(pixelToggle => {
if (!pixelToggle) return; pixelToggle.addEventListener("click", function () {
const storedStatus = getStoredPreference(PREFERENCE_KEYS.pixelStyle);
const currentStatus = storedStatus
|| document.documentElement.dataset.pixelStyle;
const newStatus = currentStatus === "true" ? "false" : "true";
pixelToggle.addEventListener("click", function () { document.documentElement.dataset.pixelStyle = newStatus;
const storedStatus = getStoredPreference(PREFERENCE_KEYS.pixelStyle); setStoredPreference(PREFERENCE_KEYS.pixelStyle, newStatus);
const currentStatus = storedStatus window.TerminalTheme?.syncPixelFont?.();
|| document.documentElement.dataset.pixelStyle; });
const newStatus = currentStatus === "true" ? "false" : "true"; });
}
document.documentElement.dataset.pixelStyle = newStatus; function registerCustomButtons() {
setStoredPreference(PREFERENCE_KEYS.pixelStyle, newStatus); document.querySelectorAll('[data-header-action="custom"]').forEach(button => {
window.TerminalTheme?.syncPixelFont?.(); const source = button.dataset.onclick?.trim();
if (!source || button.dataset.customActionReady === "true") return;
let handler;
try {
handler = new Function("event", source);
} catch (error) {
console.error("Invalid custom header button onclick:", error);
return;
}
button.dataset.customActionReady = "true";
button.addEventListener("click", function (event) {
try {
const result = handler.call(this, event);
if (result === false) {
event.preventDefault();
event.stopPropagation();
}
} catch (error) {
console.error("Custom header button onclick failed:", error);
}
});
}); });
} }
@@ -80,4 +107,5 @@ export function registerHeaderActions() {
registerSearchButton(); registerSearchButton();
registerAppearanceToggle(); registerAppearanceToggle();
registerPixelToggle(); registerPixelToggle();
registerCustomButtons();
} }
+3 -7
View File
@@ -71,10 +71,8 @@
} }
} }
#color-scheme-trigger, .color-scheme-trigger,
#appearance-toggle, .header-action-button {
#search-button,
#pixel-toggle {
background-color: transparent; background-color: transparent;
color: var(--color-theme-control); color: var(--color-theme-control);
border: var(--width-theme-border) var(--style-theme-border) var(--color-theme-control); border: var(--width-theme-border) var(--style-theme-border) var(--color-theme-control);
@@ -82,9 +80,7 @@
padding: 0; padding: 0;
} }
#appearance-toggle, .header-action-button {
#search-button,
#pixel-toggle {
margin-left: calc(var(--size-theme-font) * 0.5); margin-left: calc(var(--size-theme-font) * 0.5);
} }
} }
+8 -7
View File
@@ -25,15 +25,16 @@ html[data-pixel-style='true'] .icon-pixel {
display: inline-flex; display: inline-flex;
} }
#appearance-toggle .appearance-icon { .appearance-toggle .appearance-icon.icon-regular,
.appearance-toggle .appearance-icon.icon-pixel {
display: none; display: none;
} }
html[data-pixel-style='false'][data-theme-mode='light'] #appearance-toggle .icon-regular[data-appearance-mode='light'], html[data-pixel-style='false'][data-theme-mode='light'] .appearance-toggle .icon-regular[data-appearance-mode='light'],
html[data-pixel-style='false'][data-theme-mode='dark'] #appearance-toggle .icon-regular[data-appearance-mode='dark'], html[data-pixel-style='false'][data-theme-mode='dark'] .appearance-toggle .icon-regular[data-appearance-mode='dark'],
html[data-pixel-style='false'][data-theme-mode='system'] #appearance-toggle .icon-regular[data-appearance-mode='system'], html[data-pixel-style='false'][data-theme-mode='system'] .appearance-toggle .icon-regular[data-appearance-mode='system'],
html[data-pixel-style='true'][data-theme-mode='light'] #appearance-toggle .icon-pixel[data-appearance-mode='light'], html[data-pixel-style='true'][data-theme-mode='light'] .appearance-toggle .icon-pixel[data-appearance-mode='light'],
html[data-pixel-style='true'][data-theme-mode='dark'] #appearance-toggle .icon-pixel[data-appearance-mode='dark'], html[data-pixel-style='true'][data-theme-mode='dark'] .appearance-toggle .icon-pixel[data-appearance-mode='dark'],
html[data-pixel-style='true'][data-theme-mode='system'] #appearance-toggle .icon-pixel[data-appearance-mode='system'] { html[data-pixel-style='true'][data-theme-mode='system'] .appearance-toggle .icon-pixel[data-appearance-mode='system'] {
display: inline-flex; display: inline-flex;
} }
+62 -25
View File
@@ -9,13 +9,17 @@
</a> </a>
</div> </div>
<button <button
id="search-button" th:each="button, buttonStat : ${theme.config.header.buttons}"
th:with="regularIcon=${theme.config.header.search_icon != null ? theme.config.header.search_icon.value : null}, th:id="|search-button-${buttonStat.index}|"
pixelIcon=${theme.config.header.search_pixel_icon != null ? theme.config.header.search_pixel_icon.value : null}" class="header-action-button search-button"
th:with="buttonOptions=${button.options},
regularIcon=${buttonOptions?.iconify?.value},
pixelIcon=${buttonOptions?.pixel_iconify?.value}"
th:attr="aria-label=#{header.search.open}" th:attr="aria-label=#{header.search.open}"
th:style="|order: ${buttonStat.index}|"
type="button" type="button"
data-header-action="open-search" data-header-action="open-search"
th:if="${theme.config.header.search_button_enable != false and pluginFinder.available('PluginSearchWidget')}"> th:if="${button.value == 'search' and pluginFinder.available('PluginSearchWidget')}">
<span class="icon-regular button-icon" aria-hidden="true"> <span class="icon-regular button-icon" aria-hidden="true">
<th:block th:if="${not #strings.isEmpty(regularIcon) or not #strings.isEmpty(pixelIcon)}" <th:block th:if="${not #strings.isEmpty(regularIcon) or not #strings.isEmpty(pixelIcon)}"
th:utext="${not #strings.isEmpty(regularIcon) ? regularIcon : pixelIcon}"></th:block> th:utext="${not #strings.isEmpty(regularIcon) ? regularIcon : pixelIcon}"></th:block>
@@ -38,19 +42,21 @@
</span> </span>
</button> </button>
<div <div
id="color-scheme-picker" th:each="button, buttonStat : ${theme.config.header.buttons}"
th:id="|color-scheme-picker-${buttonStat.index}|"
class="color-scheme-picker" class="color-scheme-picker"
th:if="${theme.config.header.color_scheme_switcher_enable == true}"> th:with="buttonOptions=${button.options},
regularIcon=${buttonOptions?.iconify?.value},
pixelIcon=${buttonOptions?.pixel_iconify?.value}"
th:style="|order: ${buttonStat.index}|"
th:if="${button.value == 'color_scheme'}">
<button <button
id="color-scheme-trigger"
class="color-scheme-trigger" class="color-scheme-trigger"
th:with="regularIcon=${theme.config.header.color_scheme_icon != null ? theme.config.header.color_scheme_icon.value : null},
pixelIcon=${theme.config.header.color_scheme_pixel_icon != null ? theme.config.header.color_scheme_pixel_icon.value : null}"
type="button" type="button"
th:attr="aria-label=#{header.color_scheme.open}" th:attr="aria-label=#{header.color_scheme.open},
aria-controls=|color-scheme-menu-${buttonStat.index}|"
aria-haspopup="listbox" aria-haspopup="listbox"
aria-expanded="false" aria-expanded="false">
aria-controls="color-scheme-menu">
<span class="icon-regular button-icon" aria-hidden="true"> <span class="icon-regular button-icon" aria-hidden="true">
<th:block th:if="${not #strings.isEmpty(regularIcon) or not #strings.isEmpty(pixelIcon)}" <th:block th:if="${not #strings.isEmpty(regularIcon) or not #strings.isEmpty(pixelIcon)}"
th:utext="${not #strings.isEmpty(regularIcon) ? regularIcon : pixelIcon}"></th:block> th:utext="${not #strings.isEmpty(regularIcon) ? regularIcon : pixelIcon}"></th:block>
@@ -69,7 +75,7 @@
</span> </span>
</button> </button>
<div <div
id="color-scheme-menu" th:id="|color-scheme-menu-${buttonStat.index}|"
class="color-scheme-menu" class="color-scheme-menu"
role="listbox" role="listbox"
th:attr="aria-label=#{header.color_scheme.list}" th:attr="aria-label=#{header.color_scheme.list}"
@@ -85,15 +91,19 @@
</div> </div>
</div> </div>
<button <button
id="appearance-toggle" th:each="button, buttonStat : ${theme.config.header.buttons}"
th:with="lightRegularIcon=${theme.config.header.appearance_light_icon != null ? theme.config.header.appearance_light_icon.value : null}, th:id="|appearance-toggle-${buttonStat.index}|"
lightPixelIcon=${theme.config.header.appearance_light_pixel_icon != null ? theme.config.header.appearance_light_pixel_icon.value : null}, class="header-action-button appearance-toggle"
darkRegularIcon=${theme.config.header.appearance_dark_icon != null ? theme.config.header.appearance_dark_icon.value : null}, th:with="buttonOptions=${button.options},
darkPixelIcon=${theme.config.header.appearance_dark_pixel_icon != null ? theme.config.header.appearance_dark_pixel_icon.value : null}, lightRegularIcon=${buttonOptions?.light_iconify?.value},
systemRegularIcon=${theme.config.header.appearance_system_icon != null ? theme.config.header.appearance_system_icon.value : null}, lightPixelIcon=${buttonOptions?.light_pixel_iconify?.value},
systemPixelIcon=${theme.config.header.appearance_system_pixel_icon != null ? theme.config.header.appearance_system_pixel_icon.value : null}" darkRegularIcon=${buttonOptions?.dark_iconify?.value},
darkPixelIcon=${buttonOptions?.dark_pixel_iconify?.value},
systemRegularIcon=${buttonOptions?.system_iconify?.value},
systemPixelIcon=${buttonOptions?.system_pixel_iconify?.value}"
th:attr="aria-label=#{header.appearance.current}" th:attr="aria-label=#{header.appearance.current}"
th:if="${theme.config.header.appearance_switcher_enable != false}" th:style="|order: ${buttonStat.index}|"
th:if="${button.value == 'appearance'}"
type="button"> type="button">
<span class="appearance-icon icon-regular button-icon" data-appearance-mode="light" aria-hidden="true"> <span class="appearance-icon icon-regular button-icon" data-appearance-mode="light" aria-hidden="true">
<th:block th:if="${not #strings.isEmpty(lightRegularIcon) or not #strings.isEmpty(lightPixelIcon)}" <th:block th:if="${not #strings.isEmpty(lightRegularIcon) or not #strings.isEmpty(lightPixelIcon)}"
@@ -145,11 +155,15 @@
</span> </span>
</button> </button>
<button <button
id="pixel-toggle" th:each="button, buttonStat : ${theme.config.header.buttons}"
th:with="regularIcon=${theme.config.header.pixel_style_icon != null ? theme.config.header.pixel_style_icon.value : null}, th:id="|pixel-toggle-${buttonStat.index}|"
pixelIcon=${theme.config.header.pixel_style_pixel_icon != null ? theme.config.header.pixel_style_pixel_icon.value : null}" class="header-action-button pixel-toggle"
th:with="buttonOptions=${button.options},
regularIcon=${buttonOptions?.iconify?.value},
pixelIcon=${buttonOptions?.pixel_iconify?.value}"
th:attr="aria-label=#{header.pixel_style.toggle}" th:attr="aria-label=#{header.pixel_style.toggle}"
th:if="${theme.config.header.pixel_style_switcher_enable != false}" th:style="|order: ${buttonStat.index}|"
th:if="${button.value == 'pixel_style'}"
type="button"> type="button">
<span class="icon-pixel button-icon" aria-hidden="true"> <span class="icon-pixel button-icon" aria-hidden="true">
<th:block th:if="${not #strings.isEmpty(regularIcon) or not #strings.isEmpty(pixelIcon)}" <th:block th:if="${not #strings.isEmpty(regularIcon) or not #strings.isEmpty(pixelIcon)}"
@@ -168,6 +182,29 @@
</svg> </svg>
</span> </span>
</button> </button>
<th:block th:each="button, buttonStat : ${theme.config.header.buttons}">
<button
class="header-action-button custom-header-button"
type="button"
data-header-action="custom"
th:with="buttonOptions=${button.options},
regularIcon=${buttonOptions?.iconify?.value},
pixelIcon=${buttonOptions?.pixel_iconify?.value}"
th:if="${button.value == 'custom'
and button.options != null
and not #strings.isEmpty(button.options.name)
and (not #strings.isEmpty(button.options.iconify?.value)
or not #strings.isEmpty(button.options.pixel_iconify?.value))}"
th:style="|order: ${buttonStat.index}|"
th:attr="aria-label=${buttonOptions.name},
title=${buttonOptions.name},
data-onclick=${buttonOptions.onclick}">
<span class="icon-regular button-icon" aria-hidden="true"
th:utext="${not #strings.isEmpty(regularIcon) ? regularIcon : pixelIcon}"></span>
<span class="icon-pixel button-icon" aria-hidden="true"
th:utext="${not #strings.isEmpty(pixelIcon) ? pixelIcon : regularIcon}"></span>
</button>
</th:block>
</div> </div>
<nav class="navigation-menu"> <nav class="navigation-menu">
<ul th:if="${menu != null} and ${not #lists.isEmpty(menu.menuItems)}" <ul th:if="${menu != null} and ${not #lists.isEmpty(menu.menuItems)}"