From ae0629628e3430a7665f7be140503d28c474f575 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Wed, 9 Apr 2025 11:18:30 +0800 Subject: [PATCH] Enhance settings modal with video autoplay on hover option and improve layout. Fixes https://github.com/willmiao/ComfyUI-Lora-Manager/issues/92 --- static/css/components/modal.css | 59 +++++--- static/js/components/LoraCard.js | 29 +++- static/js/core.js | 6 +- static/js/managers/SettingsManager.js | 197 ++++++++++++++++++++++++++ templates/components/modals.html | 123 +++++++++------- 5 files changed, 341 insertions(+), 73 deletions(-) diff --git a/static/css/components/modal.css b/static/css/components/modal.css index 1153bbc4..318480e0 100644 --- a/static/css/components/modal.css +++ b/static/css/components/modal.css @@ -196,7 +196,7 @@ body.modal-open { } .settings-modal { - max-width: 500px; + max-width: 650px; /* Further increased from 600px for more space */ } /* Settings Links */ @@ -266,14 +266,22 @@ body.modal-open { } } +/* API key input specific styles */ .api-key-input { + width: 100%; /* Take full width of parent */ position: relative; display: flex; align-items: center; } .api-key-input input { - padding-right: 40px; + width: 100%; + padding: 6px 40px 6px 10px; /* Add left padding */ + height: 32px; + border-radius: var(--border-radius-xs); + border: 1px solid var(--border-color); + background-color: var(--lora-surface); + color: var(--text-color); } .api-key-input .toggle-visibility { @@ -294,8 +302,10 @@ body.modal-open { .input-help { font-size: 0.85em; color: var(--text-color); - opacity: 0.8; - margin-top: 4px; + opacity: 0.7; + margin-top: 8px; /* Space between control and help */ + line-height: 1.4; + width: 100%; /* Full width */ } /* 统一各个 section 的样式 */ @@ -341,8 +351,8 @@ body.modal-open { .setting-item { display: flex; - flex-direction: column; - margin-bottom: var(--space-2); + flex-direction: column; /* Changed to column for help text placement */ + margin-bottom: var(--space-3); /* Increased to provide more spacing between items */ padding: var(--space-1); border-radius: var(--border-radius-xs); } @@ -355,35 +365,52 @@ body.modal-open { background: rgba(255, 255, 255, 0.05); } -.setting-info { - margin-bottom: var(--space-1); +/* Control row with label and input together */ +.setting-row { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; width: 100%; } +.setting-info { + margin-bottom: 0; + width: 35%; /* Increased from 30% to prevent wrapping */ + flex-shrink: 0; /* Prevent shrinking */ +} + .setting-info label { display: block; - margin-bottom: 4px; font-weight: 500; + margin-bottom: 0; + white-space: nowrap; /* Prevent label wrapping */ } .setting-control { - width: 100%; - margin-bottom: var(--space-1); + width: 60%; /* Decreased slightly from 65% */ + margin-bottom: 0; + display: flex; + justify-content: flex-end; /* Right-align all controls */ } /* Select Control Styles */ .select-control { width: 100%; + display: flex; + justify-content: flex-end; } .select-control select { width: 100%; + max-width: 100%; /* Increased from 200px */ padding: 6px 10px; border-radius: var(--border-radius-xs); border: 1px solid var(--border-color); background-color: var(--lora-surface); color: var(--text-color); font-size: 0.95em; + height: 32px; } /* Fix dark theme select dropdown text color */ @@ -409,6 +436,7 @@ body.modal-open { width: 50px; height: 24px; cursor: pointer; + margin-left: auto; /* Push to right side */ } .toggle-switch input { @@ -458,15 +486,6 @@ input:checked + .toggle-slider:before { width: 22px; } -/* Update input help styles */ -.input-help { - font-size: 0.85em; - color: var(--text-color); - opacity: 0.7; - margin-top: 4px; - line-height: 1.4; -} - /* Blur effect for NSFW content */ .nsfw-blur { filter: blur(12px); diff --git a/static/js/components/LoraCard.js b/static/js/components/LoraCard.js index 64a59a61..c4baee23 100644 --- a/static/js/components/LoraCard.js +++ b/static/js/components/LoraCard.js @@ -57,10 +57,15 @@ export function createLoraCard(lora) { nsfwText = "R-rated Content"; } + // Check if autoplayOnHover is enabled for video previews + const autoplayOnHover = state.global.settings.autoplayOnHover || false; + const isVideo = previewUrl.endsWith('.mp4'); + const videoAttrs = autoplayOnHover ? 'controls muted loop' : 'controls autoplay muted loop'; + card.innerHTML = `
- ${previewUrl.endsWith('.mp4') ? - `