1 | <template>
|
2 | <transition name="mint-toast-pop">
|
3 | <div class="mint-toast" v-show="visible" :class="customClass" :style="{ 'padding': iconClass === '' ? '10px' : '20px' }">
|
4 | <i class="mint-toast-icon" :class="iconClass" v-if="iconClass !== ''"></i>
|
5 | <span class="mint-toast-text" :style="{ 'padding-top': iconClass === '' ? '0' : '10px' }">{{ message }}</span>
|
6 | </div>
|
7 | </transition>
|
8 | </template>
|
9 |
|
10 | <style>
|
11 | @component-namespace mint {
|
12 | @component toast {
|
13 | position: fixed;
|
14 | max-width: 80%;
|
15 | border-radius: 5px;
|
16 | background: rgba(0, 0, 0, 0.7);
|
17 | color: #fff;
|
18 | box-sizing: border-box;
|
19 | text-align: center;
|
20 | z-index: 1000;
|
21 | transition: opacity .3s linear;
|
22 |
|
23 | @descendent icon {
|
24 | display: block;
|
25 | text-align: center;
|
26 | font-size: 56px;
|
27 | }
|
28 |
|
29 | @descendent text {
|
30 | font-size: 14px;
|
31 | display: block;
|
32 | text-align: center;
|
33 | }
|
34 |
|
35 | @when placetop {
|
36 | top: 50px;
|
37 | left: 50%;
|
38 | transform: translate(-50%, 0);
|
39 | }
|
40 |
|
41 | @when placemiddle {
|
42 | left: 50%;
|
43 | top: 50%;
|
44 | transform: translate(-50%, -50%);
|
45 | }
|
46 |
|
47 | @when placebottom {
|
48 | bottom: 50px;
|
49 | left: 50%;
|
50 | transform: translate(-50%, 0);
|
51 | }
|
52 |
|
53 | @descendent pop-enter, pop-leave-active {
|
54 | opacity: 0;
|
55 | }
|
56 | }
|
57 | }
|
58 | </style>
|
59 |
|
60 | <script type="text/babel">
|
61 | export default {
|
62 | props: {
|
63 | message: String,
|
64 | className: {
|
65 | type: String,
|
66 | default: ''
|
67 | },
|
68 | position: {
|
69 | type: String,
|
70 | default: 'middle'
|
71 | },
|
72 | iconClass: {
|
73 | type: String,
|
74 | default: ''
|
75 | }
|
76 | },
|
77 |
|
78 | data() {
|
79 | return {
|
80 | visible: false
|
81 | };
|
82 | },
|
83 |
|
84 | computed: {
|
85 | customClass() {
|
86 | var classes = [];
|
87 | switch (this.position) {
|
88 | case 'top':
|
89 | classes.push('is-placetop');
|
90 | break;
|
91 | case 'bottom':
|
92 | classes.push('is-placebottom');
|
93 | break;
|
94 | default:
|
95 | classes.push('is-placemiddle');
|
96 | }
|
97 | classes.push(this.className);
|
98 |
|
99 | return classes.join(' ');
|
100 | }
|
101 | }
|
102 | };
|
103 | </script> |
\ | No newline at end of file |