Centralize overlay colors in the app palette

This commit is contained in:
Ian Gulliver
2026-10-21 11:18:05 -07:00
parent 94d882bbfa
commit 75e67c574f
4 changed files with 14 additions and 12 deletions
+7 -7
View File
@@ -249,7 +249,7 @@ struct OverlayHost: View {
var body: some View { var body: some View {
ZStack(alignment: .topLeading) { ZStack(alignment: .topLeading) {
if let switcher = overlays.switcher { if let switcher = overlays.switcher {
Color.black.opacity(0.35) Palette.overlayBackdrop
.contentShape(Rectangle()) .contentShape(Rectangle())
.onTapGesture { .onTapGesture {
switcher.close() switcher.close()
@@ -257,7 +257,7 @@ struct OverlayHost: View {
SwitcherPlacement(model: switcher) SwitcherPlacement(model: switcher)
} }
if let image = overlays.image { if let image = overlays.image {
Color.black.opacity(0.6) Palette.imageBackdrop
.onTapGesture { .onTapGesture {
overlays.image = nil overlays.image = nil
} }
@@ -283,7 +283,7 @@ struct OverlayHost: View {
.padding(4) .padding(4)
.background(Palette.raised, in: RoundedRectangle(cornerRadius: 6)) .background(Palette.raised, in: RoundedRectangle(cornerRadius: 6))
.overlay(RoundedRectangle(cornerRadius: 6).stroke(Palette.border)) .overlay(RoundedRectangle(cornerRadius: 6).stroke(Palette.border))
.shadow(color: overlayShadow, radius: 14, y: 8) .shadow(color: Palette.overlayShadow, radius: 14, y: 8)
.environment(\.paneAccent, menu.accent) .environment(\.paneAccent, menu.accent)
.onHover { inside in .onHover { inside in
overlays.menuHover = inside overlays.menuHover = inside
@@ -292,14 +292,14 @@ struct OverlayHost: View {
.offset(x: menu.anchor.minX, y: menu.anchor.maxY + 4) .offset(x: menu.anchor.minX, y: menu.anchor.maxY + 4)
} }
if let m = overlays.modal { if let m = overlays.modal {
Color.black.opacity(0.35) Palette.overlayBackdrop
.contentShape(Rectangle()) .contentShape(Rectangle())
ModalPlacement(modal: m, pane: overlays.paneFrame) { value in ModalPlacement(modal: m, pane: overlays.paneFrame) { value in
overlays.answerModal(value) overlays.answerModal(value)
} }
} }
if let alert = overlays.alerts.last { if let alert = overlays.alerts.last {
Color.black.opacity(0.35) Palette.overlayBackdrop
.contentShape(Rectangle()) .contentShape(Rectangle())
GeometryReader { g in GeometryReader { g in
AlertBox(alert: alert, maxText: max(60, g.size.height - 48 - 90)) { AlertBox(alert: alert, maxText: max(60, g.size.height - 48 - 90)) {
@@ -432,7 +432,7 @@ private struct ModalBox: View {
.frame(maxWidth: 520) .frame(maxWidth: 520)
.background(Palette.raised, in: RoundedRectangle(cornerRadius: 10)) .background(Palette.raised, in: RoundedRectangle(cornerRadius: 10))
.overlay(RoundedRectangle(cornerRadius: 10).stroke(Palette.border)) .overlay(RoundedRectangle(cornerRadius: 10).stroke(Palette.border))
.shadow(color: overlayShadow, radius: 14, y: 8) .shadow(color: Palette.overlayShadow, radius: 14, y: 8)
} }
} }
@@ -460,7 +460,7 @@ private struct AlertBox: View {
.frame(maxWidth: 520) .frame(maxWidth: 520)
.background(Palette.raised, in: RoundedRectangle(cornerRadius: 10)) .background(Palette.raised, in: RoundedRectangle(cornerRadius: 10))
.overlay(RoundedRectangle(cornerRadius: 10).stroke(Palette.border)) .overlay(RoundedRectangle(cornerRadius: 10).stroke(Palette.border))
.shadow(color: overlayShadow, radius: 14, y: 8) .shadow(color: Palette.overlayShadow, radius: 14, y: 8)
.padding(24) .padding(24)
} }
} }
-4
View File
@@ -654,7 +654,3 @@ struct FlowLayout: Layout {
return rows return rows
} }
} }
let overlayShadow = Color(nsColor: NSColor(name: nil) { appearance in
appearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua ? NSColor(srgbRed: 0, green: 0, blue: 0, alpha: 0.5) : NSColor(srgbRed: 16 / 255, green: 24 / 255, blue: 40 / 255, alpha: 0.18)
})
+6
View File
@@ -29,6 +29,12 @@ enum Palette {
static let task9 = dynamic(0x793c9f, 0xd7a6fc) static let task9 = dynamic(0x793c9f, 0xd7a6fc)
static let task10 = dynamic(0x942e79, 0xf59cd8) static let task10 = dynamic(0x942e79, 0xf59cd8)
static let overlayBackdrop = Color.black.opacity(0.35)
static let imageBackdrop = Color.black.opacity(0.6)
static let overlayShadow = Color(nsColor: NSColor(name: nil) { appearance in
appearance.bestMatch(from: [.aqua, .darkAqua]) == .darkAqua ? NSColor(srgbRed: 0, green: 0, blue: 0, alpha: 0.5) : NSColor(srgbRed: 16 / 255, green: 24 / 255, blue: 40 / 255, alpha: 0.18)
})
private static func rgb(_ hex: UInt32) -> NSColor { private static func rgb(_ hex: UInt32) -> NSColor {
NSColor(srgbRed: CGFloat(hex >> 16 & 0xff) / 255, green: CGFloat(hex >> 8 & 0xff) / 255, blue: CGFloat(hex & 0xff) / 255, alpha: 1) NSColor(srgbRed: CGFloat(hex >> 16 & 0xff) / 255, green: CGFloat(hex >> 8 & 0xff) / 255, blue: CGFloat(hex & 0xff) / 255, alpha: 1)
} }
+1 -1
View File
@@ -417,7 +417,7 @@ private struct SwitcherBox: View {
.padding(10) .padding(10)
.background(Palette.raised, in: RoundedRectangle(cornerRadius: 10)) .background(Palette.raised, in: RoundedRectangle(cornerRadius: 10))
.overlay(RoundedRectangle(cornerRadius: 10).stroke(Palette.border)) .overlay(RoundedRectangle(cornerRadius: 10).stroke(Palette.border))
.shadow(color: overlayShadow, radius: 14, y: 8) .shadow(color: Palette.overlayShadow, radius: 14, y: 8)
.onAppear { .onAppear {
DispatchQueue.main.async { DispatchQueue.main.async {
logFocus("switcher before focus") logFocus("switcher before focus")