forked from platypush/platypush
[UI] New features for the Modal
element.
- Added `uppercase` property (default: true) for the modal title. This makes it possible to override the default case of the modal title. - Added support for custom buttons in the modal titlebar.
This commit is contained in:
parent
342df0eeec
commit
336cb18cb3
1 changed files with 46 additions and 8 deletions
|
@ -2,13 +2,22 @@
|
||||||
<div class="modal-container fade-in" :id="id" :class="{hidden: !isVisible}"
|
<div class="modal-container fade-in" :id="id" :class="{hidden: !isVisible}"
|
||||||
:style="{'--z-index': zIndex}" @click="close">
|
:style="{'--z-index': zIndex}" @click="close">
|
||||||
<div class="modal" :class="$attrs.class">
|
<div class="modal" :class="$attrs.class">
|
||||||
<div class="content" :style="{'--width': width, '--height': height}" @click="$event.stopPropagation()">
|
<div class="content" :style="{'--width': width, '--height': height}" @click.stop>
|
||||||
<div class="header" v-if="title">
|
<div class="header" :class="{uppercase: uppercase}" v-if="title">
|
||||||
<div class="title" v-text="title" v-if="title" />
|
<div class="title" v-text="title" v-if="title" />
|
||||||
|
<div class="buttons">
|
||||||
|
<button v-for="(button, index) in buttons"
|
||||||
|
:key="index"
|
||||||
|
:title="button.title"
|
||||||
|
@click="button.action">
|
||||||
|
<i :class="button.icon" />
|
||||||
|
</button>
|
||||||
|
|
||||||
<button title="Close" alt="Close" @click="close">
|
<button title="Close" alt="Close" @click="close">
|
||||||
<i class="fas fa-xmark" />
|
<i class="fas fa-xmark" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<slot @modal-close="close" />
|
<slot @modal-close="close" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,6 +67,25 @@ export default {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 1,
|
default: 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Whether the header title should be uppercase
|
||||||
|
uppercase: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
// Extra buttons to be added to the modal header
|
||||||
|
buttons: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
|
||||||
|
// A function to be called before the modal is closed.
|
||||||
|
// If the function returns false, the modal will not be closed.
|
||||||
|
beforeClose: {
|
||||||
|
type: Function,
|
||||||
|
default: () => true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
@ -76,6 +104,9 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
close() {
|
close() {
|
||||||
|
if (this.beforeClose && !this.beforeClose())
|
||||||
|
return
|
||||||
|
|
||||||
this.prevVisible = this.isVisible
|
this.prevVisible = this.isVisible
|
||||||
this.isVisible = false
|
this.isVisible = false
|
||||||
},
|
},
|
||||||
|
@ -206,13 +237,20 @@ $icon-margin: 0.5em;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: $modal-header-bg;
|
background: $modal-header-bg;
|
||||||
|
|
||||||
|
&.uppercase {
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
width: auto;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
width: $icon-size;
|
width: $icon-size;
|
||||||
height: $icon-size;
|
height: $icon-size;
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
margin: auto $icon-margin;
|
margin: auto $icon-margin;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
|
|
Loading…
Reference in a new issue