Fix light-mode sidebar typing indicator contrast

This commit is contained in:
Lawrence Chen 2026-02-23 19:14:32 -08:00
parent 92d558cb95
commit 9953fa58d9
2 changed files with 56 additions and 2 deletions

View file

@ -28,6 +28,19 @@ private func coloredCircleImage(color: NSColor) -> NSImage {
return image
}
func sidebarStatusPillActiveForegroundNSColor(
colorScheme: ColorScheme,
opacity: CGFloat
) -> NSColor {
let clampedOpacity = max(0, min(opacity, 1))
switch colorScheme {
case .dark:
return NSColor.white.withAlphaComponent(clampedOpacity)
default:
return NSColor.black.withAlphaComponent(clampedOpacity)
}
}
struct ShortcutHintPillBackground: View {
var emphasis: Double = 1.0
@ -6811,12 +6824,13 @@ private struct SidebarStatusPillsRow: View {
let onFocus: () -> Void
@State private var isExpanded: Bool = false
@Environment(\.colorScheme) private var colorScheme
var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(statusText)
.font(.system(size: 10))
.foregroundColor(isActive ? .white.opacity(0.8) : .secondary)
.foregroundColor(isActive ? activePrimaryTextColor : .secondary)
.lineLimit(isExpanded ? nil : 3)
.truncationMode(.tail)
.multilineTextAlignment(.leading)
@ -6839,13 +6853,21 @@ private struct SidebarStatusPillsRow: View {
}
.buttonStyle(.plain)
.font(.system(size: 10, weight: .semibold))
.foregroundColor(isActive ? .white.opacity(0.65) : .secondary.opacity(0.9))
.foregroundColor(isActive ? activeSecondaryTextColor : .secondary.opacity(0.9))
.frame(maxWidth: .infinity, alignment: .leading)
}
}
.help(statusText)
}
private var activePrimaryTextColor: Color {
Color(nsColor: sidebarStatusPillActiveForegroundNSColor(colorScheme: colorScheme, opacity: 0.8))
}
private var activeSecondaryTextColor: Color {
Color(nsColor: sidebarStatusPillActiveForegroundNSColor(colorScheme: colorScheme, opacity: 0.65))
}
private var statusText: String {
entries
.map { entry in

View file

@ -773,6 +773,38 @@ final class BrowserPanelOmnibarPillBackgroundColorTests: XCTestCase {
}
}
final class SidebarStatusPillActiveForegroundColorTests: XCTestCase {
func testLightModeUsesBlackWithRequestedOpacity() {
guard let color = sidebarStatusPillActiveForegroundNSColor(
colorScheme: .light,
opacity: 0.8
).usingColorSpace(.sRGB) else {
XCTFail("Expected sRGB-convertible color")
return
}
XCTAssertEqual(color.redComponent, 0, accuracy: 0.001)
XCTAssertEqual(color.greenComponent, 0, accuracy: 0.001)
XCTAssertEqual(color.blueComponent, 0, accuracy: 0.001)
XCTAssertEqual(color.alphaComponent, 0.8, accuracy: 0.001)
}
func testDarkModeUsesWhiteWithRequestedOpacity() {
guard let color = sidebarStatusPillActiveForegroundNSColor(
colorScheme: .dark,
opacity: 0.65
).usingColorSpace(.sRGB) else {
XCTFail("Expected sRGB-convertible color")
return
}
XCTAssertEqual(color.redComponent, 1, accuracy: 0.001)
XCTAssertEqual(color.greenComponent, 1, accuracy: 0.001)
XCTAssertEqual(color.blueComponent, 1, accuracy: 0.001)
XCTAssertEqual(color.alphaComponent, 0.65, accuracy: 0.001)
}
}
final class BrowserDeveloperToolsShortcutDefaultsTests: XCTestCase {
func testSafariDefaultShortcutForToggleDeveloperTools() {
let shortcut = KeyboardShortcutSettings.Action.toggleBrowserDeveloperTools.defaultShortcut