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