1 | <template>
|
2 | <div class="md-action-bar">
|
3 | <div class="md-action-bar-container">
|
4 | <div class="md-action-bar-text" v-if="hasSlots">
|
5 | <slot></slot>
|
6 | </div>
|
7 | <div class="md-action-bar-group">
|
8 | <template v-for="(item, index) in coerceActions">
|
9 | <md-button
|
10 | class="md-action-bar-button"
|
11 | :type="item.type || (!!item.disabled ? 'disabled' : 'primary')"
|
12 | :plain="item.plain || (index !== coerceActions.length - 1)"
|
13 | :round="item.round"
|
14 | :inactive="item.inactive"
|
15 | :loading="item.loading"
|
16 | :icon="item.icon"
|
17 | :icon-svg="item.iconSvg"
|
18 | :key="index"
|
19 | @click="$_onBtnClick($event, item)"
|
20 | >
|
21 | {{ item.text }}
|
22 | </md-button>
|
23 | </template>
|
24 | </div>
|
25 | </div>
|
26 | </div>
|
27 | </template>
|
28 |
|
29 | <script>
import Button from '../button'
|
30 | import {isEmptyObject} from '../_util'
|
31 |
|
32 | export default {
|
33 | name: 'md-action-bar',
|
34 |
|
35 | components: {
|
36 | [Button.name]: Button,
|
37 | },
|
38 |
|
39 | props: {
|
40 | actions: {
|
41 | type: Array,
|
42 | default: [],
|
43 | },
|
44 | },
|
45 |
|
46 | computed: {
|
47 | coerceActions() {
|
48 | return this.actions.slice(0, 2)
|
49 | },
|
50 | hasSlots() {
|
51 | return !isEmptyObject(this.$slots)
|
52 | },
|
53 | },
|
54 |
|
55 | methods: {
|
56 |
|
57 | $_onBtnClick(event, action) {
|
58 | action.onClick && action.onClick(event, action)
|
59 | this.$emit('click', event, action)
|
60 | },
|
61 | },
|
62 | }
|
63 |
</script>
|
64 |
|
65 | <style lang="stylus">
|
66 | .md-action-bar
|
67 | position fixed
|
68 | z-index action-bar-zindex
|
69 | left 0
|
70 | bottom 0
|
71 | right 0
|
72 | display flex
|
73 | padding action-bar-padding-v action-bar-padding-h
|
74 | background color-bg-inverse
|
75 | clearfix()
|
76 |
|
77 | .md-action-bar-container
|
78 | display flex
|
79 | flex 1
|
80 | padding-bottom constant(safe-area-inset-bottom)
|
81 | padding-bottom env(safe-area-inset-bottom)
|
82 |
|
83 | .md-action-bar-text
|
84 | display flex
|
85 | flex 1
|
86 | height action-bar-slot-height
|
87 | margin-right action-bar-button-gap
|
88 | align-items center
|
89 | overflow hidden
|
90 |
|
91 | .md-action-bar-group
|
92 | display flex
|
93 | flex 1
|
94 | height 100%
|
95 |
|
96 | .md-action-bar-button
|
97 | display flex
|
98 | float right
|
99 | align-items center
|
100 | justify-content center
|
101 | flex 1
|
102 | &:nth-of-type(2)
|
103 | margin-left action-bar-button-gap
|
104 | </style>
|