11<template >
2- <transition name =" fade" >
3- <div class =" modal-wrapper" v-if =" isShow" >
4- <div class =" modal-mask" ></div >
5- <div class =" modal-main" :style =" styles" v-click-outside =" hide" >
6- <slot ></slot >
2+ <div >
3+ <transition name =" fade-overlay" >
4+ <div class =" lai-modal-overlay" v-if =" overlay && isShow" ></div >
5+ </transition >
6+ <transition name =" fade-modal" >
7+ <div class =" lai-modal" v-if =" isShow" v-click-outside =" hide" style =" min-width : 560px ; min-height : 280px ;" >
8+ <button class =" modal-close close-button" @click =" hide" >x</button >
9+ <div class =" modal-content" >
10+ <slot ></slot >
11+ </div >
712 </div >
8- </div >
9- </transition >
13+ </transition >
14+ </div >
1015</template >
1116<script >
1217import clickOutside from ' ../../directives/click-outside'
1318export default {
1419 props: {
20+ overlay: {
21+ type: Boolean ,
22+ default: true
23+ },
1524 value: {
1625 type: Boolean ,
1726 default: false
@@ -23,7 +32,7 @@ export default {
2332 },
2433 data () {
2534 return {
26- isShow: this .value
35+ isShow: this .value ,
2736 }
2837 },
2938 directives: {
@@ -46,6 +55,7 @@ export default {
4655 </script >
4756
4857<style lang="less" scoped>
58+
4959.modal-wrapper {
5060 position : absolute ;
5161 top : 0 ;
@@ -79,5 +89,77 @@ export default {
7989 box-shadow : 0px 0px 6px rgba (0 , 0 , 0 , .1 );
8090 }
8191}
92+
93+ .modal-close {
94+ font-family : Helvetica , Arial , sans-serif ;
95+ font-size : 24px ;
96+ font-weight : 700 ;
97+ line-height : 12px ;
98+ position : absolute ;
99+ top : 5px ;
100+ right : 5px ;
101+ padding : 5px 7px 7px ;
102+ cursor : pointer ;
103+ color : #fff ;
104+ border : 0 ;
105+ outline : none ;
106+ background : #e74c3c ;
107+ & :hover {
108+ background : #c0392b ;
109+ }
110+ }
111+
112+ .lai-modal-overlay {
113+ position : fixed ;
114+ will-change : transform;
115+ z-index : 9999 ;
116+ top : 0 ;
117+ right : 0 ;
118+ bottom : 0 ;
119+ left : 0 ;
120+ background-color : rgba (0 , 0 , 0 , 0.65 );
121+ }
122+
123+ .lai-modal {
124+ position : absolute ;
125+ z-index : 10000 ;
126+ top : 50% ;
127+ left : 50% ;
128+ transform : translate (-50% , -50% );
129+ max-width : 80vw ;
130+ padding : 30px 20px ;
131+ border-radius : 4px ;
132+ background-color : #fff ;
133+ & .modal-anchored {
134+ top : 2vh ;
135+ transform : translate (-50% , 0 );
136+ }
137+ }
138+
139+ .fade-overlay-enter , .fade-overlay-leave-to {
140+ display : block ;
141+ opacity : 0 ;
142+ }
143+ .fade-overlay-enter-active , .fade-overlay-leave-active {
144+ transition : 500ms opacity 500ms ease ;
145+ }
146+ .fade-overlay-enter-to , .fade-overlay-leave {
147+ display : block ;
148+ opacity : 1 ;
149+ }
150+
151+ .fade-modal-enter , .fade-modal-leave-to {
152+ top : -300vh ;
153+ }
154+ .fade-modal-enter-active {
155+ transition : 500ms top 500ms ease ;
156+ }
157+ .fade-modal-leave-active {
158+ transition : 500ms top ease ;
159+ }
160+ .fade-modal-enter-to , .fade-modal-leave {
161+ top : 50% ;
162+ opacity : 1 ;
163+ }
82164 </style >
83165
0 commit comments