fix(view): group and theme writeback blocks

Render contiguous writeback comment lines as one block, and map output-card/writeback tokens to the View dark theme. Static and live pages no longer show three dashed fragments or light output cards on dark.
This commit is contained in:
cflmy committed 2026-10-18 13:51:11 +08:00
1 parent ab6648ae0e
commit 92b91ffc81
2 files changed
+43 -9

No files matched your search

+10 -3
View File
@@ -101,11 +101,18 @@ pub fn render_module_document(module: &Module, source: &str, annots: &[ViewAnnot
}
LineKind::Writeback => {
flush_para(&mut para, &mut out);
let start_line = l.line_no;
let mut block = String::new();
while i < lines.len() && matches!(lines[i].kind, LineKind::Writeback) {
if !block.is_empty() {
block.push('\n');
}
block.push_str(lines[i].text.trim_end_matches(['\r', '\n']));
i += 1;
}
out.push_str(&crate::view::render::render_writeback_source_line(
l.line_no,
l.text.trim_end_matches(['\r', '\n']),
start_line, &block,
));
i += 1;
}
LineKind::Comment => {
let text = l.text.trim_end_matches(['\r', '\n']);
+33 -6
View File
@@ -1039,20 +1039,18 @@ body.notebook-page .exec-clear:hover { border-color: var(--nb-accent); color: va
}
.doc-writeback {
margin: 0.35rem 0;
padding: 0.4rem 0.55rem;
padding: 0.45rem 0.6rem;
border-radius: 8px;
border: 1px dashed #94a3b8;
background: #f1f5f9;
display: flex;
flex-wrap: wrap;
gap: 0.4rem 0.65rem;
align-items: baseline;
}
.doc-writeback[data-wb-kind="image"] {
border-color: #0d9488;
background: #f0fdfa;
}
.wb-source-badge {
display: inline-block;
margin-bottom: 0.28rem;
font: 0.68rem/1.2 var(--sans);
letter-spacing: 0.04em;
text-transform: uppercase;
@@ -1066,10 +1064,11 @@ body.notebook-page .exec-clear:hover { border-color: var(--nb-accent); color: va
color: #115e59;
}
.wb-source-text {
display: block;
font: 0.82rem/1.4 var(--mono);
color: #0f172a;
white-space: pre-wrap;
word-break: break-all;
word-break: break-word;
}
.wb-outline {
margin-top: 0.75rem;
@@ -3498,6 +3497,34 @@ body.notebook-page .stdin-form button {
color: #fff;
}
body.notebook-page .output-card {
background: var(--nb-surface-2);
border-left-color: var(--nb-accent);
}
body.notebook-page .output-card.output-card-image { border-left-color: var(--nb-success); }
body.notebook-page .output-card .wb-badges { color: var(--nb-muted); }
body.notebook-page .output-card .output-body {
color: var(--nb-text);
background: var(--nb-bg);
}
body.notebook-page .wb-badge {
background: var(--nb-surface-3);
color: var(--nb-text);
border-color: var(--nb-border);
}
body.notebook-page .wb-badge.wb-ok { background: #143d2b; color: #86efac; }
body.notebook-page .wb-badge.wb-error { background: #4a1d1d; color: #fca5a5; }
body.notebook-page .wb-badge.wb-trace { background: #2e2a5a; color: #c7d2fe; }
body.notebook-page .doc-writeback {
background: var(--nb-surface-2);
border-color: var(--nb-border);
}
body.notebook-page .wb-source-badge {
background: var(--nb-surface-3);
color: var(--nb-muted);
}
body.notebook-page .wb-source-text { color: var(--nb-text); }
/* ── Narrow preview panes ──────────────────────────────────────────── */
@media (max-width: 760px) {
body.notebook-page main.panel { padding: 1rem 0.75rem 3.5rem; }