mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-12-02 17:53:47 +08:00
Improve theme consistency, keyboard navigation, and reusable frontend components. Harden fullstack initialization and expose scoped lint and Vitest commands.
44 lines
1.5 KiB
TypeScript
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,
|
|
)
|
|
}
|
|
}
|
|
},
|
|
)
|