Cotton code
74 lines · 3.0 KB · SwiftRaw
// Cotton Story's NOTE CARD (`note.card`, contract 17 Nov 2026): a thought kept// beside the story, perhaps about one scene. Its title, its words, and the// scene it is about, quietly at the foot.//// Slots: `title`, `body`, `crumb` (the heading of the scene it is about).// Every word is the core's.import CottonPaperimport CottonValuesimport SwiftUIstruct StoryNoteCardFace: View {    let card: DeckCard    init(card: DeckCard) {        self.card = card    }    var body: some View {        VStack(alignment: .leading, spacing: StoryCardKnobs.gap) {            if let title = card.text("title") {                Text(verbatim: title)                    .font(StoryType.sans(.title2, weight: .semibold))                    .foregroundStyle(StoryMaterial.ink.colour)                    .fixedSize(horizontal: false, vertical: true)                    .accessibilityIdentifier("deck-title")                    .facePart(.title)            }            if let words = card.text("body") {                Text(verbatim: words)                    .font(StoryType.sans(.body))                    .foregroundStyle(StoryMaterial.ink.colour)                    .fixedSize(horizontal: false, vertical: true)                    .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)                    .clipped()                    .storyFadesOut()                    .accessibilityIdentifier("note-body")                    .facePart(.body)            }            Spacer(minLength: 0)            if let scene = card.text("crumb") {                Text(verbatim: scene)                    .font(StoryType.script(13, relativeTo: .footnote))                    .foregroundStyle(StoryMaterial.quiet.colour)                    .fixedSize(horizontal: false, vertical: true)                    .accessibilityIdentifier("note-scene")            }        }        .padding(StoryCardKnobs.inset)        .storySheet()        .accessibilityElement(children: .contain)        .accessibilityIdentifier("note-card")    }}/// The note card, and the cards it is reviewed in.public enum StoryNoteCardFaceCatalogue {    public static let stock: FaceStock = .own    public static let ground: FaceGround = .blank    public static let face = Face(id: "note.card", specimens: [Specimen("about-scene", aboutScene), Specimen("loose", loose)]) { card, _, _ in        StoryNoteCardFace(card: card)    }    public static let aboutScene = DeckCard(face: "note.card", corner: nil, pressing: false, pace: nil, plate: nil, fields: [        "title": .text("Ravi lies too easily here"),        "body": .text("He should hesitate before the mooring line. One beat of silence, then the tea."),        "crumb": .text("INT. LIGHTHOUSE KITCHEN - NIGHT"),    ])    public static let loose = DeckCard(face: "note.card", corner: nil, pressing: false, pace: nil, plate: nil, fields: [        "title": .text("Ending"),        "body": .text("What if the boat is the last image, not the lighthouse?"),    ])}