feat(authFileCard): add disabled state styling and update tests for clarity

This commit is contained in:
Supra4E8C
2026-09-28 21:12:49 +08:00
parent 2c234bc317
commit 59228ead02
3 changed files with 20 additions and 1 deletions
@@ -2,7 +2,7 @@
/* ============================================================
* 凭证卡片 — statTile 配方(14px 圆角 / 1px 边框 / 82% 透感纸面)
* 身份优先;启停仅由底部开关表达,停用不降低内容对比度。
* 身份优先;停用时弱化内容,操作区保持清晰以便重新启用。
* ============================================================ */
.card {
@@ -23,6 +23,14 @@
}
}
.cardDisabled {
background: color-mix(in srgb, var(--bg-primary) 55%, var(--bg-tertiary));
}
.cardDisabled > :not(.actions) {
opacity: 0.68;
}
.cardCompact {
gap: 10px;
padding: 13px 14px;
@@ -119,6 +119,7 @@ export function AuthFileCard(props: AuthFileCardProps) {
styles.card,
compact ? styles.cardCompact : '',
selected ? styles.cardSelected : '',
file.disabled === true ? styles.cardDisabled : '',
mountEntranceDelayMs != null ? styles.cardEnter : '',
]
.filter(Boolean)
+10
View File
@@ -7,6 +7,10 @@ const source = readFileSync(
new URL('../src/features/authFiles/components/AuthFileCard.tsx', import.meta.url),
'utf8'
);
const styles = readFileSync(
new URL('../src/features/authFiles/components/AuthFileCard.module.scss', import.meta.url),
'utf8'
);
describe('auth file card presentation contract', () => {
test('uses identity rather than logos or duplicate status badges', () => {
@@ -32,6 +36,12 @@ describe('auth file card presentation contract', () => {
expect(footer).toContain('!isRuntimeOnly &&');
});
test('dims disabled card content but keeps the re-enable controls clear', () => {
expect(source).toContain("file.disabled === true ? styles.cardDisabled : ''");
expect(styles).toMatch(/\.cardDisabled\s*>\s*:not\(\.actions\)\s*\{\s*opacity:\s*0\.68;/);
expect(styles).not.toMatch(/\.cardDisabled\s*\{[^}]*opacity:/);
});
test('uses a plain-text weight tooltip while preserving the details link', () => {
expect(source).toContain("title={t('auth_files.weight_tooltip')}");
expect(source).not.toContain("title={t('auth_files.weight_hint')}");