|
12 | 12 | enter-active-class="animated quick zoomIn" |
13 | 13 | leave-active-class="animated quick zoomOut" |
14 | 14 | > |
15 | | - <li v-if="toggle" :style="{ 'background-color': bgColor }" |
16 | | - @click="toParent(action.name)" class="pointer"> |
17 | | - <i class="material-icons">{{action.icon}}</i> |
18 | | - </li> |
| 15 | + <template v-if="action.tooltip"> |
| 16 | + <li v-if="toggle" :style="{ 'background-color': bgColor }" |
| 17 | + v-v-tooltip="{ content: action.tooltip, placement: tooltipPosition }" |
| 18 | + @click="toParent(action.name)" class="pointer"> |
| 19 | + <i class="material-icons">{{action.icon}}</i> |
| 20 | + </li> |
| 21 | + </template> |
| 22 | + <template v-else> |
| 23 | + <li v-if="toggle" :style="{ 'background-color': bgColor }" |
| 24 | + @click="toParent(action.name)" class="pointer"> |
| 25 | + <i class="material-icons">{{action.icon}}</i> |
| 26 | + </li> |
| 27 | + </template> |
19 | 28 | </transition> |
20 | 29 | </template> |
21 | 30 | </ul> |
22 | 31 | </transition> |
23 | 32 | </div> |
24 | 33 | <template v-if="rippleShow"> |
25 | | - <div v-ripple="rippleColor == 'light' ? 'rgba(255, 255, 255, 0.35)' : ''" @click="toggle = !toggle" |
26 | | - class="fab pointer" :style="{ 'background-color': bgColor }" |
27 | | - > |
28 | | - <i class="material-icons md-36 main" :class="{ rotate: toggle }">{{mainIcon}}</i> |
29 | | - <i class="material-icons md-36 close" :class="{ rotate: toggle }">add</i> |
30 | | - </div> |
| 34 | + <template v-if="mainTooltip"> |
| 35 | + <div v-ripple="rippleColor == 'light' ? 'rgba(255, 255, 255, 0.35)' : ''" @click="toggle = !toggle" |
| 36 | + v-v-tooltip="{ content: mainTooltip, placement: tooltipPosition }" |
| 37 | + class="fab pointer" :style="{ 'background-color': bgColor }" |
| 38 | + > |
| 39 | + <i class="material-icons md-36 main" :class="{ rotate: toggle }">{{mainIcon}}</i> |
| 40 | + <i class="material-icons md-36 close" :class="{ rotate: toggle }">add</i> |
| 41 | + </div> |
| 42 | + </template> |
| 43 | + <template v-else> |
| 44 | + <div v-ripple="rippleColor == 'light' ? 'rgba(255, 255, 255, 0.35)' : ''" @click="toggle = !toggle" |
| 45 | + class="fab pointer" :style="{ 'background-color': bgColor }" |
| 46 | + > |
| 47 | + <i class="material-icons md-36 main" :class="{ rotate: toggle }">{{mainIcon}}</i> |
| 48 | + <i class="material-icons md-36 close" :class="{ rotate: toggle }">add</i> |
| 49 | + </div> |
| 50 | + </template> |
31 | 51 | </template> |
32 | 52 | <template v-else> |
33 | | - <div @click="toggle = !toggle" |
34 | | - class="fab pointer" :style="{ 'background-color': bgColor, 'z-index': zIndex }" |
35 | | - > |
36 | | - <i class="material-icons md-36 main" :class="{ rotate: toggle }">{{mainIcon}}</i> |
37 | | - <i class="material-icons md-36 close" :class="{ rotate: toggle }">add</i> |
38 | | - </div> |
| 53 | + <template v-if="mainTooltip"> |
| 54 | + <div v-v-tooltip="{ content: mainTooltip, placement: tooltipPosition }" |
| 55 | + class="fab pointer" :style="{ 'background-color': bgColor }" |
| 56 | + > |
| 57 | + <i class="material-icons md-36 main" :class="{ rotate: toggle }">{{mainIcon}}</i> |
| 58 | + <i class="material-icons md-36 close" :class="{ rotate: toggle }">add</i> |
| 59 | + </div> |
| 60 | + </template> |
| 61 | + <template v-else> |
| 62 | + <div class="fab pointer" :style="{ 'background-color': bgColor }" |
| 63 | + > |
| 64 | + <i class="material-icons md-36 main" :class="{ rotate: toggle }">{{mainIcon}}</i> |
| 65 | + <i class="material-icons md-36 close" :class="{ rotate: toggle }">add</i> |
| 66 | + </div> |
| 67 | + </template> |
39 | 68 | </template> |
40 | 69 | </div> |
41 | 70 | </template> |
42 | 71 |
|
43 | 72 | <script> |
44 | 73 | import {mixin as clickaway} from 'vue-clickaway'; |
45 | 74 | import Ripple from 'vue-ripple-directive'; |
| 75 | + import { VTooltip } from 'v-tooltip' |
46 | 76 |
|
47 | 77 | export default { |
48 | 78 | mixins: [clickaway], |
49 | | - directives: {Ripple}, |
| 79 | + directives: {Ripple, VTooltip}, |
50 | 80 | data() { |
51 | 81 | return { |
52 | 82 | toggle: false, |
53 | | - pos: {} |
| 83 | + pos: {}, |
| 84 | + tooltipPosition: 'left' |
54 | 85 | } |
55 | 86 | }, |
56 | 87 | props: { |
|
72 | 103 | mainIcon: { |
73 | 104 | default: 'add' |
74 | 105 | }, |
| 106 | + mainTooltip: { |
| 107 | + default: null |
| 108 | + }, |
75 | 109 | actions: {} |
76 | 110 | }, |
77 | 111 | computed: { |
78 | 112 | listPos() { |
79 | | -
|
80 | 113 | if (this.position === 'top-right' || this.position === 'top-left') { |
81 | 114 | return { |
82 | 115 | top: '-20px', |
|
116 | 149 | } |
117 | 150 | }, |
118 | 151 | methods: { |
| 152 | + tooltipPos() { |
| 153 | + if(this.position === 'top-right' || this.position === 'bototm-right') { |
| 154 | + this.mainTooltip.placement = 'left' |
| 155 | + } else { |
| 156 | + this.mainTooltip.placement = 'right' |
| 157 | + } |
| 158 | + }, |
119 | 159 | toParent(name) { |
120 | 160 | this.$emit(name); |
121 | 161 | this.toggle = false; |
|
164 | 204 |
|
165 | 205 | this.$nextTick(() => { |
166 | 206 | this.moveTransition(); |
| 207 | + this.tooltipPos(); |
167 | 208 | }); |
168 | 209 | } |
169 | 210 | }, |
|
176 | 217 | } |
177 | 218 | </script> |
178 | 219 |
|
| 220 | +<style> |
| 221 | + .tooltip { |
| 222 | + display: block !important; |
| 223 | + padding: .5rem 1rem; |
| 224 | + z-index: 10000; |
| 225 | + } |
| 226 | +
|
| 227 | + .tooltip .tooltip-inner { |
| 228 | + background: #333333; |
| 229 | + font-size: .85rem; |
| 230 | + color: white; |
| 231 | + padding: .2rem 1rem; |
| 232 | + } |
| 233 | +
|
| 234 | + .tooltip .tooltip-arrow{ |
| 235 | + display: none; |
| 236 | + } |
| 237 | +
|
| 238 | + .tooltip[aria-hidden='true'] { |
| 239 | + visibility: hidden; |
| 240 | + opacity: 0; |
| 241 | + transition: opacity .15s, visibility .15s; |
| 242 | + } |
| 243 | +
|
| 244 | + .tooltip[aria-hidden='false'] { |
| 245 | + visibility: visible; |
| 246 | + opacity: 1; |
| 247 | + transition: opacity .15s; |
| 248 | + } |
| 249 | +</style> |
| 250 | + |
179 | 251 | <style scoped> |
180 | 252 | .animated.quick { |
181 | 253 | -webkit-animation-duration: .7s !important; |
|
195 | 267 | height: 65px; |
196 | 268 | display: flex; |
197 | 269 | align-items: center; |
198 | | - box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23); |
| 270 | + box-shadow: 0 10px 10px rgba(0, 0, 0, 0.20), 0 4px 4px rgba(0, 0, 0, 0.15); |
199 | 271 | z-index: 2; |
200 | 272 | } |
201 | 273 |
|
|
250 | 322 | display: flex; |
251 | 323 | align-items: center; |
252 | 324 | border-radius: 100px; |
253 | | - box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23); |
| 325 | + box-shadow: 0 10px 10px rgba(0, 0, 0, 0.20), 0 4px 4px rgba(0, 0, 0, 0.15); |
254 | 326 | } |
255 | 327 |
|
256 | 328 | .fab-list li .material-icons { |
|
0 commit comments