debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/gl_modal.vue

113 lines
2.5 KiB
Vue
Raw Normal View History

2018-03-27 19:54:05 +05:30
<script>
2018-05-09 12:01:36 +05:30
const buttonVariants = ['danger', 'primary', 'success', 'warning'];
2018-11-08 19:23:39 +05:30
const sizeVariants = ['sm', 'md', 'lg', 'xl'];
2018-03-27 19:54:05 +05:30
2018-05-09 12:01:36 +05:30
export default {
name: 'GlModal',
props: {
id: {
type: String,
required: false,
default: null,
2018-03-27 19:54:05 +05:30
},
2018-11-08 19:23:39 +05:30
modalSize: {
type: String,
required: false,
default: 'md',
validator: value => sizeVariants.includes(value),
},
2018-05-09 12:01:36 +05:30
headerTitleText: {
type: String,
required: false,
default: '',
},
footerPrimaryButtonVariant: {
type: String,
required: false,
default: 'primary',
validator: value => buttonVariants.includes(value),
},
footerPrimaryButtonText: {
type: String,
required: false,
default: '',
},
},
2018-11-08 19:23:39 +05:30
computed: {
modalSizeClass() {
return this.modalSize === 'md' ? '' : `modal-${this.modalSize}`;
},
},
2018-05-09 12:01:36 +05:30
methods: {
emitCancel(event) {
this.$emit('cancel', event);
},
emitSubmit(event) {
this.$emit('submit', event);
2018-03-27 19:54:05 +05:30
},
2018-05-09 12:01:36 +05:30
},
};
2018-03-27 19:54:05 +05:30
</script>
<template>
<div
:id="id"
class="modal fade"
tabindex="-1"
role="dialog"
>
<div
2018-11-08 19:23:39 +05:30
:class="modalSizeClass"
2018-03-27 19:54:05 +05:30
class="modal-dialog"
role="document"
>
<div class="modal-content">
<div class="modal-header">
<slot name="header">
2018-11-08 19:23:39 +05:30
<h4 class="modal-title">
<slot name="title">
{{ headerTitleText }}
</slot>
</h4>
2018-03-27 19:54:05 +05:30
<button
2018-11-08 19:23:39 +05:30
:aria-label="s__('Modal|Close')"
2018-03-27 19:54:05 +05:30
type="button"
2018-05-09 12:01:36 +05:30
class="close js-modal-close-action"
2018-03-27 19:54:05 +05:30
data-dismiss="modal"
@click="emitCancel($event)"
>
<span aria-hidden="true">&times;</span>
</button>
</slot>
</div>
<div class="modal-body">
<slot></slot>
</div>
<div class="modal-footer">
<slot name="footer">
<button
type="button"
2018-05-09 12:01:36 +05:30
class="btn js-modal-cancel-action"
2018-03-27 19:54:05 +05:30
data-dismiss="modal"
@click="emitCancel($event)"
>
{{ s__('Modal|Cancel') }}
</button>
<button
2018-11-08 19:23:39 +05:30
:class="`btn-${footerPrimaryButtonVariant}`"
2018-03-27 19:54:05 +05:30
type="button"
2018-05-09 12:01:36 +05:30
class="btn js-modal-primary-action"
2018-03-27 19:54:05 +05:30
data-dismiss="modal"
@click="emitSubmit($event)"
>
{{ footerPrimaryButtonText }}
</button>
</slot>
</div>
</div>
</div>
</div>
</template>