Skip to content

Commit 8a706cd

Browse files
committed
Fix dark mode panel colors
1 parent 4c99fc8 commit 8a706cd

2 files changed

Lines changed: 54 additions & 9 deletions

File tree

Sources/Sub2APIStatusBar/MonitorPanel.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ struct OverviewCard: View {
410410
.background(
411411
LinearGradient(
412412
colors: [
413-
Color(nsColor: .controlBackgroundColor).opacity(0.96),
414-
Color(red: 0.88, green: 0.93, blue: 1.0).opacity(0.64),
413+
PanelColors.heroSurfaceStart,
414+
PanelColors.heroSurfaceEnd,
415415
],
416416
startPoint: .topLeading,
417417
endPoint: .bottomTrailing
@@ -443,6 +443,6 @@ struct OverviewStat: View {
443443
}
444444
.frame(maxWidth: .infinity, alignment: .leading)
445445
.padding(10)
446-
.background(Color.primary.opacity(0.035), in: RoundedRectangle(cornerRadius: 8))
446+
.background(PanelColors.softFill, in: RoundedRectangle(cornerRadius: 8))
447447
}
448448
}

Sources/Sub2APIStatusBar/SharedViews.swift

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,50 @@ struct SectionBlock<Content: View>: View {
2424

2525
enum PanelColors {
2626
static let backgroundTop = Color(nsColor: .windowBackgroundColor)
27-
static let backgroundBottom = Color(red: 0.91, green: 0.94, blue: 0.98)
28-
static let surface = Color(nsColor: .controlBackgroundColor).opacity(0.86)
29-
static let elevatedSurface = Color(nsColor: .windowBackgroundColor).opacity(0.94)
30-
static let border = Color.primary.opacity(0.08)
31-
static let mutedBorder = Color.primary.opacity(0.05)
27+
static let backgroundMid = Color(
28+
light: Color(red: 0.96, green: 0.98, blue: 1.0),
29+
dark: Color(red: 0.14, green: 0.15, blue: 0.17)
30+
)
31+
static let backgroundBottom = Color(
32+
light: Color(red: 0.91, green: 0.94, blue: 0.98),
33+
dark: Color(red: 0.09, green: 0.10, blue: 0.12)
34+
)
35+
static let surface = Color(
36+
light: Color(nsColor: .controlBackgroundColor).opacity(0.86),
37+
dark: Color(red: 0.18, green: 0.19, blue: 0.21).opacity(0.94)
38+
)
39+
static let elevatedSurface = Color(
40+
light: Color(nsColor: .windowBackgroundColor).opacity(0.94),
41+
dark: Color(red: 0.13, green: 0.14, blue: 0.16).opacity(0.98)
42+
)
43+
static let heroSurfaceStart = Color(
44+
light: Color(nsColor: .controlBackgroundColor).opacity(0.96),
45+
dark: Color(red: 0.20, green: 0.21, blue: 0.23)
46+
)
47+
static let heroSurfaceEnd = Color(
48+
light: Color(red: 0.88, green: 0.93, blue: 1.0).opacity(0.64),
49+
dark: Color(red: 0.12, green: 0.15, blue: 0.18)
50+
)
51+
static let softFill = Color(
52+
light: Color.primary.opacity(0.035),
53+
dark: Color.white.opacity(0.055)
54+
)
55+
static let border = Color(
56+
light: Color.primary.opacity(0.08),
57+
dark: Color.white.opacity(0.10)
58+
)
59+
static let mutedBorder = Color(
60+
light: Color.primary.opacity(0.05),
61+
dark: Color.white.opacity(0.07)
62+
)
3263
}
3364

3465
struct PanelBackground: View {
3566
var body: some View {
3667
LinearGradient(
3768
colors: [
3869
PanelColors.backgroundTop,
39-
Color(red: 0.95, green: 0.97, blue: 0.99),
70+
PanelColors.backgroundMid,
4071
PanelColors.backgroundBottom,
4172
],
4273
startPoint: .top,
@@ -45,6 +76,20 @@ struct PanelBackground: View {
4576
}
4677
}
4778

79+
extension Color {
80+
init(light: Color, dark: Color) {
81+
self.init(nsColor: NSColor(name: nil) { appearance in
82+
let bestMatch = appearance.bestMatch(from: [.darkAqua, .aqua])
83+
switch bestMatch {
84+
case .darkAqua:
85+
return NSColor(dark)
86+
default:
87+
return NSColor(light)
88+
}
89+
})
90+
}
91+
}
92+
4893
struct StatusPill: View {
4994
let text: String
5095
let color: Color

0 commit comments

Comments
 (0)