|
1 | | -import { BookOpen, Edit3, Link2, Paperclip } from 'lucide-react'; |
| 1 | +import { BookOpen, Link2, Paperclip, Pencil, Trash2 } from 'lucide-react'; |
2 | 2 | import { tFallback, type Attachment } from '@mindwtr/core'; |
3 | 3 | import { useBareFileReferenceCheck, useExternalFileReferenceCheck } from '../../../lib/attachment-reference'; |
4 | 4 | import { getAttachmentDisplayTitle } from '../../../lib/attachment-utils'; |
5 | 5 | import { isImageAttachment } from '../task-item-attachment-utils'; |
6 | 6 | import { AttachmentImage } from '../AttachmentImage'; |
7 | | -import { QUICK_ADD_FIELD_TOKENS, QuickAddTokenBadge, taskEditorLabelClassName } from '../task-editor-label'; |
| 7 | +import { QUICK_ADD_FIELD_TOKENS, QuickAddTokenBadge, TaskEditorFieldLabel } from '../task-editor-label'; |
| 8 | + |
| 9 | +// Secondary add actions share one bordered blue shape with the checklist's |
| 10 | +// "Add item" control so every way to grow a task reads the same. |
| 11 | +const taskEditorAddButtonClassName = 'inline-flex h-7 items-center gap-1.5 rounded-md border border-primary/30 px-2.5 text-xs font-medium text-primary transition-colors hover:bg-primary/10'; |
8 | 12 |
|
9 | 13 | type AttachmentsFieldProps = { |
10 | 14 | t: (key: string) => string; |
@@ -53,34 +57,34 @@ export function AttachmentsField({ |
53 | 57 | return ( |
54 | 58 | <div className="flex flex-col gap-2"> |
55 | 59 | <div className="flex items-center justify-between"> |
56 | | - <label className={`${taskEditorLabelClassName} inline-flex items-center gap-1.5`}> |
| 60 | + <TaskEditorFieldLabel icon={Paperclip}> |
57 | 61 | {t('attachments.title')} |
58 | 62 | <QuickAddTokenBadge t={t} token={QUICK_ADD_FIELD_TOKENS.link} /> |
59 | | - </label> |
| 63 | + </TaskEditorFieldLabel> |
60 | 64 | <div className="flex items-center gap-2"> |
61 | 65 | <button |
62 | 66 | type="button" |
63 | 67 | onClick={addFileAttachment} |
64 | | - className="text-xs px-2 py-1 rounded bg-muted/50 hover:bg-muted transition-colors flex items-center gap-1" |
| 68 | + className={taskEditorAddButtonClassName} |
65 | 69 | > |
66 | | - <Paperclip className="w-3 h-3" /> |
| 70 | + <Paperclip className="w-3.5 h-3.5" aria-hidden="true" /> |
67 | 71 | {t('attachments.addFile')} |
68 | 72 | </button> |
69 | 73 | <button |
70 | 74 | type="button" |
71 | 75 | onClick={addLinkAttachment} |
72 | | - className="text-xs px-2 py-1 rounded bg-muted/50 hover:bg-muted transition-colors flex items-center gap-1" |
| 76 | + className={taskEditorAddButtonClassName} |
73 | 77 | > |
74 | | - <Link2 className="w-3 h-3" /> |
| 78 | + <Link2 className="w-3.5 h-3.5" aria-hidden="true" /> |
75 | 79 | {t('attachments.addLink')} |
76 | 80 | </button> |
77 | 81 | {showObsidianNoteAttachment && ( |
78 | 82 | <button |
79 | 83 | type="button" |
80 | 84 | onClick={addObsidianNoteAttachment} |
81 | | - className="text-xs px-2 py-1 rounded bg-muted/50 hover:bg-muted transition-colors flex items-center gap-1" |
| 85 | + className={taskEditorAddButtonClassName} |
82 | 86 | > |
83 | | - <BookOpen className="w-3 h-3" /> |
| 87 | + <BookOpen className="w-3.5 h-3.5" aria-hidden="true" /> |
84 | 88 | {t('attachments.attachObsidianNote')} |
85 | 89 | </button> |
86 | 90 | )} |
@@ -130,23 +134,26 @@ export function AttachmentsField({ |
130 | 134 | > |
131 | 135 | {displayTitle} |
132 | 136 | </button> |
133 | | - <div className="flex shrink-0 items-center gap-2"> |
| 137 | + <div className="flex shrink-0 items-center gap-1"> |
134 | 138 | {canEditAsLink(attachment) && ( |
135 | 139 | <button |
136 | 140 | type="button" |
137 | 141 | onClick={() => editLinkAttachment(attachment)} |
138 | | - className="inline-flex items-center gap-1 text-muted-foreground hover:text-foreground" |
| 142 | + aria-label={t('common.edit')} |
| 143 | + title={t('common.edit')} |
| 144 | + className="rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground" |
139 | 145 | > |
140 | | - <Edit3 className="h-3 w-3" /> |
141 | | - {t('common.edit')} |
| 146 | + <Pencil className="h-3.5 w-3.5" aria-hidden="true" /> |
142 | 147 | </button> |
143 | 148 | )} |
144 | 149 | <button |
145 | 150 | type="button" |
146 | 151 | onClick={() => removeAttachment(attachment.id)} |
147 | | - className="text-muted-foreground hover:text-foreground" |
| 152 | + aria-label={t('attachments.remove')} |
| 153 | + title={t('attachments.remove')} |
| 154 | + className="rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground" |
148 | 155 | > |
149 | | - {t('attachments.remove')} |
| 156 | + <Trash2 className="h-3.5 w-3.5" aria-hidden="true" /> |
150 | 157 | </button> |
151 | 158 | </div> |
152 | 159 | </div> |
@@ -178,23 +185,26 @@ export function AttachmentsField({ |
178 | 185 | {displayTitle} |
179 | 186 | </button> |
180 | 187 | </div> |
181 | | - <div className="flex shrink-0 items-center gap-2"> |
| 188 | + <div className="flex shrink-0 items-center gap-1"> |
182 | 189 | {canEditAsLink(attachment) && ( |
183 | 190 | <button |
184 | 191 | type="button" |
185 | 192 | onClick={() => editLinkAttachment(attachment)} |
186 | | - className="inline-flex items-center gap-1 text-muted-foreground hover:text-foreground" |
| 193 | + aria-label={t('common.edit')} |
| 194 | + title={t('common.edit')} |
| 195 | + className="rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground" |
187 | 196 | > |
188 | | - <Edit3 className="h-3 w-3" /> |
189 | | - {t('common.edit')} |
| 197 | + <Pencil className="h-3.5 w-3.5" aria-hidden="true" /> |
190 | 198 | </button> |
191 | 199 | )} |
192 | 200 | <button |
193 | 201 | type="button" |
194 | 202 | onClick={() => removeAttachment(attachment.id)} |
195 | | - className="text-muted-foreground hover:text-foreground" |
| 203 | + aria-label={t('attachments.remove')} |
| 204 | + title={t('attachments.remove')} |
| 205 | + className="rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground" |
196 | 206 | > |
197 | | - {t('attachments.remove')} |
| 207 | + <Trash2 className="h-3.5 w-3.5" aria-hidden="true" /> |
198 | 208 | </button> |
199 | 209 | </div> |
200 | 210 | </div> |
|
0 commit comments