Skip to content

Commit 6b5ad36

Browse files
committed
Change provide/inject example
1 parent b729851 commit 6b5ad36

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

docs/.vuepress/components/ThemeButton.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<p class="demo">
3-
<button class="btn" :style="{ color: '#fff', backgroundColor: primary && theme.primaryColor }">
3+
<button class="btn" :style="{ color: '#fff', backgroundColor: (primary && theme.primaryColor) || (secondary && theme.secondaryColor) }">
44
<slot></slot>
55
</button>
66
</p>
@@ -10,15 +10,17 @@
1010
export default {
1111
inject: {
1212
theme: {
13-
default: {
14-
primaryColor: 'darkseagreen',
15-
},
13+
default: {},
1614
},
1715
},
1816
props: {
1917
primary: {
2018
type: Boolean,
21-
default: true,
19+
default: false,
20+
},
21+
secondary: {
22+
type: Boolean,
23+
default: false,
2224
},
2325
},
2426
};

docs/.vuepress/components/ThemeProvider.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export default {
33
provide: {
44
theme: {
55
primaryColor: '#3eaf7c',
6+
secondaryColor: '#1FA2FF'
67
},
78
},
89
render(h) {

docs/patterns/README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,12 @@ export default {
878878
provide: {
879879
theme: {
880880
primaryColor: '#3eaf7c',
881+
secondaryColor: '#1FA2FF'
881882
},
882883
},
884+
render(h) {
885+
return this.$slots.default[0];
886+
},
883887
};
884888
```
885889

@@ -888,7 +892,7 @@ export default {
888892
889893
<template>
890894
<p class="demo">
891-
<button class="btn" :style="{ color: '#fff', backgroundColor: primary && theme.primaryColor }">
895+
<button class="btn" :style="{ color: '#fff', backgroundColor: (primary && theme.primaryColor) || (secondary && theme.secondaryColor) }">
892896
<slot></slot>
893897
</button>
894898
</p>
@@ -898,15 +902,17 @@ export default {
898902
export default {
899903
inject: {
900904
theme: {
901-
default: {
902-
primaryColor: 'darkseagreen',
903-
},
905+
default: {},
904906
},
905907
},
906908
props: {
907909
primary: {
908910
type: Boolean,
909-
default: true,
911+
default: false,
912+
},
913+
secondary: {
914+
type: Boolean,
915+
default: false,
910916
},
911917
},
912918
};
@@ -915,14 +921,14 @@ export default {
915921

916922
```vue
917923
<theme-provider>
918-
<theme-button>Themed Button</theme-button>
924+
<theme-button secondary>Themed Button</theme-button>
919925
</theme-provider>
920926
```
921927

922928
#### Working Example:
923929

924930
<ThemeProvider>
925-
<ThemeButton>Themed Button</ThemeButton>
931+
<ThemeButton secondary>Themed Button</ThemeButton>
926932
</ThemeProvider>
927933

928934
### [@Provide / @Inject Decorator](https://github.com/kaorun343/vue-property-decorator)

0 commit comments

Comments
 (0)