Skip to content

Commit e7a278f

Browse files
committed
Add visual feedback for button addition: implement mouse ripple effect and update addButton function to trigger it
1 parent 0f5f004 commit e7a278f

File tree

4 files changed

+69
-10
lines changed

4 files changed

+69
-10
lines changed

popup-page-scripts/popup-page-customButtons.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ function createButtonCardElement(button, index) {
4242
<label class="checkbox-row">
4343
<input type="checkbox" class="autosend-toggle" ${button.autoSend ? 'checked' : ''}>
4444
<span>Auto-send</span>
45-
${ index < 10
46-
? `<span class="shortcut-indicator">[Ctrl+${index === 9 ? 0 : index + 1}]</span>`
47-
: ''
48-
}
45+
${index < 10
46+
? `<span class="shortcut-indicator">[Ctrl+${index === 9 ? 0 : index + 1}]</span>`
47+
: ''
48+
}
4949
</label>
5050
<button class="delete-button danger">Delete</button>
5151
`;
@@ -94,8 +94,9 @@ function clearText() {
9494

9595
/**
9696
* Adds a new custom button and related card to the current profile.
97+
* @param {MouseEvent} [event] - The click event, used for visual feedback around the cursor.
9798
*/
98-
async function addButton() {
99+
async function addButton(event) {
99100
const icon = document.getElementById('buttonIcon').value || '✨';
100101
const text = document.getElementById('buttonText').value || 'New Button';
101102
const autoSend = document.getElementById('buttonAutoSendToggle').checked;
@@ -109,6 +110,13 @@ async function addButton() {
109110
await saveCurrentProfile();
110111
updatebuttonCardsList();
111112
logToGUIConsole('Added new button');
113+
114+
// --- Visual Feedback ---
115+
showToast('Button added', 'success');
116+
if (event) {
117+
// This function is in popup-page-visuals.js
118+
showMouseEffect(event);
119+
}
112120
}
113121

114122

@@ -302,8 +310,8 @@ function handleDragOver(e) {
302310
} else {
303311
// If DOM position didn't change, ensure it still has the correct base dragging transform
304312
// and importantly, ensure no transition is active from a previous interrupted move.
305-
draggedItem.style.transition = 'none'; // Remove any potentially active transition
306-
draggedItem.style.transform = playTransform; // Ensure the scale(0.8) is applied
313+
draggedItem.style.transition = 'none'; // Remove any potentially active transition
314+
draggedItem.style.transform = playTransform; // Ensure the scale(0.8) is applied
307315
}
308316
}
309317

@@ -420,9 +428,10 @@ function textareaSaverAndResizerFunc() {
420428
const buttonItem = textarea.closest('.button-item');
421429
const index = parseInt(buttonItem.dataset.index);
422430
currentProfile.customButtons[index].text = textarea.value;
423-
431+
424432
// Use debounced save to throttle saving
425433
debouncedSaveCurrentProfile();
426434
});
427435
});
428436
}
437+

popup-page-scripts/popup-page-script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ document.addEventListener('DOMContentLoaded', () => {
296296
});
297297

298298
// Button management
299-
document.getElementById('addButton').addEventListener('click', addButton);
299+
document.getElementById('addButton').addEventListener('click', e => addButton(e));
300300
document.getElementById('clearText').addEventListener('click', clearText);
301301
document.getElementById('addSeparator').addEventListener('click', addSeparator);
302302

popup-page-scripts/popup-page-visuals.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,27 @@ function showToast(message, type = 'info', duration = 3000) {
3838
}, duration);
3939
}
4040

41+
42+
/**
43+
* Creates a ripple effect at the mouse cursor's position.
44+
* This is used to provide visual feedback on actions like adding a button.
45+
*
46+
* @param {MouseEvent} event - The mouse event that triggered the effect.
47+
*/
48+
function showMouseEffect(event) {
49+
// Ensure event is provided
50+
if (!event) return;
51+
52+
const effect = document.createElement('div');
53+
effect.className = 'mouse-effect';
54+
document.body.appendChild(effect);
55+
56+
// Position at mouse coordinates. Use clientX/Y for viewport-relative position.
57+
effect.style.left = `${event.clientX}px`;
58+
effect.style.top = `${event.clientY}px`;
59+
60+
// Remove the element after the animation finishes to keep the DOM clean.
61+
effect.addEventListener('animationend', () => {
62+
effect.remove();
63+
});
64+
}

popup-page-styles/popup-components.css

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,32 @@ Key areas:
2323
--text-muted: #666;
2424
}
2525

26+
/* ------------------------------------------------------------------------- */
27+
/* Mouse Click Effect */
28+
/* ------------------------------------------------------------------------- */
29+
.mouse-effect {
30+
position: fixed;
31+
/* Use fixed positioning so scroll doesn't matter */
32+
border: 2px solid var(--primary-color);
33+
border-radius: 50%;
34+
width: 20px;
35+
height: 20px;
36+
/* Center on cursor and start scaled down */
37+
transform: translate(-50%, -50%) scale(0);
38+
opacity: 1;
39+
pointer-events: none;
40+
/* So it doesn't interfere with other clicks */
41+
z-index: 9999;
42+
animation: mouse-ripple 0.5s ease-out forwards;
43+
}
44+
45+
@keyframes mouse-ripple {
46+
to {
47+
opacity: 0;
48+
transform: translate(-50%, -50%) scale(4);
49+
}
50+
}
51+
2652
/* ------------------------------------------------------------------------- */
2753
/* Console Styling */
2854
/* ------------------------------------------------------------------------- */
@@ -435,7 +461,7 @@ Key areas:
435461
border-bottom: none;
436462
}
437463

438-
.floating-site-item span {
464+
.floating-site-item span {
439465
font-size: 1.1em;
440466
/* Responsive, scales with parent font size */
441467
}

0 commit comments

Comments
 (0)