style: restore Conjure colors in notes

This commit is contained in:
Valdemar Lorenzen
2026-10-19 16:06:28 +02:00
parent 999d44226d
commit adac0723a1
4 changed files with 22 additions and 25 deletions
+14 -20
View File
@@ -4,10 +4,6 @@ import Highlighter
@MainActor
enum NotesAppearance {
static let background = NSColor(white: 0.035, alpha: 1)
static let text = NSColor(white: 0.94, alpha: 1)
static let muted = NSColor(white: 0.58, alpha: 1)
static let accent = NSColor(srgbRed: 1, green: 0.36, blue: 0.39, alpha: 1)
static let font = NSFont.systemFont(ofSize: 17)
static let paragraph: NSParagraphStyle = {
let style = NSMutableParagraphStyle()
@@ -49,18 +45,16 @@ final class NotesController: NSViewController, NSTextViewDelegate {
let content = NotesView()
content.commandShortcut = { [weak self] in self?.handleCommandKey($0) ?? false }
view = content
content.wantsLayer = true
content.layer?.backgroundColor = NotesAppearance.background.cgColor
let close = iconButton("circle.fill", label: "Close notes", action: #selector(closeWindow))
close.contentTintColor = NotesAppearance.accent
close.contentTintColor = SunsetPalette.accent
close.isBordered = false
close.image = close.image?.withSymbolConfiguration(.init(paletteColors: [NotesAppearance.accent]))
close.image = close.image?.withSymbolConfiguration(.init(paletteColors: [SunsetPalette.accent]))
let lights = NSStackView(views: [close])
lights.spacing = 8
for _ in 0..<2 {
let dot = NSView()
dot.wantsLayer = true
dot.layer?.backgroundColor = NSColor(white: 0.15, alpha: 1).cgColor
dot.layer?.backgroundColor = SunsetPalette.secondaryText.withAlphaComponent(0.18).cgColor
dot.layer?.cornerRadius = 6
dot.setAccessibilityElement(false)
NSLayoutConstraint.activate([dot.widthAnchor.constraint(equalToConstant: 12), dot.heightAnchor.constraint(equalToConstant: 12)])
@@ -77,7 +71,7 @@ final class NotesController: NSViewController, NSTextViewDelegate {
let controls = NSStackView(views: [actionsButton, browseButton, create])
controls.spacing = 2
noteTitle.font = .systemFont(ofSize: 13)
noteTitle.textColor = NotesAppearance.muted
noteTitle.textColor = SunsetPalette.secondaryText
noteTitle.alignment = .center
noteTitle.lineBreakMode = .byTruncatingTail
noteTitle.setAccessibilityLabel("Note title")
@@ -122,9 +116,9 @@ final class NotesController: NSViewController, NSTextViewDelegate {
editor.importsGraphics = true
editor.allowsUndo = true
editor.drawsBackground = false
editor.textColor = NotesAppearance.text
editor.insertionPointColor = NotesAppearance.accent
editor.selectedTextAttributes = [.backgroundColor: NotesAppearance.accent.withAlphaComponent(0.25)]
editor.textColor = SunsetPalette.text
editor.insertionPointColor = SunsetPalette.accent
editor.selectedTextAttributes = [.backgroundColor: SunsetPalette.selectionFill]
editor.font = NotesAppearance.font
editor.defaultParagraphStyle = NotesAppearance.paragraph
editor.isAutomaticQuoteSubstitutionEnabled = false
@@ -143,7 +137,7 @@ final class NotesController: NSViewController, NSTextViewDelegate {
scroll.drawsBackground = false
scroll.scrollerStyle = .overlay
status.font = .systemFont(ofSize: 12)
status.textColor = NotesAppearance.muted
status.textColor = SunsetPalette.secondaryText
status.setAccessibilityLabel("Notes save status")
status.lineBreakMode = .byTruncatingTail
status.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
@@ -196,7 +190,7 @@ final class NotesController: NSViewController, NSTextViewDelegate {
button.imagePosition = .imageOnly
button.bezelStyle = .accessoryBarAction
button.showsBorderOnlyWhileMouseInside = true
button.contentTintColor = NotesAppearance.muted
button.contentTintColor = SunsetPalette.secondaryText
button.toolTip = label
button.setAccessibilityLabel(label)
NSLayoutConstraint.activate([button.widthAnchor.constraint(equalToConstant: 28), button.heightAnchor.constraint(equalToConstant: 28)])
@@ -528,7 +522,7 @@ enum MarkdownHighlighting {
(try! NSRegularExpression(pattern: "(?m)^#{1,6} .+$"), [.font: NSFont.systemFont(ofSize: 23, weight: .semibold)]),
(try! NSRegularExpression(pattern: "\\*\\*[^\\n]+?\\*\\*|__[^\\n]+?__"), [.font: NSFont.boldSystemFont(ofSize: 17)]),
(try! NSRegularExpression(pattern: "(?<!\\*)\\*(?!\\*)[^*\\n]+\\*(?!\\*)|(?<!_)_(?!_)[^_\\n]+_(?!_)"), [.font: NSFontManager.shared.convert(NotesAppearance.font, toHaveTrait: .italicFontMask)]),
(try! NSRegularExpression(pattern: "!?\\[[^\\]\\n]+\\]\\([^\\n)]+\\)|(?m)^\\s*(?:[-+*]|[0-9]+\\.)\\s"), [.foregroundColor: NotesAppearance.accent]),
(try! NSRegularExpression(pattern: "!?\\[[^\\]\\n]+\\]\\([^\\n)]+\\)|(?m)^\\s*(?:[-+*]|[0-9]+\\.)\\s"), [.foregroundColor: SunsetPalette.accent]),
(try! NSRegularExpression(pattern: "~~[^\\n]+?~~"), [.strikethroughStyle: NSUnderlineStyle.single.rawValue]),
(try! NSRegularExpression(pattern: "`[^`\\n]+`"), [.font: NSFont.monospacedSystemFont(ofSize: 17, weight: .regular), .foregroundColor: NSColor.systemGreen]),
]
@@ -575,7 +569,7 @@ enum MarkdownHighlighting {
if scale < 1 { image.size = NSSize(width: size.width * scale, height: size.height * scale) }
}
storage.removeAttribute(.strikethroughStyle, range: range)
storage.addAttributes([.font: NotesAppearance.font, .foregroundColor: NotesAppearance.text,
storage.addAttributes([.font: NotesAppearance.font, .foregroundColor: SunsetPalette.text,
.paragraphStyle: NotesAppearance.paragraph], range: range)
let blocks = codeBlocks(in: text)
for (expression, attributes) in rules {
@@ -586,8 +580,8 @@ enum MarkdownHighlighting {
}
for block in blocks {
storage.addAttributes([.font: NSFont.monospacedSystemFont(ofSize: 17, weight: .regular),
.foregroundColor: NotesAppearance.muted], range: block.range)
storage.addAttribute(.foregroundColor, value: NotesAppearance.text, range: block.body)
.foregroundColor: SunsetPalette.secondaryText], range: block.range)
storage.addAttribute(.foregroundColor, value: SunsetPalette.text, range: block.body)
let code = (text as NSString).substring(with: block.body)
guard let highlighted = highlighter.highlight(code, as: block.language),
highlighted.string == code else { continue }
@@ -598,7 +592,7 @@ enum MarkdownHighlighting {
}
}
}
editor.typingAttributes = [.font: NotesAppearance.font, .foregroundColor: NotesAppearance.text,
editor.typingAttributes = [.font: NotesAppearance.font, .foregroundColor: SunsetPalette.text,
.paragraphStyle: NotesAppearance.paragraph]
}
}
+2 -2
View File
@@ -18,7 +18,7 @@ private final class ListAttachment: NSTextAttachment {
super.init(data: nil, ofType: nil)
let cell = ListAttachmentCell(textCell: isTask ? "" : (source.length == 1 ? "•" : source.string))
cell.attributedStringValue = NSAttributedString(string: cell.stringValue,
attributes: [.font: NotesAppearance.font, .foregroundColor: NotesAppearance.accent])
attributes: [.font: NotesAppearance.font, .foregroundColor: SunsetPalette.accent])
cell.alignment = .right
attachmentCell = cell
bounds = NSRect(x: 0, y: -4, width: 22, height: 21)
@@ -510,7 +510,7 @@ final class NotesTextView: NSTextView, @MainActor NSLayoutManagerDelegate {
while checkboxes.count < taskIndices.count {
let checkbox = NSButton(checkboxWithTitle: "", target: self, action: #selector(toggleTask(_:)))
checkbox.controlSize = .small
checkbox.contentTintColor = NotesAppearance.accent
checkbox.contentTintColor = SunsetPalette.accent
checkbox.sizeToFit()
checkboxes.append(checkbox)
addSubview(checkbox)