Cotton code
102 lines · 4.4 KB · SwiftRaw
// Cotton Story's STORY CARD (`story.card`, contract 17 Nov 2026): one story on// the Stories deck. Its title large, its logline, and how far it has come// (scenes, pages); the language it is written in quietly at the top. The// current story wears the accent's rule along its top.//// Slots: `title`, `subtitle` (the logline), `note` (scenes and pages, in the// core's words: "12 scenes, 18 pages"), `tag` (its language), `state` (said// when it is the current story, in the core's words). Every word is the core's.import CottonPaperimport CottonValuesimport SwiftUIstruct StoryCardFace: View {    let card: DeckCard    init(card: DeckCard) {        self.card = card    }    var body: some View {        VStack(alignment: .leading, spacing: StoryCardKnobs.gap) {            HStack(alignment: .firstTextBaseline) {                if let language = card.text("tag") {                    StoryQuietLine(text: language)                        .accessibilityIdentifier("story-language")                }                Spacer(minLength: 8)                if let current = card.text("state") {                    Text(verbatim: current)                        .font(StoryType.sans(.footnote, weight: .semibold))                        .foregroundStyle(StoryMaterial.accent.colour)                        .accessibilityIdentifier("story-current")                }            }            if let title = card.text("title") {                Text(verbatim: title)                    .font(StoryType.sans(.largeTitle, weight: .bold))                    .foregroundStyle(StoryMaterial.ink.colour)                    .fixedSize(horizontal: false, vertical: true)                    .accessibilityIdentifier("deck-title")                    .facePart(.title)            }            if let logline = card.text("subtitle") {                Text(verbatim: logline)                    .font(StoryType.sans(.title3))                    .foregroundStyle(StoryMaterial.ink.colour)                    .fixedSize(horizontal: false, vertical: true)                    .accessibilityIdentifier("story-logline")                    .facePart(.subtitle)            }            Spacer(minLength: 0)            if let figures = card.text("note") {                StoryQuietLine(text: figures)                    .accessibilityIdentifier("story-figures")            }        }        .padding(StoryCardKnobs.inset)        .storySheet()        .overlay(alignment: .top) {            if card.text("state") != nil {                Rectangle().fill(StoryMaterial.accent.colour).frame(height: 3)                    .clipShape(RoundedRectangle(cornerRadius: StoryCardKnobs.corner, style: .continuous))            }        }        .accessibilityElement(children: .contain)        .accessibilityIdentifier("story-card")    }}/// The story card, and the cards it is reviewed in.public enum StoryCardFaceCatalogue {    public static let stock: FaceStock = .own    public static let ground: FaceGround = .blank    public static let face = Face(id: "story.card", specimens: [        Specimen("current", current), Specimen("new", fresh), Specimen("translation", translation),    ]) { card, _, _ in        StoryCardFace(card: card)    }    public static let current = DeckCard(face: "story.card", corner: nil, pressing: false, pace: nil, plate: nil, fields: [        "title": .text("The Keeper's Daughter"),        "subtitle": .text("A woman comes home to a lighthouse to sell it, and finds her father has been hiding a boat."),        "note": .text("14 scenes, 22 pages"),        "tag": .text("English"),        "state": .text("Writing now"),    ])    /// Just begun: a title and nothing else.    public static let fresh = DeckCard(face: "story.card", corner: nil, pressing: false, pace: nil, plate: nil, fields: [        "title": .text("Untitled ferry story"),        "note": .text("No scenes yet"),        "tag": .text("English"),    ])    public static let translation = DeckCard(face: "story.card", corner: nil, pressing: false, pace: nil, plate: nil, fields: [        "title": .text("కాపరి కూతురు"),        "subtitle": .text("లైట్‌హౌస్ అమ్మడానికి ఇంటికి వచ్చిన ఆమెకు తండ్రి దాచిన పడవ కనిపిస్తుంది."),        "note": .text("14 scenes, 23 pages"),        "tag": .text("Telugu"),    ])}