feat(message, confirm, notification): make them work as theme context

This commit is contained in:
07akioni 2020-03-25 22:29:14 +08:00
parent d0edcb4a61
commit 9c35d19a2b
6 changed files with 28 additions and 7 deletions

View File

@ -79,6 +79,7 @@ import iosCloseCircle from '../../_icons/ios-close-circle'
import withapp from '../../_mixins/withapp'
import themeable from '../../_mixins/themeable'
import render from '../../_utils/vue/render'
import asthemecontext from '../../_mixins/asthemecontext'
export default {
name: 'NConfirm',
@ -91,7 +92,7 @@ export default {
iosCloseCircle,
render
},
mixins: [withapp, themeable],
mixins: [withapp, themeable, asthemecontext],
props: {
icon: {
type: Function,
@ -132,6 +133,10 @@ export default {
bordered: {
type: Boolean,
default: false
},
themeContextActivated: {
type: Boolean,
default: false
}
},
computed: {

View File

@ -14,6 +14,7 @@
:negative-text="negativeText"
:title="title"
:loading="loading"
theme-context-activated
@close="handleCloseClick"
@negative-click="handleNegativeClick"
@positive-click="handlePositiveClick"

View File

@ -7,8 +7,11 @@ import mdCloseCircle from '../../_icons/md-close-circle'
import NBaseLoading from '../../_base/Loading'
import IconSwitchTransition from '../../_transition/IconSwitchTransition'
import render from '../../_utils/vue/render'
import themeable from '../../_mixins/themeable'
import asthemecontext from '../../_mixins/asthemecontext'
export default {
mixins: [ themeable, asthemecontext ],
props: {
icon: {
type: [String, Function],

View File

@ -64,6 +64,7 @@ import mdAlert from '../../_icons/md-alert'
import mdInformationCircle from '../../_icons/md-information-circle'
import mdCloseCircle from '../../_icons/md-close-circle'
import render from '../../_utils/vue/render'
import asthemecontext from '../../_mixins/asthemecontext'
export default {
components: {
@ -75,7 +76,7 @@ export default {
mdInformationCircle,
mdCloseCircle
},
mixins: [ themeable ],
mixins: [ themeable, asthemecontext ],
props: {
closable: {
type: Boolean,

View File

@ -1,4 +1,10 @@
export default {
props: {
themeContextActivated: {
type: Boolean,
default: true
}
},
provide () {
return {
NThemedComponent: this

View File

@ -19,12 +19,17 @@ export default {
const theme = this.theme
if (theme !== null) {
return theme
} else if (this.NThemedComponent && this.NThemedComponent.theme) {
return this.NThemedComponent.theme
} else {
const NConfigProvider = this.NConfigProvider
return (NConfigProvider && NConfigProvider.syntheticTheme) || null
}
const NThemedComponent = this.NThemedComponent
if (
NThemedComponent &&
NThemedComponent.theme &&
NThemedComponent.themeContextActivated
) {
return NThemedComponent.theme
}
const NConfigProvider = this.NConfigProvider
return (NConfigProvider && NConfigProvider.syntheticTheme) || null
},
syntheticStyle () {
const themedStyle = this.themedStyle