Appearance
getModeByTheme
▸ getModeByTheme(color
, thresholdValue?
): "light"
| "dark"
根据颜色获取对应的颜色模式
参数
Name | Type | Default value | Description |
---|---|---|---|
color | string | undefined | 颜色 |
thresholdValue | number | 0.85 | 亮度阈值 |
返回值
"light"
| "dark"
- 'light' 表示颜色较浅,'dark' 表示颜色较深
示例
ts
const themeMode = getModeByTheme('#000000') // 'light'
const themeMode = getModeByTheme('#ffffff') // 'dark'