Darken omnibar pill relative to theme background
This commit is contained in:
parent
0d03b58be8
commit
cfce7e93e0
2 changed files with 14 additions and 18 deletions
|
|
@ -180,20 +180,19 @@ func resolvedBrowserChromeBackgroundColor(
|
|||
|
||||
func resolvedBrowserOmnibarPillBackgroundColor(
|
||||
for colorScheme: ColorScheme,
|
||||
themeBackgroundColor: NSColor,
|
||||
accentColor: NSColor
|
||||
themeBackgroundColor: NSColor
|
||||
) -> NSColor {
|
||||
let accentMix: CGFloat
|
||||
let darkenMix: CGFloat
|
||||
switch colorScheme {
|
||||
case .light:
|
||||
accentMix = 0.02
|
||||
darkenMix = 0.04
|
||||
case .dark:
|
||||
accentMix = 0.03
|
||||
darkenMix = 0.05
|
||||
@unknown default:
|
||||
accentMix = 0.02
|
||||
darkenMix = 0.04
|
||||
}
|
||||
|
||||
return themeBackgroundColor.blended(withFraction: accentMix, of: accentColor) ?? themeBackgroundColor
|
||||
return themeBackgroundColor.blended(withFraction: darkenMix, of: .black) ?? themeBackgroundColor
|
||||
}
|
||||
|
||||
/// View for rendering a browser panel with address bar
|
||||
|
|
@ -278,8 +277,7 @@ struct BrowserPanelView: View {
|
|||
private var omnibarPillBackgroundColor: NSColor {
|
||||
resolvedBrowserOmnibarPillBackgroundColor(
|
||||
for: colorScheme,
|
||||
themeBackgroundColor: browserChromeBackgroundColor,
|
||||
accentColor: .controlAccentColor
|
||||
themeBackgroundColor: browserChromeBackgroundColor
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -690,29 +690,27 @@ final class BrowserPanelChromeBackgroundColorTests: XCTestCase {
|
|||
}
|
||||
|
||||
final class BrowserPanelOmnibarPillBackgroundColorTests: XCTestCase {
|
||||
func testLightModeUsesSubtleAccentTintOverThemeBackground() {
|
||||
assertResolvedColorMatchesExpectedBlend(for: .light, accentMix: 0.02)
|
||||
func testLightModeSlightlyDarkensThemeBackground() {
|
||||
assertResolvedColorMatchesExpectedBlend(for: .light, darkenMix: 0.04)
|
||||
}
|
||||
|
||||
func testDarkModeUsesSlightlyStrongerAccentTintOverThemeBackground() {
|
||||
assertResolvedColorMatchesExpectedBlend(for: .dark, accentMix: 0.03)
|
||||
func testDarkModeSlightlyDarkensThemeBackground() {
|
||||
assertResolvedColorMatchesExpectedBlend(for: .dark, darkenMix: 0.05)
|
||||
}
|
||||
|
||||
private func assertResolvedColorMatchesExpectedBlend(
|
||||
for colorScheme: ColorScheme,
|
||||
accentMix: CGFloat,
|
||||
darkenMix: CGFloat,
|
||||
file: StaticString = #filePath,
|
||||
line: UInt = #line
|
||||
) {
|
||||
let themeBackground = NSColor(srgbRed: 0.94, green: 0.93, blue: 0.91, alpha: 1.0)
|
||||
let accent = NSColor(srgbRed: 0.25, green: 0.47, blue: 0.92, alpha: 1.0)
|
||||
let expected = themeBackground.blended(withFraction: accentMix, of: accent) ?? themeBackground
|
||||
let expected = themeBackground.blended(withFraction: darkenMix, of: .black) ?? themeBackground
|
||||
|
||||
guard
|
||||
let actual = resolvedBrowserOmnibarPillBackgroundColor(
|
||||
for: colorScheme,
|
||||
themeBackgroundColor: themeBackground,
|
||||
accentColor: accent
|
||||
themeBackgroundColor: themeBackground
|
||||
).usingColorSpace(.sRGB),
|
||||
let expectedSRGB = expected.usingColorSpace(.sRGB),
|
||||
let themeSRGB = themeBackground.usingColorSpace(.sRGB)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue