Skip to content

Commit

Permalink
Adjusting placeholder color for readability (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
andylin2004 authored Jun 4, 2023
1 parent 2baa826 commit 5b6e582
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion reminders-menubar/Views/Helpers/RmbHighlightedTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct RmbHighlightedTextField: NSViewRepresentable {
func makeNSView(context: Context) -> NSTextField {
let textField = NSTextField(frame: .infinite)
textField.delegate = context.coordinator
textField.placeholderString = placeholder
textField.placeholderAttributedString = getPlaceholderAttributedString(from: placeholder)
textField.isBordered = false
textField.backgroundColor = NSColor.clear
textField.cell?.wraps = false
Expand Down Expand Up @@ -41,6 +41,15 @@ struct RmbHighlightedTextField: NSViewRepresentable {
return attributedString
}

private func getPlaceholderAttributedString(from text: String) -> NSAttributedString {
let attributes: [NSAttributedString.Key: Any] = [
.foregroundColor: NSColor.systemGray,
.font: NSFont.preferredFont(forTextStyle: .callout)
]

return NSAttributedString(string: text, attributes: attributes)
}

func makeCoordinator() -> Coordinator {
return Coordinator(self)
}
Expand Down

0 comments on commit 5b6e582

Please sign in to comment.