Support dragging files/images onto the composer to attach them (#32)

Reuses the existing upload path unchanged: handleFileSelected's body is
now handleFile(file), called from both the file-input's onChange and a
new onDrop handler on the composer, so drag-and-drop and the "Attach a
file" button share the exact same size-check/branch-on-content-type/
error-surfacing logic rather than duplicating it.

Only the first dropped file, matching the existing single-attachment-
per-message limit. A dashed-border overlay appears while dragging over
the composer for discoverability; a nested dragenter/dragleave counter
keeps it from flickering as the drag crosses child element boundaries.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5 committed 2026-08-17 09:14:17 -06:00
1 parent 4bac502b2c
commit dbf9bfa902
2 files changed
+75 -6

No files matched your search

+17
View File
@@ -1,4 +1,5 @@
.composer {
position: relative;
padding: var(--sp-3) var(--sp-4);
border-top: 1px solid var(--ds-border);
background: var(--ds-surface);
@@ -7,6 +8,22 @@
gap: 6px;
}
.composer-drop-overlay {
position: absolute;
inset: 4px;
z-index: 20;
display: flex;
align-items: center;
justify-content: center;
background: color-mix(in srgb, var(--ds-accent) 12%, var(--ds-surface) 88%);
border: 2px dashed var(--ds-accent);
border-radius: var(--radius);
color: var(--ds-accent);
font-size: 0.86rem;
font-weight: 700;
pointer-events: none;
}
.composer-box {
display: flex;
gap: var(--sp-2);