Branchwell

Jotley / app / macOS / Views / TagView.swift

1import SwiftUI
2import AppKit
3
4struct TagView: View {
5 let tag: String
6 var isEditing: Bool
7 var onRemove: (() -> Void)? = nil
8
9 var body: some View {
10 HStack(spacing: 4) {
11 if isEditing {
12 Button(action: {
13 onRemove?()
14 }) {
15 Image(systemName: "xmark.circle.fill")
16 .foregroundColor(Color.themeTextSecondary)
17 .font(.caption) // Make the X mark smaller
18 }
19 .buttonStyle(.plain)
20 .background(
21 Color.clear
22 .onHover { hovering in
23 if hovering {
24 NSCursor.pointingHand.set()
25 } else {
26 NSCursor.arrow.set()
27 }
28 }
29 )
30 .padding(.leading, 2) // Adjust padding if needed
31 }
32
33 Text(tag)
34 .font(.caption)
35 .fixedSize(horizontal: false, vertical: true)
36 .modifier(JotleyNoteTagStyle(horizontalPadding: 8, verticalPadding: 4))
37 }
38 }
39}