Skip to content

Commit

Permalink
Allow Modal to specify inline actions
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Aug 18, 2022
1 parent 4e66611 commit 5759e57
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 140 deletions.
1 change: 1 addition & 0 deletions src/components/Actions/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ export default {
/**
* Display x items inline out of the dropdown menu
* Will be ignored if `forceMenu` is set
*/
inline: {
type: Number,
Expand Down
295 changes: 155 additions & 140 deletions src/components/Modal/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,158 +22,163 @@

<docs>

```vue
<template>
<div>
<ButtonVue @click="showModal">Show Modal</ButtonVue>
<modal
v-if="modal"
@close="closeModal"
size="small"
title="Title"
:outTransition="true"
:hasNext="true"
:hasPrevious="true">
<div class="modal__content">Hello world</div>
</modal>
</div>
</template>
<style scoped>
.modal__content {
margin: 50px;
text-align: center;
}
```vue
<template>
<div>
<ButtonVue @click="showModal">Show Modal</ButtonVue>
<modal
v-if="modal"
@close="closeModal"
size="small"
title="Title"
:outTransition="true"
:hasNext="true"
:hasPrevious="true">
<div class="modal__content">Hello world</div>
</modal>
</div>
</template>
<style scoped>
.modal__content {
margin: 50px;
text-align: center;
}
</style>
<script>
export default {
data() {
return {
modal: false
}
</style>
<script>
export default {
data() {
return {
modal: false
}
},
methods: {
showModal() {
this.modal = true
},
methods: {
showModal() {
this.modal = true
},
closeModal() {
this.modal = false
}
closeModal() {
this.modal = false
}
}
</script>
```

### Modal with more properties

```vue
<template>
<div>
<ButtonVue @click="showModal">Show Modal with fields</ButtonVue>
<modal
v-if="modal"
@close="closeModal"
size="large"
title="Title inside modal">
<div class="modal__content">
<h2>Please enter your name</h2>
<TextField label="First Name" :value.sync="firstName" />
<TextField label="Last Name" :value.sync="lastName" />
<ButtonVue
:disabled="!this.firstName || !this.lastName"
@click="closeModal"
type="primary">
Submit
</ButtonVue>
</div>
</modal>
</div>
</template>
<style scoped>
.modal__content {
margin: 50px;
text-align: center;
}
}
</script>
```

.input-field {
margin: 12px 0px;
}
### Modal with more properties

</style>
<script>
import ButtonVue from '../ButtonVue/index.js'
import TextField from '../TextField/index.js'
export default {
components: {
ButtonVue,
TextField,
},
data() {
return {
modal: false,
firstName: '',
lastName: '',
}
```vue
<template>
<div>
<ButtonVue @click="showModal">Show Modal with fields</ButtonVue>
<modal
v-if="modal"
@close="closeModal"
title="Title inside modal">
<div class="modal__content">
<h2>Please enter your name</h2>
<TextField label="First Name" :value.sync="firstName" />
<TextField label="Last Name" :value.sync="lastName" />
<ButtonVue
:disabled="!this.firstName || !this.lastName"
@click="closeModal"
type="primary">
Submit
</ButtonVue>
</div>
</modal>
</div>
</template>
<script>
import ButtonVue from '../ButtonVue/index.js'
import TextField from '../TextField/index.js'
export default {
components: {
ButtonVue,
TextField,
Plus,
Delete,
OpenInNew,
Pencil,
},
data() {
return {
modal: false,
firstName: '',
lastName: '',
}
},
methods: {
showModal() {
this.firstName = ''
this.lastName = ''
this.modal = true
},
methods: {
showModal() {
this.firstName = ''
this.lastName = ''
this.modal = true
},
closeModal() {
this.modal = false
}
closeModal() {
this.modal = false
}
}
</script>
```

### Usage of popover in modal

* Set container property to .modal-mask to inject popover context of the modal:

```vue
<template>
<div>
<ButtonVue @click="showModal">Show Modal</ButtonVue>
<modal v-if="modal" @close="closeModal" size="small">
<EmojiPicker container=".modal-mask" @select="select">
<ButtonVue>Select emoji {{ emoji }}</ButtonVue>
</EmojiPicker>
</modal>
</div>
</template>
<style scoped>
.modal__content {
margin: 50px;
text-align: center;
}
</script>
<style scoped>
.modal__content {
margin: 50px;
text-align: center;
}
.input-field {
margin: 12px 0px;
}
</style>

```

### Usage of popover in modal

* Set container property to .modal-mask to inject popover context of the modal:

```vue
<template>
<div>
<ButtonVue @click="showModal">Show Modal</ButtonVue>
<modal v-if="modal" @close="closeModal" size="small">
<EmojiPicker container=".modal-mask" @select="select">
<ButtonVue>Select emoji {{ emoji }}</ButtonVue>
</EmojiPicker>
</modal>
</div>
</template>
<style scoped>
.modal__content {
margin: 50px;
text-align: center;
}
</style>
<script>
export default {
data() {
return {
emoji: '😛',
modal: false
}
</style>
<script>
export default {
data() {
return {
emoji: '😛',
modal: false
}
},
methods: {
showModal() {
this.modal = true
},
methods: {
showModal() {
this.modal = true
},
closeModal() {
this.modal = false
},
select(emoji) {
this.emoji = emoji
},
closeModal() {
this.modal = false
},
}
</script>
```

select(emoji) {
this.emoji = emoji
},
},
}
</script>
```
</docs>

<template>
<transition name="fade">
<div ref="mask"
Expand Down Expand Up @@ -226,7 +231,7 @@
</button>

<!-- Actions menu -->
<Actions class="header-actions">
<Actions class="header-actions" :inline="inlineActions">
<!-- @slot List of actions to show -->
<slot name="actions" />
</Actions>
Expand Down Expand Up @@ -453,6 +458,16 @@ export default {
type: Array,
default: () => [],
},
/**
* Display x items inline
*
* @see Actions component usage
*/
inlineActions: {
type: Number,
default: 0,
},
},
emits: [
Expand Down

0 comments on commit 5759e57

Please sign in to comment.