ray-template/__test__/components/form-themes.spec.ts
XiaoDaiGua-Ray 911c403434
feat: refine admin workflows for v6.0.3
Improve theme consistency, keyboard navigation, and reusable frontend components.
Harden fullstack initialization and expose scoped lint and Vitest commands.
2026-12-01 11:04:13 +08:00

44 lines
1.5 KiB
TypeScript

import { darkTheme, lightTheme } from 'naive-ui'
import {
themeStyleOverrides,
themeStyles,
} from '../../packages/ui/src/theme-presets'
import { contrast } from '../utils/color-contrast'
it.each(themeStyles)(
'%s keeps editable fields and primary buttons legible in both modes',
(style) => {
for (const mode of ['light', 'dark'] as const) {
const base = mode === 'light' ? lightTheme : darkTheme
const overrides = themeStyleOverrides[style][mode]
const common = { ...base.common, ...overrides.common }
const input = { ...base.Input.self!(common), ...overrides.Input }
const selection = {
...base.Select.peers!.InternalSelection.self!(common),
...overrides.InternalSelection,
}
const button = { ...base.Button.self!(common), ...overrides.Button }
for (const field of [input, selection]) {
expect(
contrast(field.placeholderColor, field.color, common.cardColor),
).toBeGreaterThanOrEqual(4.5)
expect(
contrast(field.border.replace(/^1px solid /, ''), common.cardColor),
).toBeGreaterThanOrEqual(3)
}
for (const [text, fill] of [
[button.textColorPrimary, button.colorPrimary],
[button.textColorHoverPrimary, button.colorHoverPrimary],
[button.textColorPressedPrimary, button.colorPressedPrimary],
[button.textColorFocusPrimary, button.colorFocusPrimary],
]) {
expect(contrast(text, fill, common.cardColor)).toBeGreaterThanOrEqual(
4.5,
)
}
}
},
)