Просмотр исходного кода

Style job Save button to match reference UI

Use white fill with soft search-bar border instead of tinted hover and
selection fills. Add SaveJobButtonCell with balanced insets and spacing
between heart and title. Route Save through SaveJobPayloadButton for the
custom cell.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 2 месяцев назад
Родитель
Сommit
0ee799c9e7
1 измененных файлов с 34 добавлено и 15 удалено
  1. 34 15
      App for Indeed/Views/DashboardView.swift

+ 34 - 15
App for Indeed/Views/DashboardView.swift

@@ -812,7 +812,7 @@ final class DashboardView: NSView, NSTextFieldDelegate {
         applyButton.setContentCompressionResistancePriority(.required, for: .horizontal)
 
         let savedOn = isJobSaved(job)
-        let savedButton = JobPayloadButton(title: savedOn ? "Saved" : "Save", target: self, action: #selector(didTapJobSaved(_:)))
+        let savedButton = SaveJobPayloadButton(title: savedOn ? "Saved" : "Save", target: self, action: #selector(didTapJobSaved(_:)))
         savedButton.jobPayload = job
         savedButton.cardContext = context
         savedButton.setButtonType(.toggle)
@@ -925,20 +925,13 @@ final class DashboardView: NSView, NSTextFieldDelegate {
 
     private func styleJobSavedButton(_ button: NSButton) {
         button.wantsLayer = true
-        button.layer?.cornerRadius = 8
-        let on = button.state == .on
+        button.layer?.cornerRadius = 10
         let hovering = (button as? HoverableButton)?.isHovering ?? false
-        if on {
-            button.layer?.backgroundColor = (hovering ? Theme.selectionFillHover : Theme.selectionFill).cgColor
-            button.layer?.borderWidth = 1
-            button.layer?.borderColor = Theme.brandBlue.cgColor
-            button.contentTintColor = Theme.brandBlue
-        } else {
-            button.layer?.backgroundColor = (hovering ? Theme.proCardFill : Theme.cardBackground).cgColor
-            button.layer?.borderWidth = 1
-            button.layer?.borderColor = Theme.brandBlue.cgColor
-            button.contentTintColor = Theme.brandBlue
-        }
+        // Reference: white surface, soft blue outline, brand blue icon + label (no tinted fill on hover).
+        button.layer?.backgroundColor = Theme.cardBackground.cgColor
+        button.layer?.borderWidth = 1
+        button.layer?.borderColor = (hovering ? Theme.searchBarBorderHover : Theme.searchBarBorder).cgColor
+        button.contentTintColor = Theme.brandBlue
     }
 
     @objc private func didTapJobApply(_ sender: NSButton) {
@@ -2674,11 +2667,37 @@ private final class FeatureShortcutCardView: NSView {
 }
 
 /// `NSButton` that carries a `JobListing` for card actions (`representedObject` is unavailable on `NSButton` in this target).
-private final class JobPayloadButton: HoverableButton {
+private class JobPayloadButton: HoverableButton {
     var jobPayload: JobListing?
     var cardContext: JobListingCardContext = .homeSearchResults
 }
 
+/// Insets image + title so the Save pill matches the reference (balanced padding, not flush to the stroke).
+private final class SaveJobButtonCell: NSButtonCell {
+    private let horizontalInset: CGFloat = 10
+    private let verticalInset: CGFloat = 3
+    private let imageTitleGap: CGFloat = 5
+
+    override func imageRect(forBounds rect: NSRect) -> NSRect {
+        super.imageRect(forBounds: rect.insetBy(dx: horizontalInset, dy: verticalInset))
+    }
+
+    override func titleRect(forBounds rect: NSRect) -> NSRect {
+        let padded = rect.insetBy(dx: horizontalInset, dy: verticalInset)
+        var t = super.titleRect(forBounds: padded)
+        t.origin.x += imageTitleGap
+        t.size.width = max(0, t.size.width - imageTitleGap)
+        return t
+    }
+}
+
+private final class SaveJobPayloadButton: JobPayloadButton {
+    override class var cellClass: AnyClass? {
+        get { SaveJobButtonCell.self }
+        set { }
+    }
+}
+
 /// `NSButton` with a tracking area that reports hover transitions and (optionally) swaps in a pointing-hand cursor while hovered.
 private class HoverableButton: NSButton {
     var hoverHandler: ((Bool) -> Void)?