naive-ui/packages/mixins/themeable.js
songwanli2025@163.com 4f90dd3b05 merge from upstream
2019-12-17 14:36:37 +08:00

40 lines
1.0 KiB
JavaScript

export default {
props: {
theme: {
type: String,
default: null
},
themedStyle: {
type: Object,
default: null
}
},
inject: {
NThemedComponent: {
default: null
}
},
computed: {
synthesizedTheme () {
if (this.theme !== null) {
return this.theme
} else if (this.NThemedComponent && this.NThemedComponent.synthesizedTheme) {
return this.NThemedComponent.synthesizedTheme
} else {
return (this.NConfigProvider && this.NConfigProvider.synthesizedTheme) || null
}
},
synthesizedStyle () {
if (this.themedStyle && this.synthesizedTheme && this.themedStyle[this.synthesizedTheme]) {
return this.themedStyle[this.synthesizedTheme]
}
return null
},
synthesizedThemeEnvironment () {
if (this.synthesizedTheme && this.NConfigProvider && this.NConfigProvider.inheritedThemeEnvironment) {
return this.NConfigProvider.inheritedThemeEnvironment[this.synthesizedTheme] || null
}
}
}
}