naive-ui/packages/mixins/themeable.js

40 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-09-17 19:29:27 +08:00
export default {
props: {
theme: {
type: String,
default: null
2019-11-22 13:21:32 +08:00
},
themedStyle: {
type: Object,
default: null
2019-09-17 19:29:27 +08:00
}
},
2019-11-26 18:16:50 +08:00
inject: {
NThemedComponent: {
default: null
}
},
2019-09-17 19:29:27 +08:00
computed: {
synthesizedTheme () {
if (this.theme !== null) {
return this.theme
2019-11-26 18:16:50 +08:00
} else if (this.NThemedComponent && this.NThemedComponent.synthesizedTheme) {
return this.NThemedComponent.synthesizedTheme
2019-09-17 19:29:27 +08:00
} else {
return (this.NConfigProvider && this.NConfigProvider.synthesizedTheme) || null
2019-09-17 19:29:27 +08:00
}
2019-11-22 13:21:32 +08:00
},
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
}
2019-09-17 19:29:27 +08:00
}
}
}