Commit 51845f60a0

51845f60a0b188811bd44e17d7db5ba9a170771a

parent: ace1a9a099

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-22 20:31 UTC

Themes: a secondary text role at 4.5:1

Built-in themes draw tags, comments, keyword and planning lines, cancelled
keywords, priority C, agenda times and categories and sidebar headers in a
secondary role that reads at 4.5:1 on the background; dim stays for markup,
block delimiters and line numbers. The default light theme's done,
agenda-today, todo-cancelled, priority-c and markup greys reach 4.5:1.
Solarized is flagged low contrast. A test checks the ratios.

Ref #221

Layout: unified · split

Sources/OrgPresentation/Palettes.swift +48 −42
@@ -8,6 +8,8 @@ public struct Palette: Sendable, Equatable {
8 public let name: String 8 public let name: String
9 public let appearance: Appearance 9 public let appearance: Appearance
10 public let colors: [String: RGBA] 10 public let colors: [String: RGBA]
11 /// Body text or coloured roles under 4.5:1 on the background, kept as upstream draws them.
12 public let lowContrast: Bool
11 13
12 /// `name` in the user's language: Default and Paper are translated, the others are names. 14 /// `name` in the user's language: Default and Paper are translated, the others are names.
13 public var displayName: String { 15 public var displayName: String {
@@ -18,11 +20,12 @@ public struct Palette: Sendable, Equatable {
18 } 20 }
19 } 21 }
20 22
21 public init(id: String, name: String, appearance: Appearance, colors: [String: RGBA]) { 23 public init(id: String, name: String, appearance: Appearance, colors: [String: RGBA], lowContrast: Bool = false) {
22 self.id = id 24 self.id = id
23 self.name = name 25 self.name = name
24 self.appearance = appearance 26 self.appearance = appearance
25 self.colors = colors 27 self.colors = colors
28 self.lowContrast = lowContrast
26 } 29 }
27} 30}
28 31
@@ -67,81 +70,84 @@ extension ThemeSpec {
67 70
68 // Upstream palettes; see THIRD_PARTY.org. Colors darkened from upstream to read at 3:1 on 71 // Upstream palettes; see THIRD_PARTY.org. Colors darkened from upstream to read at 3:1 on
69 // the background: Solarized Light yellow, green and cyan; Catppuccin Latte orange, yellow 72 // the background: Solarized Light yellow, green and cyan; Catppuccin Latte orange, yellow
70 // and green; Tomorrow orange and yellow. 73 // and green; Tomorrow orange and yellow. `secondary` is `dim` mixed toward `fg` until it
74 // reads at 4.5:1 on the background.
71 static let lightPalettes: [Palette] = [ 75 static let lightPalettes: [Palette] = [
72 Palette(id: "default-light", name: "Default", appearance: .light, colors: ThemeSpec.default.light), 76 Palette(id: "default-light", name: "Default", appearance: .light, colors: ThemeSpec.default.light),
73 ported("solarized-light", "Solarized Light", .light, Roles( 77 ported("solarized-light", "Solarized Light", .light, lowContrast: true, Roles(
74 bg: "#fdf6e3", alt: "#eee8d5", fg: "#586e75", dim: "#93a1a1", red: "#dc322f", orange: "#cb4b16", yellow: "#a57c00", 78 bg: "#fdf6e3", alt: "#eee8d5", fg: "#586e75", dim: "#93a1a1", secondary: "#5f747a", red: "#dc322f", orange: "#cb4b16",
75 green: "#738a05", cyan: "#258f86", blue: "#268bd2", purple: "#6c71c4", accent: "#268bd2")), 79 yellow: "#a57c00", green: "#738a05", cyan: "#258f86", blue: "#268bd2", purple: "#6c71c4", accent: "#268bd2")),
76 ported("gruvbox-light", "Gruvbox Light", .light, Roles( 80 ported("gruvbox-light", "Gruvbox Light", .light, Roles(
77 bg: "#fbf1c7", alt: "#ebdbb2", fg: "#3c3836", dim: "#928374", red: "#9d0006", orange: "#af3a03", yellow: "#b57614", 81 bg: "#fbf1c7", alt: "#ebdbb2", fg: "#3c3836", dim: "#928374", secondary: "#776c61", red: "#9d0006", orange: "#af3a03",
78 green: "#79740e", cyan: "#427b58", blue: "#076678", purple: "#8f3f71", accent: "#076678")), 82 yellow: "#b57614", green: "#79740e", cyan: "#427b58", blue: "#076678", purple: "#8f3f71", accent: "#076678")),
79 ported("modus-operandi", "Modus Operandi", .light, Roles( 83 ported("modus-operandi", "Modus Operandi", .light, Roles(
80 bg: "#ffffff", alt: "#f2f2f2", fg: "#000000", dim: "#595959", red: "#a60000", orange: "#972500", yellow: "#6f5500", 84 bg: "#ffffff", alt: "#f2f2f2", fg: "#000000", dim: "#595959", secondary: "#595959", red: "#a60000", orange: "#972500",
81 green: "#006800", cyan: "#005e8b", blue: "#0031a9", purple: "#721045", accent: "#0031a9")), 85 yellow: "#6f5500", green: "#006800", cyan: "#005e8b", blue: "#0031a9", purple: "#721045", accent: "#0031a9")),
82 ported("catppuccin-latte", "Catppuccin Latte", .light, Roles( 86 ported("catppuccin-latte", "Catppuccin Latte", .light, Roles(
83 bg: "#eff1f5", alt: "#e6e9ef", fg: "#4c4f69", dim: "#8c8fa1", red: "#d20f39", orange: "#d0590a", yellow: "#b06f13", 87 bg: "#eff1f5", alt: "#e6e9ef", fg: "#4c4f69", dim: "#8c8fa1", secondary: "#696c83", red: "#d20f39", orange: "#d0590a",
84 green: "#388c24", cyan: "#179299", blue: "#1e66f5", purple: "#8839ef", accent: "#8839ef")), 88 yellow: "#b06f13", green: "#388c24", cyan: "#179299", blue: "#1e66f5", purple: "#8839ef", accent: "#8839ef")),
85 ported("tomorrow", "Tomorrow", .light, Roles( 89 ported("tomorrow", "Tomorrow", .light, Roles(
86 bg: "#ffffff", alt: "#efefef", fg: "#4d4d4c", dim: "#8e908c", red: "#c82829", orange: "#c76b17", yellow: "#a87e00", 90 bg: "#ffffff", alt: "#efefef", fg: "#4d4d4c", dim: "#8e908c", secondary: "#767774", red: "#c82829", orange: "#c76b17",
87 green: "#718c00", cyan: "#3e999f", blue: "#4271ae", purple: "#8959a8", accent: "#4271ae")), 91 yellow: "#a87e00", green: "#718c00", cyan: "#3e999f", blue: "#4271ae", purple: "#8959a8", accent: "#4271ae")),
88 // orgstar's own: warm paper and ink, for long reading. 92 // orgstar's own: warm paper and ink, for long reading.
89 ported("paper", "Paper", .light, Roles( 93 ported("paper", "Paper", .light, Roles(
90 bg: "#f8f3e6", alt: "#efe8d6", fg: "#3b3428", dim: "#7d7262", red: "#a8322d", orange: "#a85a1f", yellow: "#8a6d1a", 94 bg: "#f8f3e6", alt: "#efe8d6", fg: "#3b3428", dim: "#7d7262", secondary: "#796e5f", red: "#a8322d", orange: "#a85a1f",
91 green: "#4d6b2f", cyan: "#2f6b6b", blue: "#2f5486", purple: "#6b4a85", accent: "#a85a1f")), 95 yellow: "#8a6d1a", green: "#4d6b2f", cyan: "#2f6b6b", blue: "#2f5486", purple: "#6b4a85", accent: "#a85a1f")),
92 ] 96 ]
93 97
94 static let darkPalettes: [Palette] = [ 98 static let darkPalettes: [Palette] = [
95 Palette(id: "default-dark", name: "Default", appearance: .dark, colors: ThemeSpec.default.dark), 99 Palette(id: "default-dark", name: "Default", appearance: .dark, colors: ThemeSpec.default.dark),
96 ported("solarized-dark", "Solarized Dark", .dark, Roles( 100 ported("solarized-dark", "Solarized Dark", .dark, lowContrast: true, Roles(
97 bg: "#002b36", alt: "#073642", fg: "#93a1a1", dim: "#586e75", red: "#dc322f", orange: "#cb4b16", yellow: "#b58900", 101 bg: "#002b36", alt: "#073642", fg: "#93a1a1", dim: "#586e75", secondary: "#7f9092", red: "#dc322f", orange: "#cb4b16",
98 green: "#859900", cyan: "#2aa198", blue: "#268bd2", purple: "#6c71c4", accent: "#268bd2")), 102 yellow: "#b58900", green: "#859900", cyan: "#2aa198", blue: "#268bd2", purple: "#6c71c4", accent: "#268bd2")),
99 ported("gruvbox-dark", "Gruvbox Dark", .dark, Roles( 103 ported("gruvbox-dark", "Gruvbox Dark", .dark, Roles(
100 bg: "#282828", alt: "#3c3836", fg: "#ebdbb2", dim: "#928374", red: "#fb4934", orange: "#fe8019", yellow: "#fabd2f", 104 bg: "#282828", alt: "#3c3836", fg: "#ebdbb2", dim: "#928374", secondary: "#9b8c7a", red: "#fb4934", orange: "#fe8019",
101 green: "#b8bb26", cyan: "#8ec07c", blue: "#83a598", purple: "#d3869b", accent: "#83a598")), 105 yellow: "#fabd2f", green: "#b8bb26", cyan: "#8ec07c", blue: "#83a598", purple: "#d3869b", accent: "#83a598")),
102 ported("modus-vivendi", "Modus Vivendi", .dark, Roles( 106 ported("modus-vivendi", "Modus Vivendi", .dark, Roles(
103 bg: "#000000", alt: "#1e1e1e", fg: "#ffffff", dim: "#989898", red: "#ff5f59", orange: "#fec43f", yellow: "#d0bc00", 107 bg: "#000000", alt: "#1e1e1e", fg: "#ffffff", dim: "#989898", secondary: "#989898", red: "#ff5f59", orange: "#fec43f",
104 green: "#44bc44", cyan: "#00d3d0", blue: "#2fafff", purple: "#b6a0ff", accent: "#2fafff")), 108 yellow: "#d0bc00", green: "#44bc44", cyan: "#00d3d0", blue: "#2fafff", purple: "#b6a0ff", accent: "#2fafff")),
105 ported("catppuccin-mocha", "Catppuccin Mocha", .dark, Roles( 109 ported("catppuccin-mocha", "Catppuccin Mocha", .dark, Roles(
106 bg: "#1e1e2e", alt: "#181825", fg: "#cdd6f4", dim: "#7f849c", red: "#f38ba8", orange: "#fab387", yellow: "#f9e2af", 110 bg: "#1e1e2e", alt: "#181825", fg: "#cdd6f4", dim: "#7f849c", secondary: "#81869e", red: "#f38ba8", orange: "#fab387",
107 green: "#a6e3a1", cyan: "#94e2d5", blue: "#89b4fa", purple: "#cba6f7", accent: "#cba6f7")), 111 yellow: "#f9e2af", green: "#a6e3a1", cyan: "#94e2d5", blue: "#89b4fa", purple: "#cba6f7", accent: "#cba6f7")),
108 ported("nord", "Nord", .dark, Roles( 112 ported("nord", "Nord", .dark, Roles(
109 bg: "#2e3440", alt: "#3b4252", fg: "#d8dee9", dim: "#616e88", red: "#bf616a", orange: "#d08770", yellow: "#ebcb8b", 113 bg: "#2e3440", alt: "#3b4252", fg: "#d8dee9", dim: "#616e88", secondary: "#929cb0", red: "#bf616a", orange: "#d08770",
110 green: "#a3be8c", cyan: "#8fbcbb", blue: "#88c0d0", purple: "#b48ead", accent: "#88c0d0")), 114 yellow: "#ebcb8b", green: "#a3be8c", cyan: "#8fbcbb", blue: "#88c0d0", purple: "#b48ead", accent: "#88c0d0")),
111 ported("dracula", "Dracula", .dark, Roles( 115 ported("dracula", "Dracula", .dark, Roles(
112 bg: "#282a36", alt: "#44475a", fg: "#f8f8f2", dim: "#6272a4", red: "#ff5555", orange: "#ffb86c", yellow: "#f1fa8c", 116 bg: "#282a36", alt: "#44475a", fg: "#f8f8f2", dim: "#6272a4", secondary: "#8491b6", red: "#ff5555", orange: "#ffb86c",
113 green: "#50fa7b", cyan: "#8be9fd", blue: "#8be9fd", purple: "#bd93f9", accent: "#bd93f9")), 117 yellow: "#f1fa8c", green: "#50fa7b", cyan: "#8be9fd", blue: "#8be9fd", purple: "#bd93f9", accent: "#bd93f9")),
114 ported("tokyo-night", "Tokyo Night", .dark, Roles( 118 ported("tokyo-night", "Tokyo Night", .dark, Roles(
115 bg: "#1a1b26", alt: "#16161e", fg: "#c0caf5", dim: "#565f89", red: "#f7768e", orange: "#ff9e64", yellow: "#e0af68", 119 bg: "#1a1b26", alt: "#16161e", fg: "#c0caf5", dim: "#565f89", secondary: "#7881ac", red: "#f7768e", orange: "#ff9e64",
116 green: "#9ece6a", cyan: "#7dcfff", blue: "#7aa2f7", purple: "#bb9af7", accent: "#7aa2f7")), 120 yellow: "#e0af68", green: "#9ece6a", cyan: "#7dcfff", blue: "#7aa2f7", purple: "#bb9af7", accent: "#7aa2f7")),
117 ported("doom-one", "doom-one", .dark, Roles( 121 ported("doom-one", "doom-one", .dark, Roles(
118 bg: "#282c34", alt: "#21242b", fg: "#bbc2cf", dim: "#5b6268", red: "#ff6c6b", orange: "#da8548", yellow: "#ecbe7b", 122 bg: "#282c34", alt: "#21242b", fg: "#bbc2cf", dim: "#5b6268", secondary: "#8c939d", red: "#ff6c6b", orange: "#da8548",
119 green: "#98be65", cyan: "#46d9ff", blue: "#51afef", purple: "#c678dd", accent: "#51afef")), 123 yellow: "#ecbe7b", green: "#98be65", cyan: "#46d9ff", blue: "#51afef", purple: "#c678dd", accent: "#51afef")),
120 ] 124 ]
121} 125}
122 126
123extension ThemeSpec { 127extension ThemeSpec {
124 /// A palette's named colors, from which every slot is set. 128 /// A palette's named colors, from which every slot is set.
125 public struct Roles: Sendable { 129 public struct Roles: Sendable {
126 public var bg, alt, fg, dim, red, orange, yellow, green, cyan, blue, purple, accent: String 130 /// `dim` is for marks that aren't read as text (markup, delimiters, line numbers);
131 /// `secondary` for quieter text (tags, comments, planning lines, agenda times).
132 public var bg, alt, fg, dim, secondary, red, orange, yellow, green, cyan, blue, purple, accent: String
127 133
128 /// Slot → role. `selection` and `inline-background` are translucent roles. 134 /// Slot → role. `selection` and `inline-background` are translucent roles.
129 static let slots: [String: KeyPath<Roles, String> & Sendable] = [ 135 static let slots: [String: KeyPath<Roles, String> & Sendable] = [
130 "background": \.bg, "foreground": \.fg, "cursor": \.accent, "accent": \.accent, 136 "background": \.bg, "foreground": \.fg, "cursor": \.accent, "accent": \.accent,
131 "heading-1": \.blue, "heading-2": \.purple, "heading-3": \.green, "heading-4": \.orange, 137 "heading-1": \.blue, "heading-2": \.purple, "heading-3": \.green, "heading-4": \.orange,
132 "heading-5": \.blue, "heading-6": \.purple, "heading-7": \.green, "heading-8": \.orange, 138 "heading-5": \.blue, "heading-6": \.purple, "heading-7": \.green, "heading-8": \.orange,
133 "todo": \.red, "todo-next": \.blue, "todo-waiting": \.yellow, "done": \.green, "todo-cancelled": \.dim, 139 "todo": \.red, "todo-next": \.blue, "todo-waiting": \.yellow, "done": \.green, "todo-cancelled": \.secondary,
134 "priority": \.orange, "priority-a": \.red, "priority-b": \.orange, "priority-c": \.dim, 140 "priority": \.orange, "priority-a": \.red, "priority-b": \.orange, "priority-c": \.secondary,
135 "tags": \.dim, "link": \.blue, "timestamp": \.purple, "code": \.orange, "verbatim": \.cyan, 141 "tags": \.secondary, "link": \.blue, "timestamp": \.purple, "code": \.orange, "verbatim": \.cyan,
136 "markup": \.dim, "comment": \.dim, "keyword": \.dim, "metadata": \.dim, "special": \.cyan, 142 "markup": \.dim, "comment": \.secondary, "keyword": \.secondary, "metadata": \.secondary, "special": \.cyan,
137 "block-background": \.alt, "block-delimiter": \.dim, "table": \.fg, 143 "block-background": \.alt, "block-delimiter": \.dim, "table": \.fg,
138 "line-number": \.dim, "line-number-current": \.fg, 144 "line-number": \.dim, "line-number-current": \.fg,
139 "syntax-keyword": \.purple, "syntax-string": \.green, "syntax-comment": \.dim, "syntax-function": \.blue, 145 "syntax-keyword": \.purple, "syntax-string": \.green, "syntax-comment": \.secondary, "syntax-function": \.blue,
140 "syntax-type": \.yellow, "syntax-number": \.orange, "syntax-property": \.cyan, "syntax-label": \.purple, 146 "syntax-type": \.yellow, "syntax-number": \.orange, "syntax-property": \.cyan, "syntax-label": \.purple,
141 "sidebar-background": \.alt, "sidebar-foreground": \.fg, "sidebar-header": \.dim, 147 "sidebar-background": \.alt, "sidebar-foreground": \.fg, "sidebar-header": \.secondary,
142 "modeline-background": \.alt, "modeline-foreground": \.fg, "modeline-highlight": \.accent, 148 "modeline-background": \.alt, "modeline-foreground": \.fg, "modeline-highlight": \.accent,
143 "state-normal": \.blue, "state-insert": \.green, "state-visual": \.orange, 149 "state-normal": \.blue, "state-insert": \.green, "state-visual": \.orange,
144 "agenda-background": \.bg, "agenda-date": \.fg, "agenda-today": \.accent, "agenda-time": \.dim, "agenda-category": \.dim, 150 "agenda-background": \.bg, "agenda-date": \.fg, "agenda-today": \.accent, "agenda-time": \.secondary, "agenda-category": \.secondary,
145 "agenda-overdue": \.red, "agenda-due-soon": \.orange, "agenda-event": \.purple, 151 "agenda-overdue": \.red, "agenda-due-soon": \.orange, "agenda-event": \.purple,
146 "habit-clear": \.blue, "habit-ready": \.green, "habit-alert": \.yellow, "habit-overdue": \.red, 152 "habit-clear": \.blue, "habit-ready": \.green, "habit-alert": \.yellow, "habit-overdue": \.red,
147 ] 153 ]
@@ -162,8 +168,8 @@ extension ThemeSpec {
162 } 168 }
163 } 169 }
164 170
165 private static func ported(_ id: String, _ name: String, _ appearance: Palette.Appearance, _ roles: Roles) -> Palette { 171 private static func ported(_ id: String, _ name: String, _ appearance: Palette.Appearance, lowContrast: Bool = false, _ roles: Roles) -> Palette {
166 Palette(id: id, name: name, appearance: appearance, colors: roles.colors(dark: appearance == .dark)) 172 Palette(id: id, name: name, appearance: appearance, colors: roles.colors(dark: appearance == .dark), lowContrast: lowContrast)
167 } 173 }
168} 174}
169 175
Sources/OrgPresentation/ThemeSpec.swift +7 −7
@@ -153,17 +153,17 @@ public struct ThemeSpec: Equatable, Sendable {
153 "background": "#ffffff", "foreground": "#1f2328", "cursor": "#0969da", "selection": "#0969da33", 153 "background": "#ffffff", "foreground": "#1f2328", "cursor": "#0969da", "selection": "#0969da33",
154 "heading-1": "#0550ae", "heading-2": "#8250df", "heading-3": "#116329", "heading-4": "#953800", 154 "heading-1": "#0550ae", "heading-2": "#8250df", "heading-3": "#116329", "heading-4": "#953800",
155 "heading-5": "#0550ae", "heading-6": "#8250df", "heading-7": "#116329", "heading-8": "#953800", 155 "heading-5": "#0550ae", "heading-6": "#8250df", "heading-7": "#116329", "heading-8": "#953800",
156 "todo": "#d70015", "done": "#248a3d", "priority": "#c93400", "tags": "#6e7781", 156 "todo": "#d70015", "done": "#1a7f37", "priority": "#c93400", "tags": "#6e7781",
157 "todo-next": "#0a66d8", "todo-waiting": "#b25000", "todo-cancelled": "#8e8e93", 157 "todo-next": "#0a66d8", "todo-waiting": "#b25000", "todo-cancelled": "#6e7781",
158 "priority-a": "#d70015", "priority-b": "#c93400", "priority-c": "#6c7a8c", 158 "priority-a": "#d70015", "priority-b": "#c93400", "priority-c": "#6a788a",
159 "link": "#0969da", "timestamp": "#8250df", "code": "#953800", "verbatim": "#0a3069", "inline-background": "#afb8c133", 159 "link": "#0969da", "timestamp": "#8250df", "code": "#953800", "verbatim": "#0a3069", "inline-background": "#afb8c133",
160 "markup": "#8c959f", "comment": "#6e7781", "keyword": "#6e7781", "metadata": "#6e7781", "special": "#1b7c83", 160 "markup": "#6e7781", "comment": "#6e7781", "keyword": "#6e7781", "metadata": "#6e7781", "special": "#1b7c83",
161 "block-background": "#f6f8fa", "block-delimiter": "#8c959f", "table": "#1f2328", 161 "block-background": "#f6f8fa", "block-delimiter": "#6e7781", "table": "#1f2328",
162 "line-number": "#8c959f", "line-number-current": "#1f2328", 162 "line-number": "#6e7781", "line-number-current": "#1f2328",
163 "syntax-keyword": "#cf222e", "syntax-string": "#0a3069", "syntax-comment": "#6e7781", "syntax-function": "#8250df", 163 "syntax-keyword": "#cf222e", "syntax-string": "#0a3069", "syntax-comment": "#6e7781", "syntax-function": "#8250df",
164 "syntax-type": "#953800", "syntax-number": "#1b7c83", "syntax-property": "#0550ae", "syntax-label": "#8250df", 164 "syntax-type": "#953800", "syntax-number": "#1b7c83", "syntax-property": "#0550ae", "syntax-label": "#8250df",
165 "modeline-highlight": "#1f2328", "state-normal": "#0969da", "state-insert": "#1a7f37", "state-visual": "#bc4c00", 165 "modeline-highlight": "#1f2328", "state-normal": "#0969da", "state-insert": "#1a7f37", "state-visual": "#bc4c00",
166 "agenda-date": "#1f2328", "agenda-today": "#007aff", "agenda-time": "#6c6c70", "agenda-category": "#6c6c70", 166 "agenda-date": "#1f2328", "agenda-today": "#0969da", "agenda-time": "#6c6c70", "agenda-category": "#6c6c70",
167 "agenda-overdue": "#d70015", "agenda-due-soon": "#c93400", "agenda-event": "#8944ab", 167 "agenda-overdue": "#d70015", "agenda-due-soon": "#c93400", "agenda-event": "#8944ab",
168 "habit-clear": "#54aeff", "habit-ready": "#4ac26b", "habit-alert": "#d4a72c", "habit-overdue": "#ff8182", 168 "habit-clear": "#54aeff", "habit-ready": "#4ac26b", "habit-alert": "#d4a72c", "habit-overdue": "#ff8182",
169 ]), 169 ]),
Sources/OrgstarWidgets/AgendaTimeline.swift +1 −1
@@ -102,7 +102,7 @@ extension AgendaSnapshot {
102 ) 102 )
103 return AgendaSnapshot( 103 return AgendaSnapshot(
104 generated: now, days: [today, tomorrow], 104 generated: now, days: [today, tomorrow],
105 colors: ["agenda-today": Hex(light: "#007aff", dark: "#0a84ff"), "agenda-time": gray, "foreground": Hex(light: "#1f2328", dark: "#e6edf3")] 105 colors: ["agenda-today": Hex(light: "#0969da", dark: "#0a84ff"), "agenda-time": gray, "foreground": Hex(light: "#1f2328", dark: "#e6edf3")]
106 ) 106 )
107 } 107 }
108} 108}
Tests/OrgAppTests/AgendaSnapshotTests.swift +1 −1
@@ -74,7 +74,7 @@ struct AgendaSnapshotTests {
74 let lunch = try #require(rows.first { $0.title == "Lunch" }) 74 let lunch = try #require(rows.first { $0.title == "Lunch" })
75 #expect(lunch.isEvent && lunch.link == nil) 75 #expect(lunch.isEvent && lunch.link == nil)
76 #expect(lunch.categoryColor == .init(light: "#336699", dark: "#336699")) 76 #expect(lunch.categoryColor == .init(light: "#336699", dark: "#336699"))
77 #expect(snapshot.colors["agenda-today"] == .init(light: "#007aff", dark: "#0a84ff")) 77 #expect(snapshot.colors["agenda-today"] == .init(light: "#0969da", dark: "#0a84ff"))
78 #expect(snapshot.colors["agenda-background"] == nil) 78 #expect(snapshot.colors["agenda-background"] == nil)
79 } 79 }
80 80
Tests/OrgPresentationTests/PaletteTests.swift +21
@@ -62,6 +62,27 @@ struct PaletteTests {
62 } 62 }
63 } 63 }
64 64
65 /// WCAG AA for text: 4.5:1 for every slot drawn as text, in every built-in theme; in
66 /// Default, for keywords, priorities and the agenda's colours too.
67 @Test func textSlotsReachAA() throws {
68 let text = ["foreground", "table", "line-number-current", "tags", "comment", "keyword", "metadata", "syntax-comment",
69 "todo-cancelled", "priority-c", "agenda-date", "agenda-time", "agenda-category"]
70 let defaults = ["todo", "todo-next", "todo-waiting", "done", "priority", "priority-a", "priority-b", "link", "timestamp",
71 "agenda-today", "agenda-overdue", "agenda-due-soon", "agenda-event"]
72 for palette in ThemeSpec.palettes(.light) + ThemeSpec.palettes(.dark) {
73 let background = try #require(palette.colors["background"])
74 for key in text + (palette.id.hasPrefix("default-") ? defaults : []) {
75 let ratio = Self.contrast(try #require(palette.colors[key], "\(palette.id) \(key)"), background)
76 #expect(ratio >= 4.5, "\(palette.id) \(key): \(ratio)")
77 }
78 }
79 }
80
81 @Test func onlySolarizedIsMarkedLowContrast() {
82 let marked = (ThemeSpec.palettes(.light) + ThemeSpec.palettes(.dark)).filter(\.lowContrast).map(\.id)
83 #expect(marked == ["solarized-light", "solarized-dark"])
84 }
85
65 @Test func baseTakesEachAppearanceFromItsPalette() throws { 86 @Test func baseTakesEachAppearanceFromItsPalette() throws {
66 let (spec, problems) = ThemeSpec.base(light: "paper", dark: "nord") 87 let (spec, problems) = ThemeSpec.base(light: "paper", dark: "nord")
67 #expect(problems.isEmpty) 88 #expect(problems.isEmpty)
docs/manual/guide/13-configuration.org +2
@@ -691,6 +691,8 @@ The default theme has light and dark colors after GitHub's light and dark themes
691 691
692=light-theme= and =dark-theme= choose a built-in theme for each appearance instead (Settings ▸ Appearance ▸ Theme). The light themes are Default, Solarized Light, Gruvbox Light, Modus Operandi, Catppuccin Latte, Tomorrow and Paper; the dark themes are Default, Solarized Dark, Gruvbox Dark, Modus Vivendi, Catppuccin Mocha, Nord, Dracula, Tokyo Night and doom-one. Every one but Default sets every color key, the sidebar, modeline, agenda and accent included. An unknown name, or one of the other appearance, is reported and Default is used. 692=light-theme= and =dark-theme= choose a built-in theme for each appearance instead (Settings ▸ Appearance ▸ Theme). The light themes are Default, Solarized Light, Gruvbox Light, Modus Operandi, Catppuccin Latte, Tomorrow and Paper; the dark themes are Default, Solarized Dark, Gruvbox Dark, Modus Vivendi, Catppuccin Mocha, Nord, Dracula, Tokyo Night and doom-one. Every one but Default sets every color key, the sidebar, modeline, agenda and accent included. An unknown name, or one of the other appearance, is reported and Default is used.
693 693
694In every built-in theme, text in a quieter color (tags, comments, keyword lines, planning lines and drawers, cancelled keywords, priority C, agenda times and categories) reads at 4.5:1 or more on the background, the WCAG AA level for body text. Markup characters, block delimiters and line numbers are dimmer. Solarized Light and Solarized Dark keep Solarized's own colors, which put body text and the colored keywords under 4.5:1 in places. Modus Operandi and Modus Vivendi reach 4.5:1 for every color.
695
694You change any of them by setting colors in =config.toml=, or by keeping a theme in its own file. Copy to Config Folder writes the two chosen themes, every color written out, into =my-theme.toml= and sets =theme-file= to it; it leaves an existing =my-theme.toml= as it is. 696You change any of them by setting colors in =config.toml=, or by keeping a theme in its own file. Copy to Config Folder writes the two chosen themes, every color written out, into =my-theme.toml= and sets =theme-file= to it; it leaves an existing =my-theme.toml= as it is.
695 697
696Colors are strings in the form ="#rrggbb"= or ="#rrggbbaa"=. They go in these tables: 698Colors are strings in the form ="#rrggbb"= or ="#rrggbbaa"=. They go in these tables: