feat(ui): design-council polish overhaul
CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
Eight arbitrated rounds over the workspace surface: piece-scoped Mentor hosting, conversation-voice system messages, glyph-measured roster truncation, bounded learnings/archive columns, symmetric trends grid, top-aligned settings forms, serif editor titles, outline rail rhythm, launch auto-focus root fix. New seams pinned by SessionScopeTests + WordBoundaryTruncationTests; full suite green.
This commit is contained in:
1 parent
b2db859887
commit
3a7d495b4b
21 files changed
+2287
-516
No files matched your search
+125
-24
@@ -92,6 +92,26 @@ nonisolated enum OutlinePresenter {
|
||||
nodes.reduce(0) { $0 + 1 + countTree($1.children) }
|
||||
}
|
||||
|
||||
/// Top padding per visible row id — the branch rhythm
|
||||
/// (`ProseTypography.outlineBranchSpacing`) before a row that opens a
|
||||
/// top-level parent group (#ui-r5 argon#14) or FOLLOWS A DEEPER row:
|
||||
/// a nested block just closed, and its transition back to the parent
|
||||
/// level reads the SAME gap whatever follows — parent or leaf, any
|
||||
/// depth (#ui-r8 argon#7: the gap after one nested sublist read ~38px,
|
||||
/// after another ~28px, because only a parent follower carried the
|
||||
/// padding). Pure over the projection; zoom's re-based depths included.
|
||||
static func spacingBefore(rows: [Row]) -> [UUID: CGFloat] {
|
||||
var out: [UUID: CGFloat] = [:]
|
||||
for (index, row) in rows.enumerated() {
|
||||
let opensBranch = row.depth == 0 && row.childCount > 0
|
||||
let closesNested = index > 0 && rows[index - 1].depth > row.depth
|
||||
if opensBranch || closesNested {
|
||||
out[row.id] = ProseTypography.outlineBranchSpacing
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/// The visible-row ids from `from` to `to`, inclusive, in visible
|
||||
/// order; nil when either id isn't visible. Block-selection range
|
||||
/// math (⇧↑/⇧↓ anchor↔focus). #112: zoom-aware — ids outside the
|
||||
@@ -190,6 +210,27 @@ nonisolated enum OutlinePresenter {
|
||||
|
||||
// MARK: - The surface
|
||||
|
||||
/// #ui-r4 (mercury#28): nesting geometry — 30px per level (r3's 18px
|
||||
/// read flat; judges asked 28–32). #ui-r5 (argon#1): guide rails sit on
|
||||
/// the PARENT bullet's center column, the drop seam on the child bullet
|
||||
/// column. DropGeometry (OutlineDrag.swift) still owns the 20pt grip
|
||||
/// margin; its 18-based rail constants are no longer read by this chrome.
|
||||
private enum NestGeometry {
|
||||
static let unit: CGFloat = 30
|
||||
/// The bullet cell's width (bullet() frames its glyph 22×27).
|
||||
static let bulletCell: CGFloat = 22
|
||||
|
||||
/// A depth-d row's TEXT column, from the row's leading edge.
|
||||
static func textColumn(depth: Int) -> CGFloat {
|
||||
DropGeometry.gripWidth + CGFloat(depth) * unit + bulletCell
|
||||
}
|
||||
|
||||
/// The bullet CENTER column — the drop seam's left edge.
|
||||
static func bulletColumn(depth: Int) -> CGFloat {
|
||||
textColumn(depth: depth) - DropGeometry.bulletCenter
|
||||
}
|
||||
}
|
||||
|
||||
/// The outline editing surface (#109): rows of chrome (guide rails,
|
||||
/// bullets, fold counts) around one live caret row. Session mode re-parses
|
||||
/// on `loadGeneration` bumps (open / Yes-reload); draft mode seeds from
|
||||
@@ -227,6 +268,7 @@ struct OutlineEditorView: View {
|
||||
|
||||
var body: some View {
|
||||
let rows = OutlinePresenter.visibleRows(nodes, folded: folded, zoomRootID: zoomStack.last)
|
||||
let rowSpacing = OutlinePresenter.spacingBefore(rows: rows)
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
if !zoomStack.isEmpty {
|
||||
breadcrumb
|
||||
@@ -248,8 +290,15 @@ struct OutlineEditorView: View {
|
||||
} else {
|
||||
ScrollView {
|
||||
LazyVStack(alignment: .leading, spacing: 0) {
|
||||
outlineTitleHeader
|
||||
ForEach(rows) { row in
|
||||
rowView(row)
|
||||
// #ui-r5 (argon#14) + #ui-r8 (argon#7): the
|
||||
// branch rhythm — a top-level parent group
|
||||
// separates from siblings, and every nested
|
||||
// block's close reads the SAME gap whatever
|
||||
// follows (parent or leaf, any depth).
|
||||
.padding(.top, rowSpacing[row.id] ?? 0)
|
||||
}
|
||||
}
|
||||
.padding(.top, 24)
|
||||
@@ -338,20 +387,13 @@ struct OutlineEditorView: View {
|
||||
private func rowView(_ row: OutlinePresenter.Row) -> some View {
|
||||
HStack(alignment: .top, spacing: 0) {
|
||||
gripCell(row)
|
||||
// Per-depth guide rails (prototype variant B: 1px hairline per
|
||||
// ancestor level, at DropGeometry's bulletCenter + level·railUnit
|
||||
// — same constants the drop seam uses, so rails and seam
|
||||
// cannot drift apart).
|
||||
Canvas { context, size in
|
||||
for level in 0 ..< row.depth {
|
||||
let railX = DropGeometry.bulletCenter + CGFloat(level) * DropGeometry.railUnit
|
||||
context.fill(
|
||||
Path(CGRect(x: railX, y: 0, width: 1, height: size.height)),
|
||||
with: .color(DesignTokens.border),
|
||||
)
|
||||
}
|
||||
}
|
||||
.frame(width: CGFloat(row.depth) * DropGeometry.railUnit)
|
||||
// #ui-r4 (mercury#28): the per-level indent is a plain spacer —
|
||||
// the guide rails moved to the row background (rails(depth:)),
|
||||
// where a stroke can sit on the CHILD text column, right of the
|
||||
// child bullet; the old in-stack canvas could never reach past
|
||||
// the indent region.
|
||||
Color.clear
|
||||
.frame(width: CGFloat(row.depth) * NestGeometry.unit)
|
||||
bullet(row)
|
||||
if row.id == focusedID {
|
||||
OutlineRowTextView(
|
||||
@@ -384,6 +426,8 @@ struct OutlineEditorView: View {
|
||||
}
|
||||
}
|
||||
.padding(.trailing, 20)
|
||||
// #ui-r4 (mercury#28): guide rails behind the selection wash.
|
||||
.background { rails(depth: row.depth) }
|
||||
// Block-selection highlight (⇧↑/⇧↓ / ⇧click range, anchor↔focus).
|
||||
.background(rowSelected(row) ? DesignTokens.accent.opacity(0.08) : Color.clear)
|
||||
// #112: the moving run lifts (prototype .lifted) while a drag runs.
|
||||
@@ -429,15 +473,15 @@ struct OutlineEditorView: View {
|
||||
}
|
||||
|
||||
/// The seam line: left edge at the dropped block's future bullet
|
||||
/// column (11 + d·18 + the 20pt margin), running to the row's end.
|
||||
/// The spacer is height-pinned to 2 — a flexible one expands the
|
||||
/// column (bulletCenter + d·30 + the 20pt margin), running to the
|
||||
/// row's end. The spacer is height-pinned to 2 — a flexible one expands the
|
||||
/// HStack to the row height and CENTERS the bar, drawing every seam
|
||||
/// half a row off (the row's own frame alignment then has nothing
|
||||
/// to align).
|
||||
private func seamLine(depth: Int, valid: Bool) -> some View {
|
||||
HStack(spacing: 0) {
|
||||
Color.clear
|
||||
.frame(width: DropGeometry.bulletColumn(depth: depth), height: 2)
|
||||
.frame(width: NestGeometry.bulletColumn(depth: depth), height: 2)
|
||||
Group {
|
||||
if valid {
|
||||
Rectangle().fill(DesignTokens.accent)
|
||||
@@ -453,30 +497,37 @@ struct OutlineEditorView: View {
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
|
||||
/// The bullet cell (22×27): fold toggle when the node has children
|
||||
/// ("●" ~7pt, folded → accent), leaf "◦" ~10pt; tapping a leaf focuses.
|
||||
/// The bullet cell (22×27): marker by DEPTH (#ui-r2, sol#12/argon#20/
|
||||
/// mercury#32) — every top-level row the SAME filled 10pt disc, every
|
||||
/// nested level the single smaller 7pt dot. Parent-vs-leaf no longer
|
||||
/// changes the glyph (the r1 ring-vs-dot pair still read as
|
||||
/// inconsistent same-rank markers); hierarchy reads from indentation
|
||||
/// + children presence. Ink one step darker (#ui-r2, sol#45):
|
||||
/// foreground at 0.8, not muted — markers belong to their text.
|
||||
/// The fold toggle stays on rows with children ("●" button, folded =
|
||||
/// accent + "⋯ N" count); tapping a leaf focuses.
|
||||
/// #112: double-click any bullet zooms in. The two clicks of the
|
||||
/// double-click round-trip the fold toggle (fold→unfold), so the
|
||||
/// zoomed-in projection opens with the node's fold state unchanged.
|
||||
@ViewBuilder
|
||||
private func bullet(_ row: OutlinePresenter.Row) -> some View {
|
||||
let foldable = row.childCount > 0
|
||||
let glyph = Text(foldable ? "●" : "◦")
|
||||
.font(.system(size: foldable ? 7 : 10))
|
||||
.foregroundStyle(row.isFolded ? DesignTokens.accent : DesignTokens.muted)
|
||||
let glyph = Text("●")
|
||||
.font(.system(size: row.depth == 0 ? 10 : 7))
|
||||
.foregroundStyle(row.isFolded ? DesignTokens.accent : DesignTokens.foreground.opacity(0.8))
|
||||
Group {
|
||||
if foldable {
|
||||
Button {
|
||||
toggleFold(row.id)
|
||||
} label: {
|
||||
glyph.frame(width: 22, height: 27)
|
||||
glyph.frame(width: NestGeometry.bulletCell, height: 27)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.help("fold/unfold (⌘↑ / ⌘↓) · double-click: zoom in")
|
||||
.accessibilityLabel(row.isFolded ? "Unfold \(row.text)" : "Fold \(row.text)")
|
||||
} else {
|
||||
glyph
|
||||
.frame(width: 22, height: 27)
|
||||
.frame(width: NestGeometry.bulletCell, height: 27)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { focus(row.id) }
|
||||
.help("double-click: zoom in")
|
||||
@@ -842,4 +893,54 @@ extension OutlineEditorView {
|
||||
onDraftEdit?(md)
|
||||
}
|
||||
}
|
||||
|
||||
/// #ui-r5 (argon#14): the piece's title at the prose editor's title
|
||||
/// rung (serif, 22) — the outline opens as a page, not a bare bullet
|
||||
/// list. The title text comes from `outlineTitle` below.
|
||||
@ViewBuilder
|
||||
private var outlineTitleHeader: some View {
|
||||
if let title = outlineTitle {
|
||||
Text(title)
|
||||
.font(Font(ProseTypography.titleFont))
|
||||
.foregroundStyle(DesignTokens.foreground)
|
||||
.padding(.leading, DropGeometry.gripWidth)
|
||||
.padding(.bottom, 14)
|
||||
}
|
||||
}
|
||||
|
||||
/// #ui-r5 (argon#14): the piece's title — the first non-blank preamble
|
||||
/// line with heading markers stripped (Post.scan's title rule; the same
|
||||
/// line the library row shows). Rendered above the tree; the remaining
|
||||
/// preamble lines stay byte-preserved in the document but unshown, as
|
||||
/// before. Lives here, not in the struct body — the type sits at
|
||||
/// swiftlint's type_body_length ceiling.
|
||||
private var outlineTitle: String? {
|
||||
guard let raw = preamble.first(where: { !$0.trimmingCharacters(in: .whitespaces).isEmpty }) else {
|
||||
return nil
|
||||
}
|
||||
let stripped = raw.drop(while: { $0 == "#" }).trimmingCharacters(in: .whitespaces)
|
||||
return stripped.isEmpty ? nil : stripped
|
||||
}
|
||||
|
||||
/// #ui-r5 (argon#1/sol#7 — r4 REGRESSION): one hairline rail per
|
||||
/// ancestor level, at the PARENT bullet's CENTER column — directly
|
||||
/// under the parent's bullet dot, LEFT of the child's marker, in the
|
||||
/// indentation gutter. r4 put the stroke on the child TEXT column
|
||||
/// (`textColumn(depth: level + 1)`), where it read as a stray caret
|
||||
/// flush to the child's first letter. Full-row background so
|
||||
/// consecutive siblings' segments join. Lives in this extension like
|
||||
/// the other chrome helpers — the struct body sits at swiftlint's
|
||||
/// type_body_length ceiling.
|
||||
private func rails(depth: Int) -> some View {
|
||||
Canvas { context, size in
|
||||
for level in 0 ..< depth {
|
||||
let railX = NestGeometry.bulletColumn(depth: level)
|
||||
context.fill(
|
||||
Path(CGRect(x: railX, y: 0, width: 1, height: size.height)),
|
||||
with: .color(DesignTokens.border),
|
||||
)
|
||||
}
|
||||
}
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user