From 08afb05ece477afc772c0930307054afb42f7e88 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Thu, 21 May 2026 21:11:25 +0800 Subject: [PATCH] refactor: normalize components in Phase 2 - Unify button styles (padding, gap, border-radius, hover states) in _base.css - Fix .secondary-btn syntax error (extra space in var()) - Remove duplicated .card-actions in card.css - Replace hardcoded #f0f0f0 with --surface-hover token - Replace #ffc107 with accessible #d4a017 for favorite stars - Replace hardcoded rgba shadows with semantic --shadow-* tokens in layout.css - Replace hardcoded rgba(0,0,0,0.03)/rgba(255,255,255,0.03) with --surface-hover - Remove redundant [data-theme=dark] overrides by using theme-aware tokens - Replace .dropdown-main hardcoded border with --border-color token --- static/css/components/card.css | 21 +++---- static/css/components/modal/_base.css | 88 +++++++++------------------ static/css/layout.css | 20 +++--- 3 files changed, 45 insertions(+), 84 deletions(-) diff --git a/static/css/components/card.css b/static/css/components/card.css index cda903a7..99a7ef76 100644 --- a/static/css/components/card.css +++ b/static/css/components/card.css @@ -353,9 +353,11 @@ } .card-actions { + flex-shrink: 0; display: flex; - gap: var(--space-1); /* Use gap instead of margin for spacing between icons */ - align-items: center; + gap: var(--space-1); + align-items: flex-end; + align-self: flex-end; } .card-actions i:hover { @@ -364,10 +366,9 @@ background-color: rgba(255, 255, 255, 0.1); } -/* Style for active favorites */ .favorite-active { - color: #ffc107 !important; /* Gold color for favorites */ - text-shadow: 0 0 5px rgba(255, 193, 7, 0.5); + color: #d4a017 !important; + text-shadow: 0 0 5px rgba(212, 160, 23, 0.5); } @media (max-width: 1200px) { @@ -391,14 +392,6 @@ } } -.card-actions { - flex-shrink: 0; /* Prevent actions from shrinking */ - display: flex; - gap: var(--space-1); - align-items: flex-end; /* 将图标靠下对齐 */ - align-self: flex-end; /* 将整个actions容器靠下对齐 */ -} - .model-link { margin-top: var(--space-1); } @@ -438,7 +431,7 @@ .base-model { display: inline-block; - background: #f0f0f0; + background: var(--surface-hover, oklch(95% 0 0)); padding: 2px 6px; border-radius: var(--border-radius-xs); margin-right: 6px; diff --git a/static/css/components/modal/_base.css b/static/css/components/modal/_base.css index be4f21b0..e8e80b8a 100644 --- a/static/css/components/modal/_base.css +++ b/static/css/components/modal/_base.css @@ -29,10 +29,7 @@ body.modal-open { border-radius: var(--border-radius-base); padding: var(--space-3); border: 1px solid var(--lora-border); - box-shadow: - 0 4px 6px -1px rgba(0, 0, 0, 0.1), - 0 2px 4px -1px rgba(0, 0, 0, 0.06), - 0 10px 15px -3px rgba(0, 0, 0, 0.05); + box-shadow: var(--shadow-md); overflow-y: auto; overflow-x: hidden; /* 防止水平滚动条 */ scrollbar-gutter: stable both-edges; /* Reserve space to prevent layout shift when scrollbar toggles */ @@ -67,12 +64,18 @@ body.modal-open { } .cancel-btn, .delete-btn, .exclude-btn, .confirm-btn { - padding: 8px var(--space-2); - border-radius: 6px; + display: flex; + align-items: center; + justify-content: center; + gap: var(--space-1); + padding: var(--space-1) var(--space-2); + border-radius: var(--border-radius-sm); border: none; cursor: pointer; font-weight: 500; + font-size: 0.95em; min-width: 100px; + transition: background-color 0.2s, opacity 0.2s; } .cancel-btn { @@ -97,11 +100,10 @@ body.modal-open { } .delete-btn:hover { - opacity: 0.9; + background: oklch(from var(--lora-error) l c h / 85%); } .exclude-btn:hover, .confirm-btn:hover { - opacity: 0.9; background: oklch(from var(--lora-accent, #4f46e5) l c h / 85%); } @@ -135,8 +137,8 @@ body.modal-open { .update-info, .info-item, .path-preview { - background: rgba(0, 0, 0, 0.03); - border: 1px solid rgba(0, 0, 0, 0.1); + background: var(--surface-hover); + border: 1px solid var(--lora-border); border-radius: var(--border-radius-sm); padding: var(--space-2); } @@ -147,21 +149,11 @@ body.modal-open { border: 1px solid var(--lora-border); } -[data-theme="dark"] .support-section, -[data-theme="dark"] .changelog-section, -[data-theme="dark"] .update-info, -[data-theme="dark"] .info-item, -[data-theme="dark"] .path-preview, -[data-theme="dark"] #bulkDownloadMissingLorasModal .bulk-download-loras-preview { - background: rgba(255, 255, 255, 0.03); - border: 1px solid var(--lora-border); -} - .primary-btn { display: flex; align-items: center; gap: 8px; - padding: 8px 16px; + padding: var(--space-1) var(--space-2); background-color: var(--lora-accent); color: var(--lora-text); border: none; @@ -181,9 +173,9 @@ body.modal-open { display: flex; align-items: center; gap: 8px; - padding: 8px 16px; + padding: var(--space-1) var(--space-2); background-color: var(--card-bg); - color: var (--text-color); + color: var(--text-color); border: 1px solid var(--border-color); border-radius: var(--border-radius-sm); cursor: pointer; @@ -244,7 +236,7 @@ button:disabled, display: flex; align-items: center; gap: 8px; - padding: 8px 16px; + padding: var(--space-1) var(--space-2); background-color: var(--lora-error); color: white; border: none; @@ -261,18 +253,13 @@ button:disabled, /* Metadata archive status styles */ .metadata-archive-status { - background: rgba(0, 0, 0, 0.03); - border: 1px solid rgba(0, 0, 0, 0.1); + background: var(--surface-hover); + border: 1px solid var(--lora-border); border-radius: var(--border-radius-sm); padding: var(--space-2); margin-bottom: var(--space-2); } -[data-theme="dark"] .metadata-archive-status { - background: rgba(255, 255, 255, 0.03); - border: 1px solid var(--lora-border); -} - .archive-status-item { display: flex; justify-content: space-between; @@ -312,17 +299,12 @@ button:disabled, } .backup-status { - background: rgba(0, 0, 0, 0.03); - border: 1px solid rgba(0, 0, 0, 0.1); + background: var(--surface-hover); + border: 1px solid var(--lora-border); border-radius: var(--border-radius-sm); padding: var(--space-3); } -[data-theme="dark"] .backup-status { - background: rgba(255, 255, 255, 0.03); - border: 1px solid var(--lora-border); -} - .backup-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); @@ -331,17 +313,12 @@ button:disabled, } .backup-summary-card { - background: rgba(255, 255, 255, 0.5); - border: 1px solid rgba(0, 0, 0, 0.06); + background: var(--lora-surface); + border: 1px solid var(--lora-border); border-radius: var(--border-radius-sm); padding: var(--space-2); } -[data-theme="dark"] .backup-summary-card { - background: rgba(255, 255, 255, 0.02); - border-color: rgba(255, 255, 255, 0.05); -} - .backup-summary-label { color: var(--text-color); font-size: 0.85rem; @@ -404,14 +381,9 @@ button:disabled, } .backup-location-details { - border: 1px solid rgba(0, 0, 0, 0.1); + border: 1px solid var(--lora-border); border-radius: var(--border-radius-sm); - background: rgba(0, 0, 0, 0.02); -} - -[data-theme="dark"] .backup-location-details { - border-color: var(--lora-border); - background: rgba(255, 255, 255, 0.02); + background: var(--surface-hover); } .backup-location-details summary { @@ -442,16 +414,12 @@ button:disabled, max-width: 100%; padding: 6px 8px; border-radius: var(--border-radius-sm); - background: rgba(0, 0, 0, 0.05); + background: var(--surface-hover); color: var(--text-color); overflow-wrap: anywhere; word-break: break-word; } -[data-theme="dark"] .backup-location-path { - background: rgba(255, 255, 255, 0.05); -} - @media (max-width: 768px) { .backup-status-row { grid-template-columns: 1fr; @@ -519,8 +487,8 @@ button:disabled, } #bulkDownloadMissingLorasModal .bulk-download-loras-preview { - background: rgba(0, 0, 0, 0.03); - border: 1px solid rgba(0, 0, 0, 0.1); + background: var(--surface-hover); + border: 1px solid var(--lora-border); border-radius: var(--border-radius-sm); padding: var(--space-3); margin-bottom: var(--space-3); @@ -578,7 +546,7 @@ button:disabled, align-items: flex-start; gap: var(--space-2); padding: var(--space-2); - background: rgba(59, 130, 246, 0.1); + background: oklch(from var(--lora-accent) l c h / 0.1); border-radius: var(--border-radius-sm); font-size: 0.9em; color: var(--text-color); diff --git a/static/css/layout.css b/static/css/layout.css index 23cb71c5..ddee0919 100644 --- a/static/css/layout.css +++ b/static/css/layout.css @@ -22,7 +22,7 @@ z-index: calc(var(--z-header) - 1); background: var(--bg-color); padding: var(--space-1) 0; - box-shadow: 0 1px 3px rgba(0,0,0,0.05); + box-shadow: var(--shadow-xs); } /* Responsive container for larger screens */ @@ -80,19 +80,19 @@ font-size: 0.85em; transition: all 0.2s ease; cursor: pointer; - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: var(--shadow-xs); } .control-group button:hover { border-color: var(--lora-accent); background: var(--bg-color); transform: translateY(-1px); - box-shadow: 0 3px 5px rgba(0, 0, 0, 0.08); + box-shadow: var(--shadow-lg); } .control-group button:active { transform: translateY(0); - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: var(--shadow-xs); } .control-group button i { @@ -220,7 +220,7 @@ background-size: 14px; cursor: pointer; transition: all 0.2s ease; - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); + box-shadow: var(--shadow-xs); } /* Style for optgroups */ @@ -252,7 +252,7 @@ border-color: var(--lora-accent); background-color: var(--bg-color); transform: translateY(-1px); - box-shadow: 0 3px 5px rgba(0, 0, 0, 0.08); + box-shadow: var(--shadow-lg); } .control-group select:focus { @@ -294,7 +294,7 @@ transform: translateY(10px); transition: all 0.3s ease; z-index: var(--z-overlay); - box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); + box-shadow: var(--shadow-sm); } .back-to-top.visible { @@ -307,7 +307,7 @@ background: var(--lora-accent); color: white; transform: translateY(-2px); - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); + box-shadow: var(--shadow-md); } /* Prevent text selection in control and header areas */ @@ -336,7 +336,7 @@ .dropdown-main { border-top-right-radius: 0; border-bottom-right-radius: 0; - border-right: 1px solid rgba(0, 0, 0, 0.1); + border-right: 1px solid var(--border-color); } .dropdown-toggle { @@ -364,7 +364,7 @@ background-color: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--border-radius-xs); - box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); + box-shadow: var(--shadow-xl); } .dropdown-group.active .dropdown-menu {