Skip to content

Commit 28e68af

Browse files
committed
feat: Revamp drag and drop functionality with enhanced UI and improved user guidance
1 parent 8f7cb21 commit 28e68af

File tree

3 files changed

+132
-75
lines changed

3 files changed

+132
-75
lines changed

index.html

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,11 @@ <h3>EXPLORER</h3>
8383
<small class="search-meta" id="searchMeta">Search file and folder names (case-insensitive)</small>
8484
</div>
8585

86-
<div class="drag-drop-zone" id="dragDropZone">
87-
<div class="drag-drop-content">
88-
<span class="material-symbols-outlined drag-drop-icon">folder_open</span>
89-
<h4>Drag & Drop Folder Here</h4>
90-
<p>or</p>
91-
<button class="btn-select-dir" id="selectDirBtn">
92-
<img src="public/folder.svg" alt="Select Directory" class="sidebar-btn-icon" />
93-
Browse Folder
94-
</button>
95-
</div>
96-
<div class="drag-drop-overlay" id="dragDropOverlay">
97-
<span class="material-symbols-outlined drag-drop-icon-large">cloud_upload</span>
98-
<h3>Drop folder to load</h3>
99-
</div>
86+
<div class="sidebar-select">
87+
<button class="btn-select-dir" id="selectDirBtn">
88+
<img src="public/folder.svg" alt="Select Directory" class="sidebar-btn-icon" />
89+
Select Directory
90+
</button>
10091
</div>
10192

10293
<div class="sidebar-select">
@@ -170,7 +161,23 @@ <h3>Drop folder to load</h3>
170161
</div>
171162

172163
<div class="editor-content">
173-
<div class="code-editor" id="codeEditor">
164+
<div class="drag-drop-zone-main" id="dragDropZone">
165+
<div class="drag-drop-content-main">
166+
<span class="material-symbols-outlined drag-drop-icon-main">folder_open</span>
167+
<h2>Drag & Drop Your Project Folder Here</h2>
168+
<p>or click "Select Directory" in the sidebar</p>
169+
<div class="drag-drop-hint">
170+
<span class="material-symbols-outlined">info</span>
171+
<span>Drop your entire project folder to get started</span>
172+
</div>
173+
</div>
174+
<div class="drag-drop-overlay-main" id="dragDropOverlay">
175+
<span class="material-symbols-outlined drag-drop-icon-large-main">cloud_upload</span>
176+
<h2>Drop Your Folder Now</h2>
177+
<p>Release to load files</p>
178+
</div>
179+
</div>
180+
<div class="code-editor" id="codeEditor" style="display: none;">
174181
<div class="editor-placeholder">
175182
<span class="material-symbols-outlined">code_blocks</span>
176183
<p>Your generated context will appear here</p>

index.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,14 +1999,15 @@
19991999
});
20002000
}
20012001

2002-
// Drag and Drop functionality
2002+
// Drag and Drop functionality on main content area
20032003
const dragDropZone = $('dragDropZone');
20042004
const dragDropOverlay = $('dragDropOverlay');
2005+
const codeEditor = $('codeEditor');
20052006

20062007
if (dragDropZone) {
2007-
// Prevent default drag behaviors on the entire zone
2008+
// Prevent default drag behaviors on the entire document
20082009
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
2009-
dragDropZone.addEventListener(eventName, e => {
2010+
document.addEventListener(eventName, e => {
20102011
e.preventDefault();
20112012
e.stopPropagation();
20122013
}, false);
@@ -2019,41 +2020,51 @@
20192020
}, false);
20202021
});
20212022

2022-
['dragleave', 'drop'].forEach(eventName => {
2023-
dragDropZone.addEventListener(eventName, () => {
2024-
dragDropZone.classList.remove('drag-over');
2023+
// Remove highlight when leaving or dropping
2024+
['dragleave'].forEach(eventName => {
2025+
dragDropZone.addEventListener(eventName, e => {
2026+
// Only remove if leaving the drop zone itself, not child elements
2027+
if (e.target === dragDropZone) {
2028+
dragDropZone.classList.remove('drag-over');
2029+
}
20252030
}, false);
20262031
});
20272032

20282033
// Handle dropped files
2029-
dragDropZone.addEventListener('drop', e => {
2030-
const items = e.dataTransfer.items;
2031-
if (!items || items.length === 0) return;
2034+
document.addEventListener('drop', e => {
2035+
dragDropZone.classList.remove('drag-over');
20322036

2033-
// Check if folder was dropped (check webkitdirectory support)
20342037
const files = e.dataTransfer.files;
20352038
if (files.length > 0) {
2039+
// Hide drag-drop zone and show editor
2040+
dragDropZone.style.display = 'none';
2041+
if (codeEditor) codeEditor.style.display = 'block';
2042+
20362043
// Show loader IMMEDIATELY
20372044
load(true, 'Loading dropped files...');
20382045
// Process files in next tick to let loader render
20392046
setTimeout(() => loadFiles(files), 0);
20402047
} else {
2041-
toast('Please drop a folder, not individual files', 'warning');
2048+
toast('Please drop a folder with files', 'warning');
20422049
}
20432050
}, false);
20442051

20452052
// Click on zone to trigger folder selection
2046-
dragDropZone.addEventListener('click', e => {
2047-
// Don't trigger if clicking the button itself
2048-
if (!e.target.closest('.btn-select-dir')) {
2049-
if (D.sel) D.sel.click();
2050-
}
2053+
dragDropZone.addEventListener('click', () => {
2054+
if (D.sel) D.sel.click();
20512055
});
20522056
}
20532057

20542058
// Optimize file input change handler
20552059
inp.onchange = e => {
20562060
if (!e.target.files.length) return;
2061+
2062+
// Hide drag-drop zone and show editor when files are selected
2063+
const dragDropZone = $('dragDropZone');
2064+
const codeEditor = $('codeEditor');
2065+
if (dragDropZone) dragDropZone.style.display = 'none';
2066+
if (codeEditor) codeEditor.style.display = 'block';
2067+
20572068
// Show loader IMMEDIATELY
20582069
load(true, 'Loading files...');
20592070
// Process files in next tick to let loader render

style.css

Lines changed: 83 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -480,103 +480,142 @@ html, body {
480480
line-height: 1.2;
481481
}
482482

483-
/* Drag and Drop Zone */
484-
.drag-drop-zone {
483+
/* Main Content Drag and Drop Zone */
484+
.drag-drop-zone-main {
485485
position: relative;
486-
margin: 12px 12px 8px 12px;
487-
border: 2px dashed var(--border-color);
488-
border-radius: 8px;
489-
padding: 24px 16px;
490-
background: rgba(255, 255, 255, 0.02);
486+
width: 100%;
487+
height: 100%;
488+
display: flex;
489+
align-items: center;
490+
justify-content: center;
491+
background: var(--color-darker);
492+
border: 3px dashed var(--border-color);
493+
border-radius: 12px;
491494
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
492495
cursor: pointer;
493-
flex-shrink: 0;
496+
overflow: hidden;
494497
}
495498

496-
.drag-drop-zone:hover {
499+
.drag-drop-zone-main:hover {
497500
border-color: var(--color-accent);
498-
background: rgba(251, 191, 36, 0.05);
501+
background: rgba(251, 191, 36, 0.03);
499502
}
500503

501-
.drag-drop-zone.drag-over {
504+
.drag-drop-zone-main.drag-over {
502505
border-color: var(--color-accent);
503-
background: rgba(251, 191, 36, 0.1);
506+
background: rgba(251, 191, 36, 0.08);
504507
border-style: solid;
505-
transform: scale(1.02);
508+
border-width: 4px;
509+
transform: scale(0.99);
506510
}
507511

508-
.drag-drop-content {
512+
.drag-drop-content-main {
509513
display: flex;
510514
flex-direction: column;
511515
align-items: center;
512-
gap: 8px;
516+
gap: 16px;
513517
z-index: 1;
514518
position: relative;
519+
padding: 48px;
520+
text-align: center;
521+
max-width: 600px;
515522
}
516523

517-
.drag-drop-icon {
518-
font-size: 48px;
524+
.drag-drop-icon-main {
525+
font-size: 120px;
519526
color: var(--color-accent);
520-
opacity: 0.8;
527+
opacity: 0.7;
528+
animation: float 3s ease-in-out infinite;
521529
}
522530

523-
.drag-drop-content h4 {
531+
.drag-drop-content-main h2 {
524532
margin: 0;
525-
font-size: 14px;
526-
font-weight: 600;
533+
font-size: 28px;
534+
font-weight: 700;
527535
color: var(--text-primary);
536+
letter-spacing: -0.5px;
528537
}
529538

530-
.drag-drop-content p {
531-
margin: 4px 0;
532-
font-size: 12px;
539+
.drag-drop-content-main > p {
540+
margin: 0;
541+
font-size: 16px;
533542
color: var(--text-secondary);
534543
}
535544

536-
.drag-drop-content .btn-select-dir {
537-
margin: 8px 0 0 0;
538-
width: auto;
539-
padding: 8px 16px;
540-
font-size: 12px;
545+
.drag-drop-hint {
546+
display: flex;
547+
align-items: center;
548+
gap: 8px;
549+
padding: 12px 20px;
550+
background: rgba(251, 191, 36, 0.1);
551+
border-radius: 6px;
552+
margin-top: 8px;
553+
}
554+
555+
.drag-drop-hint .material-symbols-outlined {
556+
font-size: 20px;
557+
color: var(--color-accent);
558+
}
559+
560+
.drag-drop-hint span:last-child {
561+
font-size: 13px;
562+
color: var(--text-secondary);
541563
}
542564

543-
.drag-drop-overlay {
565+
.drag-drop-overlay-main {
544566
position: absolute;
545567
top: 0;
546568
left: 0;
547569
right: 0;
548570
bottom: 0;
549-
background: rgba(251, 191, 36, 0.15);
550-
backdrop-filter: blur(4px);
551-
border-radius: 6px;
571+
background: rgba(251, 191, 36, 0.2);
572+
backdrop-filter: blur(8px);
552573
display: none;
553574
flex-direction: column;
554575
align-items: center;
555576
justify-content: center;
577+
gap: 16px;
556578
z-index: 10;
557579
pointer-events: none;
558580
}
559581

560-
.drag-drop-zone.drag-over .drag-drop-overlay {
582+
.drag-drop-zone-main.drag-over .drag-drop-overlay-main {
561583
display: flex;
562584
}
563585

564-
.drag-drop-icon-large {
565-
font-size: 64px;
586+
.drag-drop-icon-large-main {
587+
font-size: 120px;
566588
color: var(--color-accent);
567-
animation: bounce 0.6s ease infinite;
589+
animation: bounceScale 0.6s ease infinite;
590+
filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.5));
568591
}
569592

570-
.drag-drop-overlay h3 {
571-
margin: 8px 0 0 0;
572-
font-size: 16px;
573-
font-weight: 600;
593+
.drag-drop-overlay-main h2 {
594+
margin: 0;
595+
font-size: 32px;
596+
font-weight: 700;
574597
color: var(--color-accent);
598+
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
599+
}
600+
601+
.drag-drop-overlay-main p {
602+
margin: 0;
603+
font-size: 16px;
604+
color: var(--text-primary);
605+
}
606+
607+
@keyframes float {
608+
0%, 100% { transform: translateY(0px); }
609+
50% { transform: translateY(-20px); }
575610
}
576611

577-
@keyframes bounce {
578-
0%, 100% { transform: translateY(0); }
579-
50% { transform: translateY(-10px); }
612+
@keyframes bounceScale {
613+
0%, 100% {
614+
transform: translateY(0) scale(1);
615+
}
616+
50% {
617+
transform: translateY(-20px) scale(1.1);
618+
}
580619
}
581620

582621
.sidebar-select {

0 commit comments

Comments
 (0)