feat(app): inherit theme

This commit is contained in:
07akioni 2019-10-12 16:09:30 +08:00
parent 28262b5ee9
commit 1b11ba77a3
4 changed files with 23 additions and 1 deletions

View File

@ -4,4 +4,5 @@ App is using to set global theme and set namespace for components (detached part
```demo
theme
namespace
inherit-theme
```

View File

@ -0,0 +1,7 @@
# Inherit Theme
If you don't set theme of app, the theme of app is inherited by default.
```html
<n-app>
<n-tag>Oops</n-tag>
</n-app>
```

View File

@ -18,6 +18,11 @@ export default {
NApp: this
}
},
inject: {
NApp: {
default: null
}
},
props: {
namespace: {
type: String,
@ -27,6 +32,15 @@ export default {
type: String,
default: null
}
},
computed: {
synthesizedTheme () {
if (this.theme !== null) {
return this.theme
} else {
return (this.NApp && this.NApp.synthesizedTheme) || null
}
}
}
}
</script>

View File

@ -10,7 +10,7 @@ export default {
if (this.theme !== null) {
return this.theme
} else {
return (this.NApp && this.NApp.theme) || null
return (this.NApp && this.NApp.synthesizedTheme) || null
}
}
}