Skip to content

Commit 32db345

Browse files
committed
Update modal code
1 parent 2c73991 commit 32db345

File tree

8 files changed

+38
-21
lines changed

8 files changed

+38
-21
lines changed

resources/assets/scripts/components/core/Modal.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
<template>
22
<transition name="modal">
3-
<div class="modal-mask" v-show="show" v-on:click="close">
4-
<div class="modal-container" @click.stop>
5-
<div v-on:click="close" v-if="dismissable && showCloseIcon">
6-
<Icon name="x"
7-
class="absolute pin-r pin-t m-2 text-neutral-500 cursor-pointer"
8-
aria-label="Close modal"
9-
role="button"
10-
/>
3+
<div class="modal-mask" v-show="isVisible" v-on:click="closeOnBackground && close()">
4+
<div class="modal-container p-8" :class="{ 'full-screen': isFullScreen }" @click.stop>
5+
<div class="modal-close-icon" v-on:click="close" v-if="dismissable && showCloseIcon">
6+
<Icon name="x" aria-label="Close modal" role="button"/>
117
</div>
128
<slot/>
139
</div>
@@ -24,17 +20,19 @@
2420
components: {Icon},
2521
2622
props: {
27-
showCloseIcon: {type: Boolean, default: true},
2823
modalName: {type: String, default: 'modal'},
29-
show: {type: Boolean, default: false},
24+
isVisible: {type: Boolean, default: false},
3025
closeOnEsc: {type: Boolean, default: true},
3126
dismissable: {type: Boolean, default: true},
27+
showCloseIcon: {type: Boolean, default: true},
28+
isFullScreen: {type: Boolean, default: false},
29+
closeOnBackground: {type: Boolean, default: true},
3230
},
3331
3432
mounted: function () {
35-
if (this.$props.dismissable && this.$props.closeOnEsc) {
33+
if (this.$props.closeOnEsc) {
3634
document.addEventListener('keydown', e => {
37-
if (this.show && e.key === 'Escape') {
35+
if (this.isVisible && e.key === 'Escape') {
3836
this.close();
3937
}
4038
})
@@ -43,9 +41,11 @@
4341
4442
methods: {
4543
close: function () {
46-
if (this.$props.dismissable) {
47-
this.$emit('close', this.$props.modalName);
44+
if (!this.$props.dismissable) {
45+
return;
4846
}
47+
48+
this.$emit('close', this.$props.modalName);
4949
}
5050
},
5151
});

resources/assets/scripts/components/dashboard/Account.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div>
33
<Navigation/>
44
<div class="container animate fadein mt-2 sm:mt-6">
5-
<Modal :show="modalVisible" v-on:close="modalVisible = false">
5+
<Modal :isVisible="modalVisible" v-on:close="modalVisible = false">
66
<TwoFactorAuthentication v-on:close="modalVisible = false"/>
77
</Modal>
88
<Flash container="mt-2 sm:mt-6 mb-2"/>

resources/assets/scripts/components/server/components/filemanager/modals/CreateFolderModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Modal :show="visible" v-on:close="onModalClose" :showCloseIcon="false" :dismissable="!isLoading">
2+
<Modal :isVisible="visible" v-on:close="onModalClose" :showCloseIcon="false" :dismissable="!isLoading">
33
<div>
44
<label class="input-label">
55
Directory Name

resources/assets/scripts/components/server/components/filemanager/modals/DeleteFileModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Modal :show="isVisible" v-on:close="isVisible = false" :dismissable="!isLoading">
2+
<Modal :isVisible="isVisible" v-on:close="isVisible = false" :dismissable="!isLoading">
33
<MessageBox
44
class="alert error mb-8"
55
title="Error"

resources/assets/scripts/components/server/components/filemanager/modals/MoveFileModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Modal :show="visible" v-on:close="isVisible = false" :dismissable="!isLoading">
2+
<Modal :isVisible="visible" v-on:close="isVisible = false" :dismissable="!isLoading">
33
<MessageBox class="alert error mb-8" title="Error" :message="error" v-if="error"/>
44
<div class="flex items-end">
55
<div class="flex-1">

resources/assets/scripts/components/server/components/filemanager/modals/RenameModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Modal :show="isVisible" v-on:close="closeModal" :showCloseIcon="false" :dismissable="!isLoading">
2+
<Modal :isVisible="isVisible" v-on:close="closeModal" :showCloseIcon="false" :dismissable="!isLoading">
33
<MessageBox
44
class="alert error mb-8"
55
title="Error"

resources/assets/scripts/components/server/subpages/Databases.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<div>
1919
<button class="btn btn-primary btn-lg" v-on:click="showCreateModal = true">Create new database</button>
2020
</div>
21-
<Modal :show="showCreateModal" v-on:close="showCreateModal = false">
21+
<Modal :isVisible="showCreateModal" v-on:close="showCreateModal = false">
2222
<CreateDatabaseModal
2323
v-on:close="showCreateModal = false"
2424
v-on:database="handleModalCallback"

resources/assets/styles/components/modal.css

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@
44
transition: opacity 250ms ease;
55

66
& > .modal-container {
7-
@apply .relative .p-8 .bg-white .w-full .max-w-md .m-auto .flex-col .flex .rounded;
7+
@apply .relative .bg-white .w-full .max-w-md .m-auto .flex-col .flex .rounded .shadow-md;
88
transition: all 250ms ease;
99
margin-top: 15%;
1010

11+
& > .modal-close-icon {
12+
@apply .absolute .pin-r .p-2 .text-white .cursor-pointer .opacity-50;
13+
transition: opacity 150ms linear, transform 150ms ease-in;
14+
top: -2.5rem;
15+
16+
&:hover {
17+
@apply .opacity-100;
18+
transform: rotate(90deg);
19+
}
20+
}
21+
1122
/**
1223
* On tiny phone screens make sure there is a margin on the sides and also
1324
* center the modal rather than putting it towards the top of the screen.
@@ -18,6 +29,12 @@
1829
}
1930
}
2031

32+
& > .modal-container.full-screen {
33+
@apply .w-3/4 .mt-32;
34+
height: calc(100vh - 16rem);
35+
max-width: none;
36+
}
37+
2138
& > .modal-container.w-auto {
2239
@apply .w-auto;
2340
}

0 commit comments

Comments
 (0)