api-client/components/smart/Modal.vue

131 lines
2.3 KiB
Vue
Raw Normal View History

2019-09-06 10:41:18 +00:00
<template>
<transition name="modal" appear>
<div class="modal-backdrop">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-header">
<slot name="header"></slot>
</div>
<div class="modal-body">
<slot name="body"></slot>
2020-03-05 03:03:06 +00:00
<!-- <div class="fade top"></div>
<div class="fade bottom"></div> -->
</div>
<div v-if="hasFooterSlot" class="modal-footer">
<slot name="footer"></slot>
2019-09-06 10:41:18 +00:00
</div>
</div>
</div>
</div>
</transition>
2019-09-06 10:41:18 +00:00
</template>
2019-12-06 01:41:38 +00:00
<style scoped lang="scss">
2019-11-02 05:32:21 +00:00
.modal-backdrop {
2020-09-22 17:06:37 +00:00
@apply fixed;
@apply inset-0;
@apply z-50;
@apply w-full;
@apply h-full;
@apply flex;
@apply items-center;
@apply justify-center;
@apply transition;
@apply ease-in-out;
@apply duration-150;
2020-10-16 01:40:07 +00:00
background-color: rgba(0, 0, 0, 0.32);
2019-11-02 05:32:21 +00:00
}
2019-09-06 10:41:18 +00:00
2019-11-02 05:32:21 +00:00
.modal-wrapper {
2020-09-22 17:06:37 +00:00
@apply flex;
@apply items-center;
@apply justify-center;
@apply flex-1;
2019-11-02 05:32:21 +00:00
}
2019-09-06 10:41:18 +00:00
2019-11-02 05:32:21 +00:00
.modal-container {
2020-09-22 17:06:37 +00:00
@apply relative;
@apply flex;
@apply flex-1;
@apply flex-col;
@apply m-2;
@apply transition;
@apply ease-in-out;
@apply duration-150;
2020-09-22 17:06:37 +00:00
@apply bg-bgColor;
@apply rounded-lg;
@apply shadow-2xl;
2020-10-16 01:40:07 +00:00
2020-03-03 01:32:27 +00:00
max-height: calc(100vh - 128px);
2020-12-11 16:54:34 +00:00
max-width: 640px;
}
.modal-header {
@apply pl-2;
}
.modal-body {
2020-09-22 17:06:37 +00:00
@apply overflow-auto;
2019-11-02 05:32:21 +00:00
}
2019-09-06 10:41:18 +00:00
2020-12-11 16:54:34 +00:00
.modal-footer {
@apply p-2;
}
2019-11-02 05:32:21 +00:00
/*
2019-10-25 08:14:34 +00:00
* The following styles are auto-applied to elements with
* transition="modal" when their visibility is toggled
* by Vue.js.
*
* You can easily play with the modal transition by editing
* these styles.
*/
2019-09-06 10:41:18 +00:00
.modal-enter,
.modal-leave-active {
2020-09-22 17:06:37 +00:00
@apply opacity-0;
2019-11-02 05:32:21 +00:00
}
2019-09-06 10:41:18 +00:00
.modal-enter .modal-container,
.modal-leave-active .modal-container {
2020-09-22 17:06:37 +00:00
@apply transform;
@apply scale-90;
2020-09-22 17:06:37 +00:00
@apply transition;
@apply ease-in-out;
@apply duration-150;
2019-11-02 05:32:21 +00:00
}
2020-03-05 01:18:10 +00:00
.fade {
2020-09-22 17:06:37 +00:00
@apply absolute;
@apply block;
@apply transition;
@apply ease-in-out;
@apply duration-150;
2020-03-05 01:18:10 +00:00
2020-10-16 01:40:07 +00:00
left: 16px;
right: 20px;
height: 32px;
2020-03-05 01:18:10 +00:00
&.top {
top: 68px;
background: linear-gradient(to bottom, var(--bg-color), transparent);
}
&.bottom {
bottom: 16px;
background: linear-gradient(to top, var(--bg-color), transparent);
}
}
2019-09-09 05:57:00 +00:00
</style>
<script>
export default {
computed: {
hasFooterSlot() {
return !!this.$slots.footer
},
},
}
</script>