// // PostsPaneView.swift // Museion // // #17 (S1.1): the Posts pane — library column mirroring the Home's posts/ // on disk, editor placeholder until #19–#21, mentor column (#14). // import SwiftUI /// The Posts destination: the workspace's full four-column layout /// library 232 | editor ≥420 | mentor 356 (design contract grid). struct PostsPaneView: View { let home: URL /// #14: the app-scoped mentor model + the gate's winning binary (no re-probe). var mentor: MentorSessionModel var mentorBinaryPath: String? /// Width budget after the rail — drives column collapse (export media queries: /// library hides ≤1100, mentor hides ≤920). var availableWidth: CGFloat = .infinity @State private var library = PostLibrary() @State private var selectedPostID: String? private var showsLibrary: Bool { availableWidth >= 1100 - DesignTokens.railWidth } private var showsMentor: Bool { availableWidth >= 920 - DesignTokens.railWidth } var body: some View { HStack(spacing: 0) { if showsLibrary { libraryColumn paneBorder } editorPlaceholder if showsMentor { paneBorder mentorColumn } } .task(id: home) { library = PostLibrary.scan(home: home) } } private var paneBorder: some View { Rectangle() .fill(DesignTokens.border) .frame(width: 1) } // MARK: Library column private var libraryColumn: some View { VStack(spacing: 0) { PaneHeader(title: "Posts") { // New Post arrives with #18 (Post lifecycle: lazy folder + slug). EmptyView() } if library.posts.isEmpty { emptyState } else { ScrollView { LazyVStack(alignment: .leading, spacing: 4) { ForEach(Post.PassState.allCases, id: \.self) { state in let posts = library.posts.filter { $0.passState == state } if !posts.isEmpty { Text(state.rawValue.uppercased()) .font(.system(size: 11, design: DesignTokens.mono)) .kerning(0.6) .foregroundStyle(DesignTokens.muted) .padding(.horizontal, 14) .padding(.top, 18) .padding(.bottom, 7) ForEach(posts) { post in PostRow(post: post, selected: post.id == selectedPostID) { selectedPostID = post.id } } } } } .padding(.bottom, 12) } } } .frame(width: DesignTokens.libraryWidth) } private var emptyState: some View { VStack(spacing: 8) { Text("No posts yet") .font(.system(size: 16, weight: .semibold, design: DesignTokens.serif)) Text("Posts in this Home's posts/ folder appear here.") .font(.callout) .foregroundStyle(DesignTokens.muted) .multilineTextAlignment(.center) } .padding(38) .frame(maxWidth: .infinity, maxHeight: .infinity) } // MARK: Editor + mentor columns private var editorPlaceholder: some View { VStack(spacing: 10) { if let post = library.posts.first(where: { $0.id == selectedPostID }) { Text(post.title) .font(.system(size: 16, weight: .semibold, design: DesignTokens.serif)) } Text("The editor arrives with S1.2 (#19–#21).") .font(.callout) .foregroundStyle(DesignTokens.muted) } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(DesignTokens.surface) } private var mentorColumn: some View { MentorPaneView(model: mentor, binaryPath: mentorBinaryPath) .frame(width: DesignTokens.mentorWidth) } } /// One post row per the export: title, Pass State + Origin in mono 11. private struct PostRow: View { let post: Post let selected: Bool let select: () -> Void @State private var hover = false var body: some View { Button(action: select) { VStack(alignment: .leading, spacing: 5) { Text(post.title) .font(.callout.weight(.semibold)) .lineLimit(1) .truncationMode(.tail) .frame(maxWidth: .infinity, alignment: .leading) HStack { Text(post.passState.rawValue) Text(post.origin.rawValue) } .font(.system(size: 11, design: DesignTokens.mono)) .foregroundStyle(DesignTokens.muted) .frame(maxWidth: .infinity, alignment: .leading) } .padding(10) } .buttonStyle(.plain) .foregroundStyle(DesignTokens.foreground) .background { let fill: Color? = selected ? DesignTokens.surface : (hover ? DesignTokens.foreground.opacity(0.06) : nil) if let fill { RoundedRectangle(cornerRadius: DesignTokens.radius) .fill(fill) .overlay( RoundedRectangle(cornerRadius: DesignTokens.radius) .strokeBorder(selected ? DesignTokens.border : .clear), ) } } .padding(.horizontal, 8) .onHover { hover = $0 } .accessibilityLabel("\(post.title), \(post.passState.rawValue), origin \(post.origin.rawValue)") } }