feat: add configurable header actions
This commit is contained in:
@@ -29,7 +29,10 @@ header.search.open=Open search
|
|||||||
header.color_scheme.open=Choose color scheme
|
header.color_scheme.open=Choose color scheme
|
||||||
header.color_scheme.list=Color schemes
|
header.color_scheme.list=Color schemes
|
||||||
header.color_scheme.current=Current color scheme
|
header.color_scheme.current=Current color scheme
|
||||||
header.theme.toggle=Toggle light or dark mode
|
header.appearance.current=Current appearance
|
||||||
|
header.appearance.light=Light
|
||||||
|
header.appearance.dark=Dark
|
||||||
|
header.appearance.system=System
|
||||||
header.pixel_style.toggle=Toggle pixel style
|
header.pixel_style.toggle=Toggle pixel style
|
||||||
toc.show=Show table of contents
|
toc.show=Show table of contents
|
||||||
toc.hide=Hide table of contents
|
toc.hide=Hide table of contents
|
||||||
@@ -53,4 +56,4 @@ page.links.apply.field.feedUrls.placeholder=One URL per line
|
|||||||
page.links.apply.field.captcha=CAPTCHA
|
page.links.apply.field.captcha=CAPTCHA
|
||||||
page.links.apply.field.captcha.alt=CAPTCHA
|
page.links.apply.field.captcha.alt=CAPTCHA
|
||||||
page.links.apply.field.captcha.title=Click to refresh CAPTCHA
|
page.links.apply.field.captcha.title=Click to refresh CAPTCHA
|
||||||
page.links.apply.field.captcha.expired=CAPTCHA expired
|
page.links.apply.field.captcha.expired=CAPTCHA expired
|
||||||
|
|||||||
+5
-2
@@ -29,7 +29,10 @@ header.search.open=Open search
|
|||||||
header.color_scheme.open=Choose color scheme
|
header.color_scheme.open=Choose color scheme
|
||||||
header.color_scheme.list=Color schemes
|
header.color_scheme.list=Color schemes
|
||||||
header.color_scheme.current=Current color scheme
|
header.color_scheme.current=Current color scheme
|
||||||
header.theme.toggle=Toggle light or dark mode
|
header.appearance.current=Current appearance
|
||||||
|
header.appearance.light=Light
|
||||||
|
header.appearance.dark=Dark
|
||||||
|
header.appearance.system=System
|
||||||
header.pixel_style.toggle=Toggle pixel style
|
header.pixel_style.toggle=Toggle pixel style
|
||||||
toc.show=Show table of contents
|
toc.show=Show table of contents
|
||||||
toc.hide=Hide table of contents
|
toc.hide=Hide table of contents
|
||||||
@@ -53,4 +56,4 @@ page.links.apply.field.feedUrls.placeholder=One URL per line
|
|||||||
page.links.apply.field.captcha=CAPTCHA
|
page.links.apply.field.captcha=CAPTCHA
|
||||||
page.links.apply.field.captcha.alt=CAPTCHA
|
page.links.apply.field.captcha.alt=CAPTCHA
|
||||||
page.links.apply.field.captcha.title=Click to refresh CAPTCHA
|
page.links.apply.field.captcha.title=Click to refresh CAPTCHA
|
||||||
page.links.apply.field.captcha.expired=CAPTCHA expired
|
page.links.apply.field.captcha.expired=CAPTCHA expired
|
||||||
|
|||||||
+5
-2
@@ -29,7 +29,10 @@ header.search.open=Abrir búsqueda
|
|||||||
header.color_scheme.open=Elegir esquema de color
|
header.color_scheme.open=Elegir esquema de color
|
||||||
header.color_scheme.list=Esquemas de color
|
header.color_scheme.list=Esquemas de color
|
||||||
header.color_scheme.current=Esquema de color actual
|
header.color_scheme.current=Esquema de color actual
|
||||||
header.theme.toggle=Cambiar entre modo claro y oscuro
|
header.appearance.current=Apariencia actual
|
||||||
|
header.appearance.light=Claro
|
||||||
|
header.appearance.dark=Oscuro
|
||||||
|
header.appearance.system=Sistema
|
||||||
header.pixel_style.toggle=Activar o desactivar el estilo píxel
|
header.pixel_style.toggle=Activar o desactivar el estilo píxel
|
||||||
toc.show=Mostrar tabla de contenido
|
toc.show=Mostrar tabla de contenido
|
||||||
toc.hide=Ocultar tabla de contenido
|
toc.hide=Ocultar tabla de contenido
|
||||||
@@ -53,4 +56,4 @@ page.links.apply.field.feedUrls.placeholder=Una URL por línea
|
|||||||
page.links.apply.field.captcha=CAPTCHA
|
page.links.apply.field.captcha=CAPTCHA
|
||||||
page.links.apply.field.captcha.alt=CAPTCHA
|
page.links.apply.field.captcha.alt=CAPTCHA
|
||||||
page.links.apply.field.captcha.title=Haz clic para actualizar el CAPTCHA
|
page.links.apply.field.captcha.title=Haz clic para actualizar el CAPTCHA
|
||||||
page.links.apply.field.captcha.expired=El CAPTCHA ha caducado
|
page.links.apply.field.captcha.expired=El CAPTCHA ha caducado
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ header.search.open=打开搜索
|
|||||||
header.color_scheme.open=选择配色
|
header.color_scheme.open=选择配色
|
||||||
header.color_scheme.list=配色列表
|
header.color_scheme.list=配色列表
|
||||||
header.color_scheme.current=当前配色
|
header.color_scheme.current=当前配色
|
||||||
header.theme.toggle=切换深色或浅色模式
|
header.appearance.current=当前外观模式
|
||||||
|
header.appearance.light=浅色
|
||||||
|
header.appearance.dark=深色
|
||||||
|
header.appearance.system=跟随系统
|
||||||
header.pixel_style.toggle=切换像素风格
|
header.pixel_style.toggle=切换像素风格
|
||||||
toc.show=显示文章目录
|
toc.show=显示文章目录
|
||||||
toc.hide=隐藏文章目录
|
toc.hide=隐藏文章目录
|
||||||
@@ -53,4 +56,4 @@ page.links.apply.field.feedUrls.placeholder=每行填写一个地址
|
|||||||
page.links.apply.field.captcha=验证码
|
page.links.apply.field.captcha=验证码
|
||||||
page.links.apply.field.captcha.alt=验证码
|
page.links.apply.field.captcha.alt=验证码
|
||||||
page.links.apply.field.captcha.title=点击刷新验证码
|
page.links.apply.field.captcha.title=点击刷新验证码
|
||||||
page.links.apply.field.captcha.expired=验证码已过期
|
page.links.apply.field.captcha.expired=验证码已过期
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ header.search.open=開啟搜尋
|
|||||||
header.color_scheme.open=選擇配色
|
header.color_scheme.open=選擇配色
|
||||||
header.color_scheme.list=配色清單
|
header.color_scheme.list=配色清單
|
||||||
header.color_scheme.current=目前配色
|
header.color_scheme.current=目前配色
|
||||||
header.theme.toggle=切換深色或淺色模式
|
header.appearance.current=目前外觀模式
|
||||||
|
header.appearance.light=淺色
|
||||||
|
header.appearance.dark=深色
|
||||||
|
header.appearance.system=跟隨系統
|
||||||
header.pixel_style.toggle=切換像素風格
|
header.pixel_style.toggle=切換像素風格
|
||||||
toc.show=顯示文章目錄
|
toc.show=顯示文章目錄
|
||||||
toc.hide=隱藏文章目錄
|
toc.hide=隱藏文章目錄
|
||||||
@@ -53,4 +56,4 @@ page.links.apply.field.feedUrls.placeholder=每行填寫一個地址
|
|||||||
page.links.apply.field.captcha=驗證碼
|
page.links.apply.field.captcha=驗證碼
|
||||||
page.links.apply.field.captcha.alt=驗證碼
|
page.links.apply.field.captcha.alt=驗證碼
|
||||||
page.links.apply.field.captcha.title=點擊重新整理驗證碼
|
page.links.apply.field.captcha.title=點擊重新整理驗證碼
|
||||||
page.links.apply.field.captcha.expired=驗證碼已過期
|
page.links.apply.field.captcha.expired=驗證碼已過期
|
||||||
|
|||||||
@@ -48,6 +48,21 @@ spec:
|
|||||||
label: 默认像素化风格
|
label: 默认像素化风格
|
||||||
value: false
|
value: false
|
||||||
help: 开启后将默认使用像素风格字体及图标
|
help: 开启后将默认使用像素风格字体及图标
|
||||||
|
- $formkit: checkbox
|
||||||
|
name: search_button_enable
|
||||||
|
label: 展示搜索按钮
|
||||||
|
value: true
|
||||||
|
help: 搜索组件插件可用时在页头展示搜索按钮
|
||||||
|
- $formkit: checkbox
|
||||||
|
name: appearance_switcher_enable
|
||||||
|
label: 展示深浅切换按钮
|
||||||
|
value: true
|
||||||
|
help: 在页头展示浅色, 深色和跟随系统三态切换按钮
|
||||||
|
- $formkit: checkbox
|
||||||
|
name: pixel_style_switcher_enable
|
||||||
|
label: 展示像素化按钮
|
||||||
|
value: true
|
||||||
|
help: 在页头展示像素风格切换按钮
|
||||||
- $formkit: checkbox
|
- $formkit: checkbox
|
||||||
name: custom_font_enable
|
name: custom_font_enable
|
||||||
id: custom_font_enable
|
id: custom_font_enable
|
||||||
|
|||||||
@@ -1,5 +1,34 @@
|
|||||||
import {syncColorSchemePicker} from "./color-scheme-picker.js";
|
import {syncColorSchemePicker} from "./color-scheme-picker.js";
|
||||||
import {getStoredPreference, PREFERENCE_KEYS, setStoredPreference} from "../utils/theme-preferences.js";
|
import {getStoredPreference, PREFERENCE_KEYS, setStoredPreference} from "../utils/theme-preferences.js";
|
||||||
|
import {getMessage} from "../utils/messages.js";
|
||||||
|
|
||||||
|
const APPEARANCE_MODES = ["light", "dark", "system"];
|
||||||
|
|
||||||
|
function getAppearanceMode() {
|
||||||
|
const mode = document.documentElement.dataset.themeMode
|
||||||
|
|| getStoredPreference(PREFERENCE_KEYS.themeMode)
|
||||||
|
|| window.TerminalThemeConfig?.defaultMode;
|
||||||
|
|
||||||
|
return APPEARANCE_MODES.includes(mode) ? mode : "system";
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncAppearanceToggle(toggle) {
|
||||||
|
const mode = getAppearanceMode();
|
||||||
|
const fallbackLabels = {
|
||||||
|
light: "Light",
|
||||||
|
dark: "Dark",
|
||||||
|
system: "System"
|
||||||
|
};
|
||||||
|
const currentLabel = getMessage("currentAppearance", "Current appearance");
|
||||||
|
const modeLabel = getMessage(
|
||||||
|
`appearance${mode[0].toUpperCase()}${mode.slice(1)}`,
|
||||||
|
fallbackLabels[mode]
|
||||||
|
);
|
||||||
|
const description = `${currentLabel}: ${modeLabel}`;
|
||||||
|
|
||||||
|
toggle.setAttribute("aria-label", description);
|
||||||
|
toggle.title = description;
|
||||||
|
}
|
||||||
|
|
||||||
function registerSearchButton() {
|
function registerSearchButton() {
|
||||||
const searchButton = document.querySelector('[data-header-action="open-search"]');
|
const searchButton = document.querySelector('[data-header-action="open-search"]');
|
||||||
@@ -12,16 +41,21 @@ function registerSearchButton() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerThemeToggle() {
|
function registerAppearanceToggle() {
|
||||||
const toggle = document.getElementById("theme-toggle");
|
const toggle = document.getElementById("appearance-toggle");
|
||||||
if (!toggle || typeof window.applyTheme !== "function") return;
|
if (!toggle || typeof window.applyTheme !== "function") return;
|
||||||
|
|
||||||
|
syncAppearanceToggle(toggle);
|
||||||
|
|
||||||
toggle.addEventListener("click", function () {
|
toggle.addEventListener("click", function () {
|
||||||
const currentScheme = document.documentElement.dataset.colorScheme;
|
const currentMode = getAppearanceMode();
|
||||||
const nextMode = currentScheme === "dark" ? "light" : "dark";
|
const nextMode = APPEARANCE_MODES[
|
||||||
|
(APPEARANCE_MODES.indexOf(currentMode) + 1) % APPEARANCE_MODES.length
|
||||||
|
];
|
||||||
|
|
||||||
window.applyTheme(nextMode, {clearColorScheme: true});
|
window.applyTheme(nextMode, {clearColorScheme: true});
|
||||||
setStoredPreference(PREFERENCE_KEYS.themeMode, nextMode);
|
setStoredPreference(PREFERENCE_KEYS.themeMode, nextMode);
|
||||||
|
syncAppearanceToggle(toggle);
|
||||||
syncColorSchemePicker();
|
syncColorSchemePicker();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -44,6 +78,6 @@ function registerPixelToggle() {
|
|||||||
|
|
||||||
export function registerHeaderActions() {
|
export function registerHeaderActions() {
|
||||||
registerSearchButton();
|
registerSearchButton();
|
||||||
registerThemeToggle();
|
registerAppearanceToggle();
|
||||||
registerPixelToggle();
|
registerPixelToggle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#color-scheme-trigger,
|
#color-scheme-trigger,
|
||||||
#theme-toggle,
|
#appearance-toggle,
|
||||||
#search-button,
|
#search-button,
|
||||||
#pixel-toggle {
|
#pixel-toggle {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#theme-toggle,
|
#appearance-toggle,
|
||||||
#search-button,
|
#search-button,
|
||||||
#pixel-toggle {
|
#pixel-toggle {
|
||||||
margin-left: calc(var(--size-theme-font) * 0.5);
|
margin-left: calc(var(--size-theme-font) * 0.5);
|
||||||
|
|||||||
+14
-1
@@ -13,4 +13,17 @@ html[data-pixel-style='false'] .icon-regular {
|
|||||||
|
|
||||||
html[data-pixel-style='true'] .icon-pixel {
|
html[data-pixel-style='true'] .icon-pixel {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#appearance-toggle .appearance-icon {
|
||||||
|
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'] {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
th:attr="aria-label=#{header.search.open}"
|
th:attr="aria-label=#{header.search.open}"
|
||||||
type="button"
|
type="button"
|
||||||
data-header-action="open-search"
|
data-header-action="open-search"
|
||||||
th:if="${pluginFinder.available('PluginSearchWidget')}">
|
th:if="${theme.config.style.search_button_enable != false and pluginFinder.available('PluginSearchWidget')}">
|
||||||
<svg class="icon-regular button-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
<svg class="icon-regular button-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
<path
|
<path
|
||||||
fill="currentColor"
|
fill="currentColor"
|
||||||
@@ -61,20 +61,46 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button id="theme-toggle" th:attr="aria-label=#{header.theme.toggle}" type="button">
|
<button
|
||||||
<svg class="icon-regular button-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
|
id="appearance-toggle"
|
||||||
preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24">
|
th:attr="aria-label=#{header.appearance.current}"
|
||||||
<path
|
th:if="${theme.config.style.appearance_switcher_enable != false}"
|
||||||
fill="currentColor"
|
type="button">
|
||||||
d="M7.5 2c-1.79 1.15-3 3.18-3 5.5s1.21 4.35 3.03 5.5C4.46 13 2 10.54 2 7.5A5.5 5.5 0 0 1 7.5 2m11.57 1.5l1.43 1.43L4.93 20.5L3.5 19.07L19.07 3.5m-6.18 2.43L11.41 5L9.97 6l.42-1.7L9 3.24l1.75-.12l.58-1.65L12 3.1l1.73.03l-1.35 1.13l.51 1.67m-3.3 3.61l-1.16-.73l-1.12.78l.34-1.32l-1.09-.83l1.36-.09l.45-1.29l.51 1.27l1.36.03l-1.05.87l.4 1.31M19 13.5a5.5 5.5 0 0 1-5.5 5.5c-1.22 0-2.35-.4-3.26-1.07l7.69-7.69c.67.91 1.07 2.04 1.07 3.26m-4.4 6.58l2.77-1.15l-.24 3.35l-2.53-2.2m4.33-2.7l1.15-2.77l2.2 2.54l-3.35.23m1.15-4.96l-1.14-2.78l3.34.24l-2.2 2.54M9.63 18.93l2.77 1.15l-2.53 2.19l-.24-3.34Z"
|
<svg class="appearance-icon icon-regular button-icon" data-appearance-mode="light" aria-hidden="true"
|
||||||
/>
|
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
|
<circle cx="12" cy="12" r="4" fill="currentColor"/>
|
||||||
|
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2"
|
||||||
|
d="M12 2v2m0 16v2M4.93 4.93l1.42 1.42m11.3 11.3l1.42 1.42M2 12h2m16 0h2M4.93 19.07l1.42-1.42m11.3-11.3l1.42-1.42"/>
|
||||||
</svg>
|
</svg>
|
||||||
<svg class="icon-pixel button-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
<svg class="appearance-icon icon-pixel button-icon" data-appearance-mode="light" aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
<path fill="currentColor"
|
<path fill="currentColor"
|
||||||
d="M11 0h2v4h-2zm1 12H8v2H4v2H2v4h2v2h10v-2h2v-4h-2v-2h-2zm0 2v2h2v4H4v-4h4v2h2v-2H8v-2zM8 6h6v2H8zm0 2v2H6V8zm8 2h-2V8h2zm0 0h2v2h-2zm4-8h2v2h-2zm0 2v2h-2V4zM2 2h2v2H2zm2 2h2v2H4zm20 7h-4v2h4z"/>
|
d="M10 0h4v4h-4zM10 20h4v4h-4zM0 10h4v4H0zM20 10h4v4h-4zM4 4h3v3H4zM17 4h3v3h-3zM4 17h3v3H4zM17 17h3v3h-3zM8 8h8v8H8z"/>
|
||||||
|
</svg>
|
||||||
|
<svg class="appearance-icon icon-regular button-icon" data-appearance-mode="dark" aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor" d="M20.69 15.95A9 9 0 0 1 8.05 3.31a9 9 0 1 0 12.64 12.64Z"/>
|
||||||
|
</svg>
|
||||||
|
<svg class="appearance-icon icon-pixel button-icon" data-appearance-mode="dark" aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor"
|
||||||
|
d="M8 2h6v2h-2v2h-2v6h2v2h6v-2h2v4h-2v2h-2v2H8v-2H6v-2H4V8h2V4h2z"/>
|
||||||
|
</svg>
|
||||||
|
<svg class="appearance-icon icon-regular button-icon" data-appearance-mode="system" aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
|
<circle cx="12" cy="12" r="8" fill="none" stroke="currentColor" stroke-width="2"/>
|
||||||
|
</svg>
|
||||||
|
<svg class="appearance-icon icon-pixel button-icon" data-appearance-mode="system" aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor"
|
||||||
|
d="M8 2h8v2h4v4h2v8h-2v4h-4v2H8v-2H4v-4H2V8h2V4h4v2H6v2H4v8h2v2h2v2h8v-2h2v-2h2V8h-2V6h-2V4H8z"/>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<button id="pixel-toggle" th:attr="aria-label=#{header.pixel_style.toggle}" type="button">
|
<button
|
||||||
|
id="pixel-toggle"
|
||||||
|
th:attr="aria-label=#{header.pixel_style.toggle}"
|
||||||
|
th:if="${theme.config.style.pixel_style_switcher_enable != false}"
|
||||||
|
type="button">
|
||||||
<svg class="icon-pixel button-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
<svg class="icon-pixel button-icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
<path fill="currentColor"
|
<path fill="currentColor"
|
||||||
d="M22 17h2v2h-2Zm-1 2h1v2h-1Zm1-6V9h1V6h-4v3h2v4h1zm-3 8h2v1h-2Zm0-8h2v1h-2Zm-1 9h1v2h-1Zm0-8h1v1h-1Zm-1 1h1v1h-1Zm-1 1h1v8h-1Zm1-3V3h1V0h-3v3h1v10ZM16 1h1v1h-1Zm-1 12h1v1h-1Zm-1 1h1v10h-1Zm-4-3h1v13h2V11h1V8h-4v3zm-1 3h1v10H9Zm-1-1h1v1H8Zm-1 5h1v6H7ZM8 7h1V3H6v4h1v6h1V7zM6 17h1v1H6Zm-1 5h1v2H5Zm0-6h1v1H5Zm1-1v-4H2v4h1v1h2v-1Zm-3-1v-1h2v1Zm0 7h2v1H3Zm-1-2h1v2H2Zm-2-2h2v2H0Z"/>
|
d="M22 17h2v2h-2Zm-1 2h1v2h-1Zm1-6V9h1V6h-4v3h2v4h1zm-3 8h2v1h-2Zm0-8h2v1h-2Zm-1 9h1v2h-1Zm0-8h1v1h-1Zm-1 1h1v1h-1Zm-1 1h1v8h-1Zm1-3V3h1V0h-3v3h1v10ZM16 1h1v1h-1Zm-1 12h1v1h-1Zm-1 1h1v10h-1Zm-4-3h1v13h2V11h1V8h-4v3zm-1 3h1v10H9Zm-1-1h1v1H8Zm-1 5h1v6H7ZM8 7h1V3H6v4h1v6h1V7zM6 17h1v1H6Zm-1 5h1v2H5Zm0-6h1v1H5Zm1-1v-4H2v4h1v1h2v-1Zm-3-1v-1h2v1Zm0 7h2v1H3Zm-1-2h1v2H2Zm-2-2h2v2H0Z"/>
|
||||||
|
|||||||
@@ -12,6 +12,10 @@
|
|||||||
customCss: /*[[${theme.config.style.custom}]]*/ "",
|
customCss: /*[[${theme.config.style.custom}]]*/ "",
|
||||||
messages: {
|
messages: {
|
||||||
currentColorScheme: /*[[#{header.color_scheme.current}]]*/ "Current color scheme",
|
currentColorScheme: /*[[#{header.color_scheme.current}]]*/ "Current color scheme",
|
||||||
|
currentAppearance: /*[[#{header.appearance.current}]]*/ "Current appearance",
|
||||||
|
appearanceLight: /*[[#{header.appearance.light}]]*/ "Light",
|
||||||
|
appearanceDark: /*[[#{header.appearance.dark}]]*/ "Dark",
|
||||||
|
appearanceSystem: /*[[#{header.appearance.system}]]*/ "System",
|
||||||
showToc: /*[[#{toc.show}]]*/ "Show table of contents",
|
showToc: /*[[#{toc.show}]]*/ "Show table of contents",
|
||||||
hideToc: /*[[#{toc.hide}]]*/ "Hide table of contents",
|
hideToc: /*[[#{toc.hide}]]*/ "Hide table of contents",
|
||||||
networkError: /*[[#{moment.network_error}]]*/ "Network error. Please try again."
|
networkError: /*[[#{moment.network_error}]]*/ "Network error. Please try again."
|
||||||
@@ -87,12 +91,18 @@
|
|||||||
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeThemeMode(mode) {
|
||||||
|
return ["light", "dark", "system"].includes(mode) ? mode : "system";
|
||||||
|
}
|
||||||
|
|
||||||
function applyTheme(mode, options = {}) {
|
function applyTheme(mode, options = {}) {
|
||||||
if (options.clearColorScheme) {
|
if (options.clearColorScheme) {
|
||||||
removeStoredPreference(storageKeys.colorScheme);
|
removeStoredPreference(storageKeys.colorScheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
const actualMode = mode === "system" ? getSystemScheme() : mode;
|
const normalizedMode = normalizeThemeMode(mode);
|
||||||
|
const actualMode = normalizedMode === "system" ? getSystemScheme() : normalizedMode;
|
||||||
|
root.dataset.themeMode = normalizedMode;
|
||||||
root.dataset.colorScheme = actualMode;
|
root.dataset.colorScheme = actualMode;
|
||||||
root.dataset.themeColorScheme = getStoredColorScheme() || resolveTheme(actualMode);
|
root.dataset.themeColorScheme = getStoredColorScheme() || resolveTheme(actualMode);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user