Cotton code
30 lines · 1.3 KB · SwiftRaw
// What the app knows that the look does not, said to the look as plain values.//// `CottonPaper` is the look alone: it builds with no core and no manifest, so// it never reads a wire value or asks which app it is. These two are the// app's answers, read here — beside `ThemeModel`, the one place the app builds// its theme — and handed to the look in its own types:////   - which flavour this process is (`FlavourManifest`), as the flavour's look;//   - a project's brand kit (a record's `JSONValue`), as a `ThemeBrandKit`.import CottonKitimport CottonPaperimport Foundationextension FlavourLook {    /// This process's look: its manifest's flavour's, or none.    public static let current: FlavourLook? = shipped(for: FlavourManifest.current?.flavour)}extension ThemeBrandKit {    /// The kit a project's record carries (`update_project`'s `brand`): each    /// colour's name and hex and each font's role and family, as the record    /// spells them, a blank one absent.    public init(record brand: JSONValue) {        self.init(            colors: brand.list("colors").map { Colour(name: $0.text("name"), hex: $0.text("hex")) },            fonts: brand.list("fonts").map { Font(role: $0.text("role"), family: $0.text("family")) }        )    }}