95 lines
3.8 KiB
Swift
95 lines
3.8 KiB
Swift
//
|
|
// LibraryPostRow.swift
|
|
// Museion
|
|
//
|
|
// #193: the shared post row, moved from PostsPaneView.swift
|
|
// (file-length ceiling) — the Archive pane reuses it, code
|
|
// unchanged.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// One post row per the export: title + origin-only mono-11 meta (the Pass
|
|
/// State rides the uppercase group label above; it stays in the a11y label).
|
|
/// #108 (variant B): 2px accent edge bar on the leading side when selected
|
|
/// (`.vB .post-row[aria-current] { border-left-color: var(--accent) }`,
|
|
/// radius 0 8 8 0), and a muted ✳ suffix on outline pieces. Internal: the
|
|
/// Archive pane reuses it.
|
|
struct LibraryPostRow: View {
|
|
let post: Post
|
|
let selected: Bool
|
|
let select: () -> Void
|
|
@State private var hover = false
|
|
|
|
var body: some View {
|
|
// `.vB .post-row { border-left: 2px solid transparent;
|
|
// border-radius: 0 8px 8px 0 }` — every row: leading corners square
|
|
// (the 2px strip below), trailing rounded 8. Only the strip's
|
|
// VISIBILITY changes on selection.
|
|
let shape = UnevenRoundedRectangle(cornerRadii: .init(bottomTrailing: 8, topTrailing: 8))
|
|
return Button(action: select) {
|
|
HStack(spacing: 0) {
|
|
// The leading strip is always 2px wide so hover/selection
|
|
// never shifts the title. r6 (mercury#49/52, argon#13):
|
|
// the shared SelectedRowStrip capsule — accent, radius-1
|
|
// ends, vertically inset 6pt (was 3) so it sits INSIDE
|
|
// the card, never pasted on its square leading edge.
|
|
SelectedRowStrip()
|
|
.opacity(selected ? 1 : 0)
|
|
VStack(alignment: .leading, spacing: 5) {
|
|
HStack(alignment: .firstTextBaseline, spacing: 0) {
|
|
Text(post.title)
|
|
if post.type == .outline {
|
|
Text(" ✳")
|
|
.foregroundStyle(DesignTokens.muted)
|
|
}
|
|
}
|
|
// ui-polish r8: serif-13 per the row contract — `.callout`
|
|
// was the system sans design (the r6/r7 councils pixel-
|
|
// verified sans glyphs on the Archive rows).
|
|
.font(.system(size: 13, weight: .semibold, design: DesignTokens.serif))
|
|
.lineLimit(1)
|
|
.truncationMode(.tail)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
// Origin only — the Pass State already rides the uppercase
|
|
// group label above (it stays in the accessibility label).
|
|
// r7: the status micro-label sits INSIDE the row's content
|
|
// padding — same x as the title, never flush with the edge.
|
|
Text(post.origin.rawValue)
|
|
.font(.system(size: 11, design: DesignTokens.mono))
|
|
.foregroundStyle(DesignTokens.muted)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
.padding(.horizontal, 12)
|
|
.padding(.vertical, 10)
|
|
}
|
|
.clipShape(shape)
|
|
}
|
|
.buttonStyle(.plain)
|
|
.foregroundStyle(DesignTokens.foreground)
|
|
.background {
|
|
if selected || hover {
|
|
// r8 (mercury#11): the selected row DROPS its gray outline —
|
|
// fill + accent capsule read as ONE shape; stacking fill +
|
|
// outline + capsule competed. Hover keeps its borderless
|
|
// 0.06 wash exactly as before.
|
|
shape
|
|
.fill(selected ? DesignTokens.foreground.opacity(0.08) : DesignTokens.foreground.opacity(0.06))
|
|
}
|
|
}
|
|
// r7 (mercury#18, argon#12 — two-axis ladder): the row CARD
|
|
// leads at the PRIMARY inset (x14, the 'Posts' header text's
|
|
// edge); its INNER content (title + status micro-label, strip
|
|
// 2 + padding 12) lands at x28 — the ONE indent step, shared
|
|
// with the head text and the group labels. No other x-axis
|
|
// exists in the column. Vertical padding stays the content
|
|
// VStack's constant 10 whether or not the row shows its strip.
|
|
.padding(.horizontal, 14)
|
|
.onHover { hover = $0 }
|
|
// help sits on the row — the ✳ span isn't individually hoverable in
|
|
// SwiftUI (prototype: `title="outline"` on the star).
|
|
.help(post.type == .outline ? "\(post.title) — outline" : post.title)
|
|
.accessibilityLabel("\(post.title), \(post.passState.rawValue), origin \(post.origin.rawValue)")
|
|
}
|
|
}
|