mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 02:39:13 +00:00
menubar: one set of quota colour bands, 60/70/95, for the flame, popover and dock
This commit is contained in:
parent
aacd9cf675
commit
89213cb13b
4 changed files with 23 additions and 20 deletions
|
|
@ -79,17 +79,17 @@ struct QuotaSummary: Equatable {
|
|||
/// to "you're over" (red) — matches what the user expects from a warning
|
||||
/// indicator in the menu bar.
|
||||
static func severity(for percent: Double) -> Severity {
|
||||
if percent >= 0.9 { return .danger }
|
||||
if percent >= 0.75 { return .critical }
|
||||
if percent >= 0.5 { return .warning }
|
||||
if percent >= 0.95 { return .danger }
|
||||
if percent >= 0.7 { return .critical }
|
||||
if percent >= 0.6 { return .warning }
|
||||
return .normal
|
||||
}
|
||||
|
||||
enum Severity {
|
||||
case normal // <50% green
|
||||
case warning // 50-75% yellow
|
||||
case critical // 75-90% orange
|
||||
case danger // >=90% red
|
||||
case normal // <60% green
|
||||
case warning // 60-70% yellow
|
||||
case critical // 70-95% orange
|
||||
case danger // >=95% red
|
||||
}
|
||||
|
||||
/// The glance value (percent + color) for Capacity Dock. Every provider is
|
||||
|
|
|
|||
|
|
@ -225,14 +225,16 @@ enum CapacityDockGlance {
|
|||
static let todayHeight: CGFloat = sectionPadTop + captionLine + pillGap
|
||||
+ todayContentHeight + sectionPadBottom
|
||||
|
||||
/// Four bands, matching the rail's own sense of escalation: comfortable,
|
||||
/// watch it, nearly out, over. Rings start green because a ring with no
|
||||
/// colour reads as broken.
|
||||
/// The menu-bar flame's bands, so the rail and the flame never disagree
|
||||
/// about a window. Rings start green because a ring with no colour reads
|
||||
/// as broken.
|
||||
static func severityColor(_ fraction: Double) -> Color {
|
||||
if fraction >= 0.9 { return .red }
|
||||
if fraction >= 0.8 { return .orange }
|
||||
if fraction >= 0.7 { return .yellow }
|
||||
return .green
|
||||
switch QuotaSummary.severity(for: fraction) {
|
||||
case .normal: .green
|
||||
case .warning: .yellow
|
||||
case .critical: .orange
|
||||
case .danger: .red
|
||||
}
|
||||
}
|
||||
|
||||
/// Share of the pill the tint covers. Anything outside 0...1 is a bad
|
||||
|
|
|
|||
|
|
@ -84,11 +84,11 @@ struct QuotaSummaryHeadlineTests {
|
|||
|
||||
@Test("severity steps at the 0.50 / 0.75 / 0.90 band boundaries")
|
||||
func severityBoundaries() {
|
||||
#expect(QuotaSummary.severity(for: 0.49) == .normal)
|
||||
#expect(QuotaSummary.severity(for: 0.50) == .warning)
|
||||
#expect(QuotaSummary.severity(for: 0.74) == .warning)
|
||||
#expect(QuotaSummary.severity(for: 0.75) == .critical)
|
||||
#expect(QuotaSummary.severity(for: 0.89) == .critical)
|
||||
#expect(QuotaSummary.severity(for: 0.90) == .danger)
|
||||
#expect(QuotaSummary.severity(for: 0.59) == .normal)
|
||||
#expect(QuotaSummary.severity(for: 0.60) == .warning)
|
||||
#expect(QuotaSummary.severity(for: 0.69) == .warning)
|
||||
#expect(QuotaSummary.severity(for: 0.70) == .critical)
|
||||
#expect(QuotaSummary.severity(for: 0.94) == .critical)
|
||||
#expect(QuotaSummary.severity(for: 0.95) == .danger)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue