style: 优化按钮禁用态与主题入口并将设置移至侧栏底部

This commit is contained in:
GouJ
2026-09-01 21:58:32 +08:00
parent 03bf87ca9a
commit a24326b85d
11 changed files with 278 additions and 71 deletions
+8 -3
View File
@@ -83,7 +83,7 @@ describe('微信风格明暗主题', () => {
expect(state.theme.value?.name).toBe('dark')
expect(state.overrides.value.common?.primaryColor).toBe('#07c160')
expect(state.overrides.value.common?.bodyColor).toBe('#111111')
expect(state.overrides.value.Button?.textColorPrimary).toBe('#082b17')
expect(state.overrides.value.Button?.textColorPrimary).toBe('#ffffff')
expect(document.documentElement.dataset.theme).toBe('dark')
})
@@ -127,8 +127,13 @@ describe('微信风格明暗主题', () => {
expect(Button?.colorHover).toBe(tokens['control-hover'])
expect(Select?.peers?.InternalSelection?.color).toBe(tokens.control)
expect(Button?.textColorPrimary).toBe(tokens['on-accent'])
for (const background of [common!.primaryColor!, common!.primaryColorHover!, common!.primaryColorPressed!]) {
expect(contrast(String(Button!.textColorPrimary), background)).toBeGreaterThanOrEqual(4.5)
expect(Button?.colorPrimary).toBe(tokens['button-primary'])
expect(Button?.colorHoverPrimary).toBe(tokens['button-hover'])
expect(Button?.colorPressedPrimary).toBe(tokens['button-pressed'])
expect(Button?.colorDisabledPrimary).toBe(tokens['disabled-bg'])
expect(Button?.textColorDisabledPrimary).toBe(tokens['disabled-text'])
for (const background of [Button!.colorPrimary!, Button!.colorHoverPrimary!, Button!.colorPressedPrimary!]) {
expect(contrast(String(Button!.textColorPrimary), String(background))).toBeGreaterThanOrEqual(4.5)
}
expect(contrast(tokens.ink!, tokens.surface!)).toBeGreaterThanOrEqual(4.5)
expect(contrast(tokens.muted!, tokens.subtle!)).toBeGreaterThanOrEqual(4.5)
+40 -4
View File
@@ -28,7 +28,13 @@ export function useTheme() {
const primary = '#07c160'
const hover = '#2dcb79'
const pressed = '#06ad56'
const onPrimary = '#082b17'
// 实心绿按钮使用白字;按钮底色独立于品牌绿,兼顾正常、悬停和按下态的可读性。
const onPrimary = '#ffffff'
const buttonPrimary = '#078640'
const buttonHover = '#087c42'
const buttonPressed = '#066b36'
const disabledColor = dark ? '#303030' : '#e4e4e4'
const disabledText = dark ? '#808080' : '#8c8c8c'
const accentText = dark ? '#5cd693' : '#087c42'
const body = dark ? '#111111' : '#ededed'
const surface = dark ? '#191919' : '#ffffff'
@@ -102,13 +108,43 @@ export function useTheme() {
borderPressed: 'none',
borderDisabled: 'none',
borderFocus: focusBorder,
opacityDisabled: '1',
colorDisabled: disabledColor,
textColorDisabled: disabledText,
colorPrimary: buttonPrimary,
colorHoverPrimary: buttonHover,
colorPressedPrimary: buttonPressed,
colorFocusPrimary: buttonHover,
colorDisabledPrimary: disabledColor,
borderPrimary: 'none',
borderHoverPrimary: 'none',
borderPressedPrimary: 'none',
borderFocusPrimary: 'none',
borderDisabledPrimary: 'none',
textColorPrimary: onPrimary,
textColorHoverPrimary: onPrimary,
textColorPressedPrimary: onPrimary,
textColorFocusPrimary: onPrimary,
textColorDisabledPrimary: onPrimary,
textColorDisabledPrimary: disabledText,
textColorTextPrimary: accentText,
textColorGhostPrimary: accentText
textColorGhostPrimary: accentText,
colorSuccess: buttonPrimary,
colorHoverSuccess: buttonHover,
colorPressedSuccess: buttonPressed,
colorFocusSuccess: buttonHover,
colorDisabledSuccess: disabledColor,
borderSuccess: 'none',
borderHoverSuccess: 'none',
borderPressedSuccess: 'none',
borderFocusSuccess: 'none',
borderDisabledSuccess: 'none',
textColorSuccess: onPrimary,
textColorHoverSuccess: onPrimary,
textColorPressedSuccess: onPrimary,
textColorFocusSuccess: onPrimary,
textColorDisabledSuccess: disabledText,
textColorTextSuccess: accentText,
textColorGhostSuccess: accentText
},
Input: {
color: control,
@@ -190,7 +226,7 @@ export function useTheme() {
borderWarning: 'none',
borderError: 'none'
},
Checkbox: { checkMarkColor: onPrimary },
Checkbox: { checkMarkColor: '#082b17' },
Switch: { railColorActive: primary },
Progress: { fillColor: primary }
} satisfies GlobalThemeOverrides