action sheet component
This commit is contained in:
@@ -1,28 +1,54 @@
|
||||
<template>
|
||||
<transition name="actionsheet-float">
|
||||
<div class="zan-actionsheet" v-show="currentValue">
|
||||
<div class="zan-actionsheet-header" v-if="title">
|
||||
<div class="zan-actionsheet" :class="[ title ? 'zan-actionsheet--withtitle' : '' ]" v-show="currentValue">
|
||||
<div class="zan-actionsheet__header" v-if="title">
|
||||
<h3 v-text="title"></h3>
|
||||
<zan-icon name="close" @click.stop="currentValue = false"></zan-icon>
|
||||
</div>
|
||||
<slot>
|
||||
<ul class="zan-actionsheet-list">
|
||||
<li v-for="item in actions" class="zan-actionsheet-item" :class="item.className" @click.stop="handleItemClick(item)">{{ item.name }}</li>
|
||||
<template v-if="!title">
|
||||
<ul class="zan-actionsheet__list">
|
||||
<li
|
||||
v-for="item in actions"
|
||||
class="zan-actionsheet__item"
|
||||
:class="[item.className, item.loading ? 'zan-actionsheet__item--loading' : '']"
|
||||
@click.stop="handleItemClick(item)">
|
||||
<template v-if="!item.loading">
|
||||
<span class="zan-actionsheet__name">{{ item.name }}</span>
|
||||
<span class="zan-actionsheet__subname" v-if="item.subname">{{ item.subname }}</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<zan-loading class="zan-actionsheet__loading" type="circle" color="black"></zan-loading>
|
||||
</template>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="zan-actionsheet-button" @click.stop="currentValue = false" v-if="cancelText">{{ cancelText }}</a>
|
||||
</slot>
|
||||
<a class="zan-actionsheet__button" @click.stop="currentValue = false" v-if="cancelText">{{ cancelText }}</a>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="zan-actionsheet__content">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Popup from 'src/mixins/popup';
|
||||
import ZanLoading from 'packages/loading';
|
||||
import ZanIcon from 'packages/icon';
|
||||
|
||||
export default {
|
||||
name: 'zan-actionsheet',
|
||||
|
||||
mixins: [Popup],
|
||||
|
||||
components: {
|
||||
ZanLoading,
|
||||
ZanIcon
|
||||
},
|
||||
|
||||
props: {
|
||||
value: {},
|
||||
actions: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
@@ -40,7 +66,7 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
currentValue: false
|
||||
currentValue: this.value
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<i class="zanui-icon" :class="'zan-icon-' + name"></i>
|
||||
<i class="zan-icon" :class="'zan-icon-' + name" @click="handleIconClick"></i>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -8,6 +8,12 @@
|
||||
|
||||
props: {
|
||||
name: String
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleIconClick(event) {
|
||||
this.$emit('click', event);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -1,9 +1,81 @@
|
||||
@import './common/var.css';
|
||||
@import './mixins/border_retina.css';
|
||||
|
||||
@component-namespace zan {
|
||||
@b actionsheet {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
top: auto;
|
||||
bottom: 0;
|
||||
right: auto;
|
||||
left: 50%;
|
||||
transform: translate3d(-50%, 0, 0);
|
||||
backface-visibility: hidden;
|
||||
transition: .2s ease-out;
|
||||
background-color: #e0e0e0;
|
||||
|
||||
@m withtitle {
|
||||
background-color: $c-white;
|
||||
}
|
||||
|
||||
@e item {
|
||||
line-height: 50px;
|
||||
text-align: center;
|
||||
color: $c-black;
|
||||
font-size: 16px;
|
||||
position: relative;
|
||||
background-color: $c-white;
|
||||
|
||||
@m loading {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
&::after {
|
||||
@mixin border-retina (top);
|
||||
}
|
||||
}
|
||||
|
||||
@e subname {
|
||||
color: $c-gray-darker;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@e loading {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
@e button {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
line-height: 50px;
|
||||
color: $c-black;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
background-color: $c-white;
|
||||
}
|
||||
|
||||
@e header {
|
||||
line-height: 44px;
|
||||
color: $c-black;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
|
||||
&::after {
|
||||
@mixin border-retina (top, bottom);
|
||||
}
|
||||
|
||||
.zan-icon-close {
|
||||
position: absolute;
|
||||
font-size: 22px;
|
||||
line-height: 22px;
|
||||
top: 11px;
|
||||
right: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.actionsheet-float-bottom-enter,
|
||||
.actionsheet-float-bottom-leave-active {
|
||||
.actionsheet-float-enter,
|
||||
.actionsheet-float-leave-active {
|
||||
transform: translate3d(-50%, 100%, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user