fix(mobile): improve refresh button - float over all tabs, add animation, fix focus

**Changes:**
1. Move button to float over all tabs (not just Stats)
   - Removed from userStats.js HTML
   - Added to template.html as floating absolute element
   - Now visible on Status, Info, and Inventory tabs

2. Fix sticky black focus state
   - Added :focus { outline: none } to CSS
   - Call blur() after click to clear focus immediately

3. Add refresh animation
   - Button spins during updateRPGData() call
   - Smooth 0.8s rotation with @keyframes
   - Uses .spinning class added/removed in JS

4. Improve theming and positioning
   - Positioned absolute top-right (10px, 10px)
   - Increased to 44px for better touch target
   - z-index: 100 to float above content
   - Already uses theme colors (--rpg-highlight, --rpg-text)

Mobile UX now:
 Button visible on all tabs (floating)
 Spins smoothly when refreshing
 No sticky black state after tap
 Properly themed across all themes
This commit is contained in:
Lucas 'Paperboy' Rose-Winters
2025-10-21 21:27:20 +11:00
parent 577010e2aa
commit dd392e50d1
4 changed files with 48 additions and 13 deletions
+14 -1
View File
@@ -303,7 +303,20 @@ async function initUI() {
// console.log('[RPG Companion] Extension is disabled. Please enable it in the Extensions tab.'); // console.log('[RPG Companion] Extension is disabled. Please enable it in the Extensions tab.');
return; return;
} }
await updateRPGData(renderUserStats, renderInfoBox, renderThoughts, renderInventory);
// Remove focus to prevent sticky black state on mobile
$(this).blur();
// Add spinning animation to mobile button
const $mobileBtn = $('#rpg-manual-update-mobile');
$mobileBtn.addClass('spinning');
try {
await updateRPGData(renderUserStats, renderInfoBox, renderThoughts, renderInventory);
} finally {
// Remove spinning animation when done
$mobileBtn.removeClass('spinning');
}
}); });
$('#rpg-stat-bar-color-low').on('change', function() { $('#rpg-stat-bar-color-low').on('change', function() {
-3
View File
@@ -61,9 +61,6 @@ export function renderUserStats() {
<span style="opacity: 0.5;">|</span> <span style="opacity: 0.5;">|</span>
<span class="rpg-level-label">LVL</span> <span class="rpg-level-label">LVL</span>
<span class="rpg-level-value rpg-editable" contenteditable="true" data-field="level" title="Click to edit level">${extensionSettings.level}</span> <span class="rpg-level-value rpg-editable" contenteditable="true" data-field="level" title="Click to edit level">${extensionSettings.level}</span>
<button id="rpg-manual-update-mobile" class="rpg-refresh-icon-btn" title="Refresh RPG Info">
<i class="fa-solid fa-sync"></i>
</button>
</div> </div>
<div class="rpg-stats-grid"> <div class="rpg-stats-grid">
<div class="rpg-stat-row"> <div class="rpg-stat-row">
+29 -9
View File
@@ -2708,41 +2708,61 @@ body:has(.rpg-panel.rpg-position-left) #sheld {
} }
/* ============================================ /* ============================================
REFRESH ICON BUTTON (Mobile) REFRESH ICON BUTTON (Mobile - Floating)
============================================ */ ============================================ */
.rpg-refresh-icon-btn { .rpg-refresh-icon-btn {
display: none; /* Hidden by default, shown on mobile */ display: none; /* Hidden by default, shown on mobile */
width: 36px; position: absolute;
height: 36px; top: 10px;
right: 10px;
width: 44px; /* Touch-friendly size */
height: 44px;
padding: 0; padding: 0;
margin-left: auto; /* Push to right side */
background: var(--rpg-highlight); background: var(--rpg-highlight);
border: 2px solid var(--rpg-highlight); border: 2px solid var(--rpg-highlight);
border-radius: 50%; border-radius: 50%;
color: var(--rpg-text); color: var(--rpg-text);
font-size: 0.875rem; font-size: 1rem;
cursor: pointer; cursor: pointer;
transition: all 0.3s ease; transition: transform 0.2s ease, box-shadow 0.2s ease;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
flex-shrink: 0; z-index: 100; /* Float above content */
}
/* Remove focus outline (prevents black state) */
.rpg-refresh-icon-btn:focus {
outline: none;
} }
.rpg-refresh-icon-btn:hover { .rpg-refresh-icon-btn:hover {
transform: scale(1.1); transform: scale(1.1);
box-shadow: 0 4px 12px var(--rpg-highlight); box-shadow: 0 4px 12px var(--rpg-highlight);
background: var(--rpg-accent);
} }
.rpg-refresh-icon-btn:active { .rpg-refresh-icon-btn:active {
transform: scale(0.95); transform: scale(0.95);
} }
/* Spinning animation when refreshing */
.rpg-refresh-icon-btn.spinning i {
animation: rpg-spin 0.8s linear infinite;
}
.rpg-refresh-icon-btn i { .rpg-refresh-icon-btn i {
pointer-events: none; pointer-events: none;
} }
@keyframes rpg-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
/* ============================================ /* ============================================
SETTINGS BUTTON SETTINGS BUTTON
============================================ */ ============================================ */
+5
View File
@@ -54,6 +54,11 @@
</div> </div>
</div> </div>
<!-- Mobile Floating Refresh Button (shown on all tabs) -->
<button id="rpg-manual-update-mobile" class="rpg-refresh-icon-btn" title="Refresh RPG Info">
<i class="fa-solid fa-sync"></i>
</button>
<!-- HTML Prompt Toggle --> <!-- HTML Prompt Toggle -->
<div class="rpg-toggle-container"> <div class="rpg-toggle-container">
<label class="rpg-toggle-label"> <label class="rpg-toggle-label">