feat(frontend): enhance dark mode syntax highlighting for code previews

- Added global styles to remap syntax highlighting colors for dark mode in the document preview component.
- Ensured that all highlighted code blocks are visually accessible against the dark background, improving readability for users in dark mode.
This commit is contained in:
wizardchen
2026-06-09 21:13:15 +08:00
committed by lyingbug
parent c6fc315042
commit ce3702b6de
@@ -834,3 +834,90 @@ onUnmounted(() => {
}
}
</style>
<!-- highlight.js github.css is a light theme imported globally; its token
colors (notably the base #24292e) become unreadable on the dark
container background used in dark mode. Remap the palette to the
github-dark colors when dark mode is active. Non-scoped on purpose so
it covers every hljs block (txt/code preview, markdown code fences). -->
<style lang="less">
html[theme-mode="dark"] {
.hljs {
color: #c9d1d9;
background: transparent;
}
.hljs-doctag,
.hljs-keyword,
.hljs-meta .hljs-keyword,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-variable.language_ {
color: #ff7b72;
}
.hljs-title,
.hljs-title.class_,
.hljs-title.class_.inherited__,
.hljs-title.function_ {
color: #d2a8ff;
}
.hljs-attr,
.hljs-attribute,
.hljs-literal,
.hljs-meta,
.hljs-number,
.hljs-operator,
.hljs-variable,
.hljs-selector-attr,
.hljs-selector-class,
.hljs-selector-id {
color: #79c0ff;
}
.hljs-regexp,
.hljs-string,
.hljs-meta .hljs-string {
color: #a5d6ff;
}
.hljs-built_in,
.hljs-symbol {
color: #ffa657;
}
.hljs-comment,
.hljs-code,
.hljs-formula {
color: #8b949e;
}
.hljs-name,
.hljs-quote,
.hljs-selector-tag,
.hljs-selector-pseudo {
color: #7ee787;
}
.hljs-subst {
color: #c9d1d9;
}
.hljs-section {
color: #1f6feb;
font-weight: bold;
}
.hljs-bullet {
color: #f2cc60;
}
.hljs-emphasis {
color: #c9d1d9;
font-style: italic;
}
.hljs-strong {
color: #c9d1d9;
font-weight: bold;
}
.hljs-addition {
color: #aff5b4;
background-color: #033a16;
}
.hljs-deletion {
color: #ffdcd7;
background-color: #67060c;
}
}
</style>