Cotton code
66 lines · 2.5 KB · SwiftRaw
// The verbs on a receipt-shaped page — a chat import's docket, a documents// filing receipt: typed words rather than capsules, because a filled button on// a sheet of paper is the slab the kit retired.//// TWO of them, because a docket often has two things to offer and only one of// them is the one to take. The MAIN verb is the accent, underlined in pencil// the way a receipt's instruction is marked. The SECOND is the same word in// the secondary ink with no underline — a plain verb standing beside the// marked one.//// **A second verb is not a disabled one** (the walk of 15 Sep 2026, on// `/messages/import`). "Choose another file" was typed in the faintest ink the// palette has, which on a cream sheet reads as "you cannot do this" — and it// works. It was also hand-rolled at each call site, so the failed stage and// the done stage of one screen drew their second verb in two different inks.// One type now draws both, and the ink is the kit's.import SwiftUI/// A docket's verb: the accent one that is underlined, or the secondary one/// beside it.struct DocketAction: View {    /// Which of the two this is.    enum Emphasis: Equatable {        /// The verb to take: the accent, underlined in pencil.        case main        /// A second thing that can be done here: the secondary ink, no        /// underline. Never the faintest ink the palette has — that reads as        /// unavailable.        case secondary    }    let label: String    let identifier: String    var emphasis: Emphasis = .main    let action: () -> Void    @Environment(\.theme) private var theme    private var ink: Color {        switch emphasis {        case .main: return CottonColors.accent        case .secondary: return CottonColors.inkSecondary        }    }    var body: some View {        Button(action: action) {            Text(label)                .font(CottonFonts.type(15))                .foregroundStyle(ink)                .padding(.bottom, 3)                .overlay(alignment: .bottom) {                    if emphasis == .main {                        PencilUnderline(seed: identifier, theme: theme)                            .stroke(theme.print(.pencil), lineWidth: 1)                            .frame(height: 3)                    }                }                .fixedSize()                .frame(minHeight: 44)                .contentShape(Rectangle())        }        .buttonStyle(MotionButtonStyle())        .accessibilityIdentifier(identifier)    }}