Преглед на файлове

Add hover feedback to the job search bar

Use HoverableView for the search pill and animate fill, brand-tinted border, and shadow on hover to match other controls.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 преди 3 седмици
родител
ревизия
dcf178fd74
променени са 1 файла, в които са добавени 14 реда и са изтрити 1 реда
  1. 14 1
      App for Indeed/Views/DashboardView.swift

+ 14 - 1
App for Indeed/Views/DashboardView.swift

@@ -30,6 +30,8 @@ final class DashboardView: NSView, NSTextFieldDelegate {
30 30
         static let border = NSColor(srgbRed: 212 / 255, green: 210 / 255, blue: 208 / 255, alpha: 1)
31 31
         /// Job search bar outer stroke (charcoal).
32 32
         static let searchBarBorder = NSColor(srgbRed: 58 / 255, green: 58 / 255, blue: 58 / 255, alpha: 1)
33
+        /// Search bar border on hover (brand-tinted, matches focus affordance elsewhere).
34
+        static let searchBarBorderHover = NSColor(srgbRed: 37 / 255, green: 87 / 255, blue: 167 / 255, alpha: 0.45)
33 35
         static let proCardFill = NSColor(srgbRed: 239 / 255, green: 244 / 255, blue: 252 / 255, alpha: 1)
34 36
         static let proCardBorder = NSColor(srgbRed: 212 / 255, green: 210 / 255, blue: 208 / 255, alpha: 1)
35 37
         static let proAccent = NSColor(srgbRed: 37 / 255, green: 87 / 255, blue: 167 / 255, alpha: 1)
@@ -67,7 +69,7 @@ final class DashboardView: NSView, NSTextFieldDelegate {
67 69
     private let greetingLabel = NSTextField(labelWithString: "")
68 70
     private let subtitleLabel = NSTextField(labelWithString: "")
69 71
     private let searchBarShadowHost = NSView()
70
-    private let searchCard = NSView()
72
+    private let searchCard = HoverableView()
71 73
     private let jobSearchIcon = NSImageView()
72 74
     private let jobKeywordsField = NSTextField()
73 75
     private let findJobsButton = HoverableButton()
@@ -593,6 +595,17 @@ final class DashboardView: NSView, NSTextFieldDelegate {
593 595
         searchCard.layer?.borderColor = Theme.searchBarBorder.cgColor
594 596
         searchCard.layer?.masksToBounds = true
595 597
 
598
+        searchCard.hoverHandler = { [weak self] hovering in
599
+            guard let self else { return }
600
+            CATransaction.begin()
601
+            CATransaction.setAnimationDuration(0.15)
602
+            self.searchCard.layer?.backgroundColor = (hovering ? Theme.neutralHoverFill : Theme.cardBackground).cgColor
603
+            self.searchCard.layer?.borderColor = (hovering ? Theme.searchBarBorderHover : Theme.searchBarBorder).cgColor
604
+            self.searchBarShadowHost.layer?.shadowColor = NSColor.black.withAlphaComponent(hovering ? 0.24 : 0.18).cgColor
605
+            self.searchBarShadowHost.layer?.shadowRadius = hovering ? 12 : 10
606
+            CATransaction.commit()
607
+        }
608
+
596 609
         searchBarShadowHost.addSubview(searchCard)
597 610
 
598 611
         func configureField(_ field: NSTextField, placeholder: String) {