doc(config-consumer)

This commit is contained in:
07akioni 2020-01-27 16:18:48 +08:00
parent ca555f31fe
commit bbfcb2da8d
4 changed files with 34 additions and 14 deletions

View File

@ -1,9 +1,11 @@
# Style Scheme
Style scheme exposes the style variables used inside naive-ui. You can use it to create same styled components of naive-ui.
```html
<n-config-consumer>
<template v-slot="{ styleScheme }">
<n-code :code="JSON.stringify(styleScheme, 0, 2)" language="js"></n-code>
</template>
</n-config-consumer>
<div style="overflow: auto">
<n-config-consumer>
<template v-slot="{ styleScheme }">
<n-code :code="JSON.stringify(styleScheme, 0, 2)" language="js"></n-code>
</template>
</n-config-consumer>
</div>
```

View File

@ -5,4 +5,17 @@ Config Consumer is built for getting config (usually as global config) of Config
basic
theme-environment
color
```
```
## Props
## Events
|Name|Parameters|
|-|-|
|theme-change|(theme, oldTheme)|
|namespace-change|(namespace, oldNamespace)|
|language-change|(language, oldLanguage)|
## Slots
|Name|Parameters|
|-|-|
|default|({ theme, namespace, language, themeEnvironment, styleScheme })|

View File

@ -2,13 +2,15 @@
```html
<n-button @click="theme = 'dark'">Dark Theme</n-button>
<n-button @click="theme = 'light'">Light Theme</n-button>
<n-config-provider :theme="theme" :theme-environment="env">
<n-config-consumer>
<template v-slot="{ themeEnvironment }">
{{ themeEnvironment }}
</template>
</n-config-consumer>
</n-config-provider>
<div>
<n-config-provider :theme="theme" :theme-environment="env">
<n-config-consumer>
<template v-slot="{ themeEnvironment }">
{{ themeEnvironment }}
</template>
</n-config-consumer>
</n-config-provider>
</div>
```
```js
export default {

View File

@ -15,6 +15,9 @@ export default {
},
synthesizedThemeEnvironment: function (value, oldValue) {
this.$emit('theme-environment-change', value, oldValue)
},
'NConfigProvider.inheritedLanguage': function (value, oldValue) {
this.$emit('language-change', value, oldValue)
}
},
render (h) {