From 88abd31c1c564d986453b4c6a9369b7dcfaf1142 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Fri, 27 Feb 2026 00:03:47 +0300 Subject: [PATCH] Add smooth animations across WebUI for modern feel - Tab panels: fade-in with subtle translateY on switch - Cards: hover lift (translateY -2px), staggered entrance animation - Modals: spring-curve entrance with backdrop blur - Buttons: press feedback (scale down on :active) - Toggle switches: spring overshoot on knob transition - Toast: smooth bounce-in replaces jarring shake - Sections: animated height collapse/expand with chevron rotation - Command palette: slide-down entrance animation - Theme switch: smooth color transitions on key elements - Dashboard: section collapse animation, target row hover - Respects prefers-reduced-motion globally Co-Authored-By: Claude Opus 4.6 --- .../src/wled_controller/static/css/base.css | 20 +++++ .../src/wled_controller/static/css/cards.css | 18 ++++- .../wled_controller/static/css/components.css | 33 +++++--- .../wled_controller/static/css/dashboard.css | 6 ++ .../src/wled_controller/static/css/layout.css | 15 +++- .../src/wled_controller/static/css/modal.css | 9 ++- .../wled_controller/static/css/streams.css | 17 ++++- .../static/js/core/card-sections.js | 76 +++++++++++++++++-- .../static/js/core/navigation.js | 2 +- .../static/js/features/dashboard.js | 34 +++++++-- 10 files changed, 193 insertions(+), 37 deletions(-) diff --git a/server/src/wled_controller/static/css/base.css b/server/src/wled_controller/static/css/base.css index d18b509..bceb6df 100644 --- a/server/src/wled_controller/static/css/base.css +++ b/server/src/wled_controller/static/css/base.css @@ -71,3 +71,23 @@ body.modal-open { margin: 0 auto; padding: 20px; } + +/* ── Smooth theme transitions ── */ +body, +.card, +.template-card, +.modal-content, +.dashboard-target, +.perf-chart-card, +header { + transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease; +} + +/* ── Respect reduced motion preference ── */ +@media (prefers-reduced-motion: reduce) { + *, *::before, *::after { + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + } +} diff --git a/server/src/wled_controller/static/css/cards.css b/server/src/wled_controller/static/css/cards.css index bcb34f7..7a02860 100644 --- a/server/src/wled_controller/static/css/cards.css +++ b/server/src/wled_controller/static/css/cards.css @@ -23,12 +23,13 @@ section { border: 2px dashed var(--border-color); background: transparent; min-height: 160px; - transition: border-color 0.2s, background 0.2s; + transition: border-color 0.25s ease, background 0.25s ease, transform 0.2s ease; } .add-device-card:hover { border-color: var(--primary-color); background: rgba(33, 150, 243, 0.05); + transform: translateY(-2px); } .add-device-icon { @@ -55,13 +56,24 @@ section { border-radius: 8px; padding: 12px 20px 20px; position: relative; - transition: transform 0.2s, box-shadow 0.2s; + transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; display: flex; flex-direction: column; } .card:hover { - box-shadow: 0 4px 12px var(--shadow-color); + box-shadow: 0 8px 24px var(--shadow-color); + transform: translateY(-2px); +} + +/* ── Card entrance animation ── */ +@keyframes cardEnter { + from { opacity: 0; transform: translateY(12px); } + to { opacity: 1; transform: translateY(0); } +} + +.card-enter { + animation: cardEnter 0.25s ease-out both; } .card-tutorial-btn { diff --git a/server/src/wled_controller/static/css/components.css b/server/src/wled_controller/static/css/components.css index 070b786..e205abe 100644 --- a/server/src/wled_controller/static/css/components.css +++ b/server/src/wled_controller/static/css/components.css @@ -59,7 +59,7 @@ cursor: pointer; font-size: 0.9rem; font-weight: 600; - transition: opacity 0.2s; + transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease; flex: 1 1 auto; min-width: 100px; } @@ -68,6 +68,11 @@ opacity: 0.9; } +.btn:active:not(:disabled) { + transform: scale(0.97); + transition-duration: 0.06s; +} + .btn:disabled { opacity: 0.5; cursor: not-allowed; @@ -100,6 +105,11 @@ opacity: 1; } +.btn-icon:active:not(:disabled) { + transform: scale(0.92); + transition-duration: 0.06s; +} + .form-group { margin-bottom: 15px; } @@ -129,7 +139,7 @@ inset: 0; background: var(--border-color); border-radius: 9px; - transition: background 0.2s; + transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1); } .settings-toggle-slider::after { @@ -141,7 +151,7 @@ height: 14px; background: white; border-radius: 50%; - transition: transform 0.2s; + transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); } .settings-toggle input:checked + .settings-toggle-slider { @@ -172,7 +182,7 @@ select { color: var(--text-color); font-size: 1rem; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; - transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s; + transition: border-color 0.25s ease, box-shadow 0.25s ease, opacity 0.2s ease; } input[type="number"]:disabled, @@ -196,7 +206,7 @@ input:focus, select:focus { outline: none; border-color: var(--primary-color); - box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2); + box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15); } /* Remove browser autofill styling */ @@ -339,7 +349,7 @@ input:-webkit-autofill:focus { font-weight: 600; font-size: 15px; opacity: 0; - transition: opacity 0.3s, transform 0.3s; + transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1); z-index: 2500; box-shadow: 0 4px 20px var(--shadow-color); min-width: 300px; @@ -349,13 +359,14 @@ input:-webkit-autofill:focus { .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); - animation: toastShake 0.5s ease-in-out; + animation: toastBounceIn 0.5s cubic-bezier(0.16, 1, 0.3, 1); } -@keyframes toastShake { - 0%, 100% { transform: translateX(-50%) translateY(0); } - 10%, 30%, 50%, 70%, 90% { transform: translateX(-50%) translateY(-5px); } - 20%, 40%, 60%, 80% { transform: translateX(-50%) translateY(5px); } +@keyframes toastBounceIn { + 0% { transform: translateX(-50%) translateY(60px); opacity: 0; } + 50% { transform: translateX(-50%) translateY(-4px); opacity: 1; } + 70% { transform: translateX(-50%) translateY(2px); } + 100% { transform: translateX(-50%) translateY(0); } } .toast.success { diff --git a/server/src/wled_controller/static/css/dashboard.css b/server/src/wled_controller/static/css/dashboard.css index 083200a..532f4af 100644 --- a/server/src/wled_controller/static/css/dashboard.css +++ b/server/src/wled_controller/static/css/dashboard.css @@ -23,6 +23,7 @@ color: var(--text-secondary); width: 10px; display: inline-block; + transition: transform 0.2s ease; } .dashboard-section-count { @@ -80,6 +81,11 @@ border: 1px solid var(--border-color); border-radius: 6px; margin-bottom: 4px; + transition: box-shadow 0.2s ease, transform 0.2s ease; +} + +.dashboard-target:hover { + box-shadow: 0 2px 8px var(--shadow-color); } .dashboard-target-info { diff --git a/server/src/wled_controller/static/css/layout.css b/server/src/wled_controller/static/css/layout.css index 5f821da..fc44a24 100644 --- a/server/src/wled_controller/static/css/layout.css +++ b/server/src/wled_controller/static/css/layout.css @@ -133,7 +133,7 @@ h2 { cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; - transition: color 0.2s, border-color 0.2s; + transition: color 0.2s ease, border-color 0.25s ease; } .tab-btn:hover { @@ -171,6 +171,12 @@ h2 { .tab-panel.active { display: block; + animation: tabFadeIn 0.25s ease-out; +} + +@keyframes tabFadeIn { + from { opacity: 0; transform: translateY(8px); } + to { opacity: 1; transform: translateY(0); } } /* Thin animated bar at top of tab panel during data refresh */ @@ -257,6 +263,7 @@ h2 { inset: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); + animation: fadeIn 0.15s ease-out; } .cp-dialog { @@ -272,6 +279,12 @@ h2 { flex-direction: column; overflow: hidden; align-self: flex-start; + animation: cpSlideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1); +} + +@keyframes cpSlideDown { + from { opacity: 0; transform: translateY(-12px) scale(0.98); } + to { opacity: 1; transform: translateY(0) scale(1); } } .cp-input { diff --git a/server/src/wled_controller/static/css/modal.css b/server/src/wled_controller/static/css/modal.css index 7a510d4..9308666 100644 --- a/server/src/wled_controller/static/css/modal.css +++ b/server/src/wled_controller/static/css/modal.css @@ -11,6 +11,7 @@ align-items: center; justify-content: center; animation: fadeIn 0.2s ease-out; + backdrop-filter: blur(2px); } /* Confirm dialog must stack above all other modals */ @@ -132,7 +133,7 @@ display: flex; flex-direction: column; box-shadow: 0 8px 32px var(--shadow-color); - animation: slideUp 0.3s ease-out; + animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); } #template-modal .modal-content { @@ -146,11 +147,11 @@ @keyframes slideUp { from { - transform: translateY(20px); + transform: translateY(20px) scale(0.98); opacity: 0; } to { - transform: translateY(0); + transform: translateY(0) scale(1); opacity: 1; } } @@ -479,7 +480,7 @@ content: '▶'; font-size: 0.6rem; opacity: 0.6; - transition: transform 0.15s; + transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); flex-shrink: 0; } diff --git a/server/src/wled_controller/static/css/streams.css b/server/src/wled_controller/static/css/streams.css index e9fc18f..9e025a1 100644 --- a/server/src/wled_controller/static/css/streams.css +++ b/server/src/wled_controller/static/css/streams.css @@ -13,14 +13,15 @@ border: 1px solid var(--border-color); border-radius: 8px; padding: 16px; - transition: box-shadow 0.2s; + transition: box-shadow 0.2s ease, transform 0.2s ease; display: flex; flex-direction: column; position: relative; } .template-card:hover { - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); + box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15); + transform: translateY(-2px); } .add-template-card { @@ -32,13 +33,14 @@ cursor: pointer; border: 2px dashed var(--border-color); background: transparent; - transition: border-color 0.2s, background 0.2s; + transition: border-color 0.25s ease, background 0.25s ease, transform 0.2s ease; } .add-template-card:hover { border-color: var(--primary-color); background: rgba(33, 150, 243, 0.05); box-shadow: none; + transform: translateY(-2px); } .add-template-icon { @@ -550,7 +552,7 @@ cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; - transition: color 0.2s, border-color 0.2s; + transition: color 0.2s ease, border-color 0.25s ease; } .stream-tab-btn:hover { @@ -610,6 +612,7 @@ .stream-tab-panel.active { display: block; + animation: tabFadeIn 0.2s ease-out; } /* Sub-tab content sections */ @@ -649,12 +652,18 @@ padding: 8px 0; } +/* Prevent sticky header from clipping cards that lift on hover */ +[data-cs-content] { + padding-top: 4px; +} + .cs-chevron { font-size: 0.65rem; color: var(--text-secondary); width: 12px; display: inline-block; flex-shrink: 0; + transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); } .cs-title { diff --git a/server/src/wled_controller/static/js/core/card-sections.js b/server/src/wled_controller/static/js/core/card-sections.js index ca8adfe..5525766 100644 --- a/server/src/wled_controller/static/js/core/card-sections.js +++ b/server/src/wled_controller/static/js/core/card-sections.js @@ -65,7 +65,7 @@ export class CardSection { const cardsHtml = items.map(i => i.html).join(''); const isCollapsed = !!_getCollapsedMap()[this.sectionKey]; - const chevron = isCollapsed ? '\u25B6' : '\u25BC'; + const chevronStyle = isCollapsed ? '' : ' style="transform:rotate(90deg)"'; const contentDisplay = isCollapsed ? ' style="display:none"' : ''; const addCard = this.addCardOnclick @@ -75,7 +75,7 @@ export class CardSection { return `
- ${chevron} + ${t(this.titleKey)} ${count}
@@ -154,6 +154,9 @@ export class CardSection { // Tag card elements with their source HTML for future reconciliation this._tagCards(content); + + // Stagger card entrance animation + this._animateEntrance(content); } /** @@ -216,6 +219,19 @@ export class CardSection { } } + // Animate newly added cards + if (added.size > 0 && this.keyAttr && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) { + let delay = 0; + for (const key of added) { + const card = content.querySelector(`[${this.keyAttr}="${key}"]`); + if (card) { + card.style.animationDelay = `${delay}ms`; + card.classList.add('card-enter'); + delay += 30; + } + } + } + // Re-apply filter if (this._filterValue) { this._applyFilter(content, this._filterValue); @@ -239,7 +255,7 @@ export class CardSection { if (content) content.style.display = ''; if (header) { const chevron = header.querySelector('.cs-chevron'); - if (chevron) chevron.textContent = '\u25BC'; + if (chevron) chevron.style.transform = 'rotate(90deg)'; } } localStorage.setItem(STORAGE_KEY, JSON.stringify(map)); @@ -255,7 +271,7 @@ export class CardSection { if (content) content.style.display = 'none'; if (header) { const chevron = header.querySelector('.cs-chevron'); - if (chevron) chevron.textContent = '\u25B6'; + if (chevron) chevron.style.transform = ''; } } localStorage.setItem(STORAGE_KEY, JSON.stringify(map)); @@ -272,12 +288,22 @@ export class CardSection { localStorage.setItem(STORAGE_KEY, JSON.stringify(map)); content.style.display = ''; const chevron = header.querySelector('.cs-chevron'); - if (chevron) chevron.textContent = '\u25BC'; + if (chevron) chevron.style.transform = 'rotate(90deg)'; } } // ── private ── + _animateEntrance(content) { + if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return; + const selector = this.keyAttr ? `[${this.keyAttr}]` : '.card, .template-card:not(.add-template-card)'; + const cards = content.querySelectorAll(selector); + cards.forEach((card, i) => { + card.style.animationDelay = `${i * 30}ms`; + card.classList.add('card-enter'); + }); + } + _tagCards(content) { if (!this.keyAttr || !this._lastItems) return; const htmlMap = new Map(this._lastItems.map(i => [i.key, i.html])); @@ -294,9 +320,45 @@ export class CardSection { map[this.sectionKey] = nowCollapsed; localStorage.setItem(STORAGE_KEY, JSON.stringify(map)); - content.style.display = nowCollapsed ? 'none' : ''; const chevron = header.querySelector('.cs-chevron'); - if (chevron) chevron.textContent = nowCollapsed ? '\u25B6' : '\u25BC'; + if (chevron) chevron.style.transform = nowCollapsed ? '' : 'rotate(90deg)'; + + // Cancel any running animation on this content + if (content._csAnim) { content._csAnim.cancel(); content._csAnim = null; } + + // Skip animation when user prefers reduced motion + if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) { + content.style.display = nowCollapsed ? 'none' : ''; + return; + } + + if (nowCollapsed) { + const h = content.offsetHeight; + content.style.overflow = 'hidden'; + const anim = content.animate( + [{ height: h + 'px', opacity: 1 }, { height: '0px', opacity: 0 }], + { duration: 200, easing: 'ease-in-out' } + ); + content._csAnim = anim; + anim.onfinish = () => { + content.style.display = 'none'; + content.style.overflow = ''; + content._csAnim = null; + }; + } else { + content.style.display = ''; + content.style.overflow = 'hidden'; + const h = content.scrollHeight; + const anim = content.animate( + [{ height: '0px', opacity: 0 }, { height: h + 'px', opacity: 1 }], + { duration: 200, easing: 'ease-in-out' } + ); + content._csAnim = anim; + anim.onfinish = () => { + content.style.overflow = ''; + content._csAnim = null; + }; + } } _applyFilter(content, query) { diff --git a/server/src/wled_controller/static/js/core/navigation.js b/server/src/wled_controller/static/js/core/navigation.js index e7e1d0e..64f0d19 100644 --- a/server/src/wled_controller/static/js/core/navigation.js +++ b/server/src/wled_controller/static/js/core/navigation.js @@ -38,7 +38,7 @@ export function navigateToCard(tab, subTab, sectionKey, cardAttr, cardValue) { if (content && content.style.display === 'none') { content.style.display = ''; const chevron = header?.querySelector('.cs-chevron'); - if (chevron) chevron.textContent = '\u25BC'; + if (chevron) chevron.style.transform = 'rotate(90deg)'; const map = JSON.parse(localStorage.getItem('sections_collapsed') || '{}'); map[sectionKey] = false; localStorage.setItem('sections_collapsed', JSON.stringify(map)); diff --git a/server/src/wled_controller/static/js/features/dashboard.js b/server/src/wled_controller/static/js/features/dashboard.js index b3d2f2f..b58a520 100644 --- a/server/src/wled_controller/static/js/features/dashboard.js +++ b/server/src/wled_controller/static/js/features/dashboard.js @@ -304,21 +304,43 @@ export function toggleDashboardSection(sectionKey) { if (!header) return; const content = header.nextElementSibling; const chevron = header.querySelector('.dashboard-section-chevron'); - if (collapsed[sectionKey]) { - content.style.display = 'none'; - chevron.textContent = '\u25B6'; + const nowCollapsed = collapsed[sectionKey]; + if (chevron) chevron.style.transform = nowCollapsed ? '' : 'rotate(90deg)'; + + // Animate collapse/expand unless reduced motion + if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) { + content.style.display = nowCollapsed ? 'none' : ''; + return; + } + if (content._dsAnim) { content._dsAnim.cancel(); content._dsAnim = null; } + if (nowCollapsed) { + const h = content.offsetHeight; + content.style.overflow = 'hidden'; + const anim = content.animate( + [{ height: h + 'px', opacity: 1 }, { height: '0px', opacity: 0 }], + { duration: 200, easing: 'ease-in-out' } + ); + content._dsAnim = anim; + anim.onfinish = () => { content.style.display = 'none'; content.style.overflow = ''; content._dsAnim = null; }; } else { content.style.display = ''; - chevron.textContent = '\u25BC'; + content.style.overflow = 'hidden'; + const h = content.scrollHeight; + const anim = content.animate( + [{ height: '0px', opacity: 0 }, { height: h + 'px', opacity: 1 }], + { duration: 200, easing: 'ease-in-out' } + ); + content._dsAnim = anim; + anim.onfinish = () => { content.style.overflow = ''; content._dsAnim = null; }; } } function _sectionHeader(sectionKey, label, count, extraHtml = '') { const collapsed = _getCollapsedSections(); const isCollapsed = !!collapsed[sectionKey]; - const chevron = isCollapsed ? '\u25B6' : '\u25BC'; + const chevronStyle = isCollapsed ? '' : ' style="transform:rotate(90deg)"'; return `
- ${chevron} + ${label} ${count} ${extraHtml}