Files
hermes-web/packages/client/src/styles/code-block.scss
T
toor 4ddf5337ad collapse the syntax theme to one dark palette
code-block.scss carried two full highlight.js themes — a light set plus a
.dark override — left over from the ink era, with keywords in violet and
no relationship to the rest of the surface. CYBER has a single dark
theme, so keep one rule set and pull every token color from the existing
semantic variables: cyan for keywords, green for strings, amber for
literals, red for types. Keywords matching the accent keeps a code block
from competing with the chrome.

Diff line chrome also moves off the old slate values onto tokens, and the
code header now reads as part of the block instead of a light strip.
2026-10-19 14:42:47 +08:00

196 lines
4.2 KiB
SCSS

@use 'variables' as *;
// Shared code-block styles used by markdown rendering and tool payload details.
// Keep these global so v-html output in both MarkdownRenderer.vue and MessageItem.vue
// stays styled even though the HTML is not compiled as Vue template content.
//
// CYBER is a single dark theme, so there is no light variant: one rule set,
// one palette. Syntax colors stay inside the established semantic set — cyan for
// structure, green for strings, amber for literals, red for types, muted for
// comments — so a code block never competes with the neon accent for attention.
.hljs-code-block {
margin: 8px 0;
border-radius: $radius-sm;
overflow: hidden;
background: $code-bg;
border: 1px solid $border-color;
box-sizing: border-box;
width: 100%;
max-width: 100%;
min-width: 0;
white-space: normal;
.code-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 6px 12px;
background: $bg-card;
border-bottom: 1px solid var(--border-light);
.code-lang {
font-size: 11px;
color: $accent-primary;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.copy-btn {
font-size: 11px;
color: $text-muted;
background: none;
border: none;
cursor: pointer;
padding: 2px 6px;
border-radius: 3px;
transition: color $transition-fast, background-color $transition-fast;
&:hover {
color: $accent-primary;
background: rgba(var(--accent-primary-rgb), 0.1);
}
}
}
code.hljs {
display: block;
padding: 12px;
font-family: $font-code;
font-size: 13px;
line-height: 1.5;
overflow-x: auto;
white-space: pre-wrap;
overflow-wrap: anywhere;
word-break: break-word;
}
&.hljs-unified-diff {
code.hljs {
display: block;
padding: 0;
overflow-x: auto;
white-space: pre;
overflow-wrap: normal;
word-break: normal;
line-height: 1.45;
}
.diff-line {
display: grid;
grid-template-columns: 58px max-content;
min-width: max-content;
white-space: pre;
}
.diff-line-number {
user-select: none;
text-align: right;
padding: 0 14px 0 10px;
color: var(--text-faint);
background: rgba(0, 0, 0, 0.22);
border-right: 1px solid var(--border-light);
}
.diff-line-content {
padding: 0 12px;
white-space: pre;
}
.diff-line-file-header {
color: $text-secondary;
background: rgba(var(--accent-info-rgb), 0.16);
}
.diff-line-hunk-header {
color: $accent-primary;
background: rgba(var(--accent-primary-rgb), 0.12);
}
.diff-line-context-fold {
color: var(--text-faint);
background: rgba(255, 255, 255, 0.05);
font-style: italic;
}
.diff-line-added {
color: $success;
background: rgba(var(--success-rgb), 0.14);
.diff-line-number {
color: $success;
background: rgba(var(--success-rgb), 0.2);
}
}
.diff-line-removed {
color: $error;
background: rgba(var(--error-rgb), 0.14);
.diff-line-number {
color: $error;
background: rgba(var(--error-rgb), 0.2);
}
}
}
}
// ─── highlight.js token colors ───────────────────────────────────────────
.hljs-code-block {
.hljs {
color: $text-primary;
background: none;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-meta .hljs-keyword {
color: $accent-primary;
font-weight: 600;
}
.hljs-string,
.hljs-attr,
.hljs-regexp,
.hljs-template-variable {
color: $success;
}
.hljs-number,
.hljs-literal,
.hljs-symbol,
.hljs-bullet {
color: $warning;
}
.hljs-comment,
.hljs-quote {
color: var(--text-faint);
font-style: italic;
}
.hljs-built_in,
.hljs-title.class_,
.hljs-title.function_ {
color: $info;
}
.hljs-type,
.hljs-variable,
.hljs-property,
.hljs-params {
color: $error;
}
.hljs-tag,
.hljs-name,
.hljs-section,
.hljs-title {
color: $text-primary;
}
.hljs-meta {
color: var(--text-muted);
}
}