mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
Add search clear button
This commit is contained in:
@@ -854,7 +854,7 @@ body.modal-open {
|
|||||||
/* 调整搜索框样式以匹配其他控件 */
|
/* 调整搜索框样式以匹配其他控件 */
|
||||||
.search-container input {
|
.search-container input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 6px 32px 6px 12px;
|
padding: 6px 40px 6px 12px; /* 减小右侧padding */
|
||||||
border: 1px solid oklch(65% 0.02 256); /* 更深的边框颜色,提高对比度 */
|
border: 1px solid oklch(65% 0.02 256); /* 更深的边框颜色,提高对比度 */
|
||||||
border-radius: var(--border-radius-sm);
|
border-radius: var(--border-radius-sm);
|
||||||
background: var(--lora-surface);
|
background: var(--lora-surface);
|
||||||
@@ -871,7 +871,7 @@ body.modal-open {
|
|||||||
|
|
||||||
.search-icon {
|
.search-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: calc(32px + 8px); /* 调整位置,留出toggle按钮的空间 */
|
right: 40px; /* 调整到toggle按钮左侧 */
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
color: oklch(var(--text-color) / 0.5);
|
color: oklch(var(--text-color) / 0.5);
|
||||||
@@ -879,6 +879,30 @@ body.modal-open {
|
|||||||
line-height: 1; /* 防止图标影响容器高度 */
|
line-height: 1; /* 防止图标影响容器高度 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 修改清空按钮样式 */
|
||||||
|
.search-clear {
|
||||||
|
position: absolute;
|
||||||
|
right: 65px; /* 放到search-icon左侧 */
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
color: oklch(var(--text-color) / 0.5);
|
||||||
|
cursor: pointer;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
padding: 4px 8px; /* 增加点击区域 */
|
||||||
|
display: none; /* 默认隐藏 */
|
||||||
|
line-height: 1;
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-clear:hover {
|
||||||
|
color: var(--lora-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-clear.visible {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
.search-mode-toggle {
|
.search-mode-toggle {
|
||||||
background: var(--lora-surface);
|
background: var(--lora-surface);
|
||||||
border: 1px solid oklch(65% 0.02 256);
|
border: 1px solid oklch(65% 0.02 256);
|
||||||
|
|||||||
@@ -13,11 +13,18 @@ export class SearchManager {
|
|||||||
this.isSearching = false;
|
this.isSearching = false;
|
||||||
this.isRecursiveSearch = false;
|
this.isRecursiveSearch = false;
|
||||||
|
|
||||||
|
// Add clear button
|
||||||
|
this.createClearButton();
|
||||||
|
|
||||||
// Add this instance to state
|
// Add this instance to state
|
||||||
state.searchManager = this;
|
state.searchManager = this;
|
||||||
|
|
||||||
if (this.searchInput) {
|
if (this.searchInput) {
|
||||||
this.searchInput.addEventListener('input', this.handleSearch.bind(this));
|
this.searchInput.addEventListener('input', this.handleSearch.bind(this));
|
||||||
|
// Update clear button visibility on input
|
||||||
|
this.searchInput.addEventListener('input', () => {
|
||||||
|
this.updateClearButtonVisibility();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.searchModeToggle) {
|
if (this.searchModeToggle) {
|
||||||
@@ -38,6 +45,35 @@ export class SearchManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createClearButton() {
|
||||||
|
// Create clear button
|
||||||
|
const clearButton = document.createElement('button');
|
||||||
|
clearButton.className = 'search-clear';
|
||||||
|
clearButton.innerHTML = '<i class="fas fa-times"></i>';
|
||||||
|
clearButton.title = 'Clear search';
|
||||||
|
|
||||||
|
// Add click handler
|
||||||
|
clearButton.addEventListener('click', () => {
|
||||||
|
this.searchInput.value = '';
|
||||||
|
this.currentSearchTerm = '';
|
||||||
|
this.updateClearButtonVisibility();
|
||||||
|
resetAndReload();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Insert after search input
|
||||||
|
this.searchInput.parentNode.appendChild(clearButton);
|
||||||
|
this.clearButton = clearButton;
|
||||||
|
|
||||||
|
// Set initial visibility
|
||||||
|
this.updateClearButtonVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateClearButtonVisibility() {
|
||||||
|
if (this.clearButton) {
|
||||||
|
this.clearButton.classList.toggle('visible', this.searchInput.value.length > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateToggleUI() {
|
updateToggleUI() {
|
||||||
if (this.searchModeToggle) {
|
if (this.searchModeToggle) {
|
||||||
this.searchModeToggle.classList.toggle('active', this.isRecursiveSearch);
|
this.searchModeToggle.classList.toggle('active', this.isRecursiveSearch);
|
||||||
|
|||||||
@@ -30,10 +30,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="search-container">
|
<div class="search-container">
|
||||||
<input type="text" id="searchInput" placeholder="Search models..." />
|
<input type="text" id="searchInput" placeholder="Search models..." />
|
||||||
|
<!-- 清空按钮将由JavaScript动态添加到这里 -->
|
||||||
|
<i class="fas fa-search search-icon"></i>
|
||||||
<button class="search-mode-toggle" id="searchModeToggle" title="Toggle recursive search in folders">
|
<button class="search-mode-toggle" id="searchModeToggle" title="Toggle recursive search in folders">
|
||||||
<i class="fas fa-folder"></i>
|
<i class="fas fa-folder"></i>
|
||||||
</button>
|
</button>
|
||||||
<i class="fas fa-search search-icon"></i>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user