Skip to content

Commit a194808

Browse files
committed
fix: fixed component name
1 parent 21d59c3 commit a194808

File tree

6 files changed

+46
-17
lines changed

6 files changed

+46
-17
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@ Vue.use(Modal. {
6464
### Props
6565
vue-modal-2 accept some props
6666

67+
#### `headerOptions`
68+
options props for vue-modal-2 header
69+
- type: `Object`
70+
- default: `{}`
71+
72+
__headerOptions key:__
73+
74+
|key|type|default|desc|
75+
|---|---|---|---|
76+
|`headerOptions.title`|`String`|Modal title| Modal title on the left side|
77+
|`headerOptions.closeIcon`|`String`|`✕`|Close button icon on the right side|
78+
79+
#### `footerOptions`
80+
options props for vue-modal-2 footer
81+
- type: `Object`
82+
- default: `{}`
83+
6784
#### `noFooter`
6885
used to remove footer
6986
- type: `Boolean`

src/App.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
<img alt="Vue logo" src="./assets/logo.png" width="25%" />
44
<p v-for="i in 10" :key="i">scroll down</p>
55

6-
<ContainerModal
6+
<modal-vue
77
name="modal1"
8+
:headerOptions="{
9+
title: 'Delete?'
10+
}"
811
:footerOptions="{
912
btn1OnClick: () => hell(),
1013
justify: 'flex-start',
@@ -19,19 +22,19 @@
1922
<!-- <div>Footer Name</div> -->
2023
</template>
2124
<div>content</div>
22-
</ContainerModal>
25+
</modal-vue>
2326
<button @click="open" class="button">Click Here</button>
2427

2528
<p v-for="i in 10" :key="i">scroll up</p>
2629
</div>
2730
</template>
2831

2932
<script>
30-
import ContainerModal from "./components/Container";
33+
// import ContainerModal from "./components/Container";
3134
export default {
3235
name: "App",
3336
components: {
34-
ContainerModal,
37+
// ContainerModal,
3538
},
3639
data() {
3740
return {

src/components/Container.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
id="vm2_box"
1313
:style="{ backgroundColor: modalBgColor, color: fontColor }"
1414
>
15-
<withHeader v-if="!noHeader" @on-icon-click="handleClose">
15+
<withHeader v-if="!noHeader" @on-icon-click="handleClose" :props="{...headerOptions}">
1616
<slot name="header" />
1717
</withHeader>
1818
<div v-if="hasDefaultSlot" style="margin: 15px">This is content</div>
@@ -38,6 +38,10 @@ export default {
3838
type: Object,
3939
default: () => {},
4040
},
41+
headerOptions: {
42+
type: Object,
43+
default: () => {},
44+
},
4145
// visible: {
4246
// type: Boolean,
4347
// default: false,

src/components/withHeader.vue

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,7 @@
1313

1414
<script>
1515
export default {
16-
props: {
17-
title: {
18-
type: String,
19-
default: "Modal title",
20-
},
21-
closeIcon: {
22-
type: String,
23-
default: "&#x2715;",
24-
},
25-
},
16+
props: ['props'],
2617
methods: {
2718
handleIconClick() {
2819
this.$emit("on-icon-click");
@@ -32,6 +23,18 @@ export default {
3223
hasDefaultSlot() {
3324
return !this.$slots.default;
3425
},
26+
title () {
27+
if (this.props && this.props.title) {
28+
return this.props.title;
29+
}
30+
return "Modal title";
31+
},
32+
closeIcon () {
33+
if (this.props && this.props.closeIcon) {
34+
return this.props.closeIcon;
35+
}
36+
return "&#x2715;";
37+
}
3538
},
3639
};
3740
</script>

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const plugin = {
1010
return;
1111
}
1212

13-
const options = Object.assign(opts, optsDefault);
13+
const options = Object.assign(optsDefault, opts);
1414

1515
const root = new Vue();
1616

src/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import App from "./App.vue";
33
import VM2 from "./index.js";
44

55
Vue.config.productionTip = false;
6-
Vue.use(VM2);
6+
Vue.use(VM2, {
7+
componentName: 'ModalVue'
8+
});
79
new Vue({
810
render: (h) => h(App)
911
}).$mount("#app");

0 commit comments

Comments
 (0)