File tree Expand file tree Collapse file tree 3 files changed +90
-5
lines changed
cypress/test-server/src/components Expand file tree Collapse file tree 3 files changed +90
-5
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <v-card rounded =" lg" >
3
+ <v-card-title color =" primary" class =" d-flex justify-space-between align-center" >
4
+ <div class =" text-h5 text-medium-emphasis" >
5
+ Custom Dialog
6
+ </div >
7
+ <v-btn
8
+ icon =" mdi-close"
9
+ variant =" text"
10
+ @click =" close"
11
+ ></v-btn >
12
+ </v-card-title >
13
+
14
+ <v-divider ></v-divider >
15
+
16
+ <v-card-text class =" text-center" >
17
+ {{ message }}
18
+ <br />
19
+ <v-btn
20
+ color =" purple"
21
+ text =" Nested Notification"
22
+ @click =" showNotification"
23
+ ></v-btn >
24
+ </v-card-text >
25
+
26
+ <v-divider ></v-divider >
27
+
28
+ <v-card-actions class =" d-flex justify-end" >
29
+ <v-btn
30
+ class =" text-none"
31
+ color =" success"
32
+ rounded =" xl"
33
+ text =" Confirm"
34
+ variant =" flat"
35
+ @click =" close"
36
+ ></v-btn >
37
+ </v-card-actions >
38
+ </v-card >
39
+ </template >
40
+
41
+ <script setup>
42
+ import { createNotification } from ' vuetify3-dialog'
43
+
44
+ const props = defineProps ({
45
+ message: {
46
+ type: String ,
47
+ required: false
48
+ }
49
+ })
50
+
51
+ const emit = defineEmits ([' closeDialog' ])
52
+ function close () {
53
+ emit (' closeDialog' , false )
54
+ }
55
+
56
+ function showNotification () {
57
+ createNotification ({
58
+ text: " Notification from dialog!" ,
59
+ notifyOptions: {
60
+ timeout: 3000 ,
61
+ location: ' bottom right'
62
+ }
63
+ })
64
+ }
65
+ </script >
Original file line number Diff line number Diff line change 18
18
<v-btn id =" create-custom-component-dialog" @click =" createCustomComponentDialog()" color =" warning" >Custom component Dialog</v-btn >
19
19
<v-btn id =" success-dialog" @click =" successDialog()" color =" success" >Success Dialog</v-btn >
20
20
<v-btn id =" confirm-dialog" @click =" confirmDialog()" color =" primary" >Confirm Dialog</v-btn >
21
+ <br />
22
+ <v-btn id =" custom-component-dialog-notif" @click =" customComponentDialogNotif()" color =" brown" >Dialog w/Notification</v-btn >
21
23
</div >
22
24
</div >
23
25
58
60
<script lang="ts">
59
61
import { defineComponent } from " vue" ;
60
62
import MyComponent from " ./MyComponent.vue" ;
63
+ import DialogNotifComponent from " ./DialogNotifComponent.vue" ;
61
64
import sfcExampleVue from " ./sfc-example.vue" ;
62
65
63
66
@@ -94,6 +97,17 @@ export default defineComponent({
94
97
}
95
98
})
96
99
},
100
+ customComponentDialogNotif(){
101
+ this .$dialog .create ({
102
+ customComponent: {
103
+ component: DialogNotifComponent ,
104
+ props: { message: " Notification within Dialog!" }
105
+ },
106
+ dialogOptions: {
107
+ width: " 600px"
108
+ }
109
+ })
110
+ },
97
111
successDialog(){
98
112
this .$dialog .success ({title: " My success dialog" , text: " Hello world!" })
99
113
},
Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ export function createNotification(options: CreateNotifyOptions) {
39
39
options . notifyOptions ?. location ||
40
40
PluginContext . getPluginOptions ( ) ?. defaults ?. notify ?. location ||
41
41
'top right' ;
42
- let location = potentialLocation . split ( ' ' ) [ 0 ] || 'top' ;
42
+ let locationY = potentialLocation . split ( ' ' ) [ 0 ] || 'top' ;
43
+ let locationX = potentialLocation . split ( ' ' ) [ 1 ] || 'right' ;
43
44
let div = document . createElement ( 'div' ) ;
44
45
45
46
if ( ! isNotEmptyAndNotNull ( options . text ) ) throw new Error ( 'text is required' ) ;
@@ -65,17 +66,22 @@ export function createNotification(options: CreateNotifyOptions) {
65
66
66
67
if ( ( vuetifyDivOverlay as HTMLElement ) ?. childElementCount > 1 ) {
67
68
for ( let child of ( vuetifyDivOverlay as HTMLElement ) . children ) {
68
- if ( child === ( vuetifyDivOverlay as HTMLElement ) . lastElementChild ) continue ;
69
- // console.log('child', child);
69
+ if (
70
+ child === ( vuetifyDivOverlay as HTMLElement ) . lastElementChild ||
71
+ ! (
72
+ child . classList . contains ( 'v-snackbar--' + locationX ) &&
73
+ child . classList . contains ( 'v-snackbar--' + locationY )
74
+ )
75
+ )
76
+ continue ;
70
77
if ( ( child as HTMLElement ) . lastElementChild ) {
71
- // console.log('child of child', (child as HTMLElement).lastElementChild);
72
78
margin += ( ( child as HTMLElement ) . lastElementChild as HTMLElement ) . offsetHeight + 12 ;
73
79
}
74
80
}
75
81
}
76
82
77
83
if ( margin > 0 ) {
78
- switch ( location ) {
84
+ switch ( locationY ) {
79
85
case 'top' :
80
86
( vuetifyDivOverlay ?. lastElementChild as HTMLElement ) . style . marginTop = `${ margin + 12 } px` ;
81
87
break ;
You can’t perform that action at this time.
0 commit comments