Skip to content

Commit febe730

Browse files
authored
feat: ✨ config-provider 支持customClass 与 customeStyle (#535)
1 parent cb6be3e commit febe730

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

docs/component/config-provider.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,10 @@ const themeVars: ConfigProviderThemeVars = {
129129
| theme | 主题风格,设置为 `dark` 来开启深色模式,全局生效 | string | `dark`/`light` | - | - |
130130
| theme-vars | 自定义主题变量 | `ConfigProviderThemeVars` | - | - | - |
131131

132+
133+
## 外部样式类
134+
135+
| 类名 | 说明 | 最低版本 |
136+
| ------------ | ---------- | ---------------- |
137+
| custom-class | 根节点样式 | $LOWEST_VERSION$ |
138+
| custom-style | 根节点样式 | $LOWEST_VERSION$ |

src/uni_modules/wot-design-uni/components/wd-config-provider/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import type { ExtractPropTypes, PropType } from 'vue'
2-
import { makeStringProp } from '../common/props'
2+
import { makeStringProp, baseProps } from '../common/props'
33

44
export type ConfigProviderTheme = 'light' | 'dark'
55

66
export const configProviderProps = {
7+
...baseProps,
78
/**
89
* 主题风格,设置为 dark 来开启深色模式,全局生效
910
*/

src/uni_modules/wot-design-uni/components/wd-config-provider/wd-config-provider.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ export default {
2727
<script lang="ts" setup>
2828
import { computed } from 'vue'
2929
import { configProviderProps } from './types'
30+
import { objToStyle } from '../common/util'
3031
3132
const props = defineProps(configProviderProps)
3233
3334
const themeClass = computed(() => {
34-
return `wot-theme-${props.theme}`
35+
return `wot-theme-${props.theme} ${props.customClass}`
3536
})
3637
3738
const themeStyle = computed(() => {
38-
return mapThemeVarsToCSSVars(props.themeVars)
39+
const styleObj = mapThemeVarsToCSSVars(props.themeVars)
40+
return styleObj ? `${objToStyle(styleObj)};${props.customStyle}` : props.customStyle
3941
})
4042
4143
const kebabCase = (str: string): string => {

0 commit comments

Comments
 (0)