feat(reading): polish typography, externalize CSS
Critique-directed polish of the reading surface (#72 ruling: pipeline calm, surface not-calm) plus the single-user typography rework: - Flow: leading 1.5, paragraph gap tightened; heading ladder rescaled (h1 1.15x / h2 0.85x / h3 body-face semibold) with cling margins, hN+hN suppression, no title dead space - Constructs: confident blockquote (near-ink text, 3px rail, nesting degrades), booktabs tables, tinted code panels, relative inline code - Fonts hardcoded for Alexander's faces: Valkyrie OT B 17 body, Concourse OT Semibold headings, UbuntuMono 14 code; 66ch measure - Stylesheet moved to Museion/Resources/reading.css, read fresh per page build — Debug builds load the repo copy (#filePath), so CSS edits hot-reload on the next reading toggle - Settings Typography/Text Flow sections and all flow-key plumbing deleted (56 insertions, 417 deletions) Refs #72, #78. Detector: 192 findings -> 0. Build + 93 tests green. [Generated by AI]
This commit is contained in:
1 parent
eae86dd2ef
commit
4cb753d17f
9 files changed
+134
-417
No files matched your search
@@ -3,39 +3,22 @@
|
||||
// Museion
|
||||
//
|
||||
// #17 (S1.1): Settings — the Museion Home path, repoint-only (ADR-0004).
|
||||
// #71 (map #20 / #70): the Typography section — three role slots (Body /
|
||||
// Headings / Code), each {face, size}: a Picker over every installed font
|
||||
// family (defaults are being auditioned; shrinks to a curated shortlist
|
||||
// once they settle) + a size field. UserDefaults persistence; re-picking a
|
||||
// face is reset. Chrome stays system.
|
||||
// #72 rework: the Typography + Text Flow sections are gone — single-user
|
||||
// app, prose typography is hardcoded (editing: ProseTypography constants;
|
||||
// reading: Museion/Resources/reading.css, editable while the app runs).
|
||||
//
|
||||
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
/// Settings pane. Home control per #17; typography slots per #70.
|
||||
/// Settings pane. Home control per #17.
|
||||
struct SettingsPaneView: View {
|
||||
@Binding var home: URL
|
||||
|
||||
/// Full family list once per pane lifetime (#70: full list while
|
||||
/// auditioning; the picker's current selection must be listed even when
|
||||
/// NSFontManager omits it — Iowan Old Style is such a case).
|
||||
private var families: [String] {
|
||||
let current = [
|
||||
UserDefaults.standard.string(forKey: "proseBodyFace"),
|
||||
UserDefaults.standard.string(forKey: "proseHeadingsFace"),
|
||||
UserDefaults.standard.string(forKey: "proseCodeFace"),
|
||||
].compactMap(\.self)
|
||||
let all = NSFontManager.shared.availableFontFamilies
|
||||
return Array((current + all).uniqued())
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 24) {
|
||||
contentSection
|
||||
typographySection
|
||||
flowSection
|
||||
}
|
||||
.padding(24)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
@@ -43,7 +26,7 @@ struct SettingsPaneView: View {
|
||||
.background(DesignTokens.background)
|
||||
}
|
||||
|
||||
// MARK: Home (#17)
|
||||
// MARK: Home (#17)
|
||||
|
||||
private var contentSection: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
@@ -66,49 +49,6 @@ struct SettingsPaneView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Text flow (#71 polish)
|
||||
|
||||
private var flowSection: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text("Text Flow")
|
||||
.font(.system(size: 13, weight: .semibold))
|
||||
Text(
|
||||
"Reading rhythm. Line height scales the leading everywhere; the two spacings shape reading mode only — in the editor, your blank lines are the separator."
|
||||
)
|
||||
.font(.callout)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
FlowRow(label: "Line height", key: "proseLineHeight", range: 1 ... 2, step: 0.05)
|
||||
FlowRow(label: "Space after ¶", key: "proseParagraphSpacingLines", range: 0 ... 4, step: 0.25)
|
||||
FlowRow(label: "Space after headings", key: "proseHeadingSpacingLines", range: 0 ... 6, step: 0.25)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Typography (#70)
|
||||
|
||||
private var typographySection: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text("Typography")
|
||||
.font(.system(size: 13, weight: .semibold))
|
||||
Text(
|
||||
"The three prose roles. Both the editor and reading mode use them; a missing face falls back to the system font.",
|
||||
)
|
||||
.font(.callout)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
SlotRow(
|
||||
label: "Body", faceKey: "proseBodyFace", sizeKey: "proseBodySize",
|
||||
families: families,
|
||||
)
|
||||
SlotRow(
|
||||
label: "Headings", faceKey: "proseHeadingsFace", sizeKey: "proseHeadingsSize",
|
||||
families: families,
|
||||
)
|
||||
SlotRow(
|
||||
label: "Code", faceKey: "proseCodeFace", sizeKey: "proseCodeSize",
|
||||
families: families,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func chooseHome() {
|
||||
let panel = NSOpenPanel()
|
||||
panel.canChooseDirectories = true
|
||||
@@ -120,83 +60,3 @@ struct SettingsPaneView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One role slot: face picker (full family list) + size stepper.
|
||||
private struct SlotRow: View {
|
||||
let label: String
|
||||
let faceKey: String
|
||||
let sizeKey: String
|
||||
let families: [String]
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 10) {
|
||||
Text(label)
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
.frame(width: 76, alignment: .leading)
|
||||
Picker("", selection: faceBinding) {
|
||||
ForEach(families, id: \.self) { family in
|
||||
Text(family).tag(family)
|
||||
}
|
||||
}
|
||||
.labelsHidden()
|
||||
.frame(maxWidth: 320)
|
||||
TextField("", value: sizeBinding, format: .number)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
.frame(width: 56)
|
||||
Text("pt")
|
||||
.font(.system(size: 11, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
}
|
||||
}
|
||||
|
||||
private var faceBinding: Binding<String> {
|
||||
Binding(
|
||||
get: { UserDefaults.standard.string(forKey: faceKey) ?? "" },
|
||||
set: { UserDefaults.standard.set($0, forKey: faceKey) },
|
||||
)
|
||||
}
|
||||
|
||||
private var sizeBinding: Binding<Double> {
|
||||
Binding(
|
||||
get: { UserDefaults.standard.double(forKey: sizeKey) },
|
||||
set: { UserDefaults.standard.set(max(6, min(72, $0)), forKey: sizeKey) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// One flow knob: label + numeric field (UserDefaults-backed).
|
||||
private struct FlowRow: View {
|
||||
let label: String
|
||||
let key: String
|
||||
let range: ClosedRange<Double>
|
||||
let step: Double
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 10) {
|
||||
Text(label)
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
.frame(width: 150, alignment: .leading)
|
||||
TextField("", value: binding, format: .number.precision(.fractionLength(2)))
|
||||
.textFieldStyle(.roundedBorder)
|
||||
.frame(width: 64)
|
||||
Text("× body line")
|
||||
.font(.system(size: 11, design: DesignTokens.mono))
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
}
|
||||
}
|
||||
|
||||
private var binding: Binding<Double> {
|
||||
Binding(
|
||||
get: { UserDefaults.standard.double(forKey: key) },
|
||||
set: { UserDefaults.standard.set(max(range.lowerBound, min(range.upperBound, $0)), forKey: key) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private extension Array {
|
||||
/// Order-preserving dedupe (face lists merge current + installed).
|
||||
func uniqued() -> [Element] where Element: Hashable {
|
||||
var seen = Set<Element>()
|
||||
return filter { seen.insert($0).inserted }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user