mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[new feature] Button: 增加新属性 ariaLabel、增加外部样式类 hover-class、增加launchapp事件
This commit is contained in:
parent
705aa8c1df
commit
386322b44a
@ -2,35 +2,35 @@
|
||||
|
||||
.van-button {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
display: inline-block;
|
||||
height: 44px;
|
||||
padding: 0;
|
||||
font-size: 16px;
|
||||
line-height: 42px;
|
||||
text-align: center;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
vertical-align: middle;
|
||||
border-radius: 2px;
|
||||
box-sizing: border-box;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
-webkit-appearance: none;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
|
||||
&::after {
|
||||
content: " ";
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
opacity: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: @black;
|
||||
border: inherit;
|
||||
border-color: @black;
|
||||
background-color: @black;
|
||||
border-radius: inherit; /* inherit parent's border radius */
|
||||
content: ' ';
|
||||
opacity: 0;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
&:active::after {
|
||||
opacity: .15;
|
||||
&--active::after {
|
||||
opacity: 0.15;
|
||||
}
|
||||
|
||||
&--unclickable::after {
|
||||
@ -90,8 +90,8 @@
|
||||
|
||||
&--small {
|
||||
height: 30px;
|
||||
padding: 0 8px;
|
||||
min-width: 60px;
|
||||
padding: 0 8px;
|
||||
font-size: 12px;
|
||||
line-height: 28px;
|
||||
}
|
||||
@ -101,8 +101,8 @@
|
||||
display: inline-block;
|
||||
width: 50px;
|
||||
height: 22px;
|
||||
line-height: 20px;
|
||||
font-size: 10px;
|
||||
line-height: 20px;
|
||||
|
||||
& + .van-button--mini {
|
||||
margin-left: 5px;
|
||||
@ -110,8 +110,8 @@
|
||||
}
|
||||
|
||||
&--block {
|
||||
width: 100%;
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&--round {
|
||||
@ -123,6 +123,6 @@
|
||||
}
|
||||
|
||||
&--disabled {
|
||||
opacity: .5;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ import { button } from '../mixins/button';
|
||||
import { openType } from '../mixins/open-type';
|
||||
|
||||
VantComponent({
|
||||
classes: ['loading-class'],
|
||||
|
||||
mixins: [button, openType],
|
||||
|
||||
classes: ['hover-class', 'loading-class'],
|
||||
|
||||
props: {
|
||||
plain: Boolean,
|
||||
block: Boolean,
|
||||
|
@ -2,21 +2,26 @@
|
||||
|
||||
<button
|
||||
id="{{ id }}"
|
||||
lang="{{ lang }}"
|
||||
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, unclickable: disabled || loading }]) }}"
|
||||
|
||||
open-type="{{ openType }}"
|
||||
hover-class="van-button--active hover-class"
|
||||
lang="{{ lang }}"
|
||||
session-from="{{ sessionFrom }}"
|
||||
app-parameter="{{ appParameter }}"
|
||||
send-message-img="{{ sendMessageImg }}"
|
||||
send-message-path="{{ sendMessagePath }}"
|
||||
show-message-card="{{ showMessageCard }}"
|
||||
send-message-title="{{ sendMessageTitle }}"
|
||||
bind:tap="onClick"
|
||||
binderror="bindError"
|
||||
bindcontact="bindContact"
|
||||
bindopensetting="bindOpenSetting"
|
||||
send-message-path="{{ sendMessagePath }}"
|
||||
send-message-img="{{ sendMessageImg }}"
|
||||
show-message-card="{{ showMessageCard }}"
|
||||
app-parameter="{{ appParameter }}"
|
||||
aria-label="{{ ariaLabel }}"
|
||||
|
||||
bindtap="onClick"
|
||||
bindgetuserinfo="bindGetUserInfo"
|
||||
bindcontact="bindContact"
|
||||
bindgetphonenumber="bindGetPhoneNumber"
|
||||
binderror="bindError"
|
||||
bindlaunchapp="bindLaunchApp"
|
||||
bindopensetting="bindOpenSetting"
|
||||
>
|
||||
<van-loading
|
||||
wx:if="{{ loading }}"
|
||||
|
@ -1,15 +1,18 @@
|
||||
export const button = Behavior({
|
||||
externalClasses: ['hover-class'],
|
||||
|
||||
properties: {
|
||||
id: String,
|
||||
sessionFrom: String,
|
||||
appParameter: String,
|
||||
sendMessageImg: String,
|
||||
sendMessagePath: String,
|
||||
showMessageCard: String,
|
||||
sendMessageTitle: String,
|
||||
lang: {
|
||||
type: String,
|
||||
value: 'en'
|
||||
},
|
||||
sessionFrom: String,
|
||||
sendMessageTitle: String,
|
||||
sendMessagePath: String,
|
||||
sendMessageImg: String,
|
||||
showMessageCard: String,
|
||||
appParameter: String,
|
||||
ariaLabel: String
|
||||
}
|
||||
});
|
||||
|
@ -16,12 +16,16 @@ export const openType = Behavior({
|
||||
this.$emit('getphonenumber', event.detail);
|
||||
},
|
||||
|
||||
bindError(event: Partial<Weapp.Event>) {
|
||||
this.$emit('error', event.detail);
|
||||
},
|
||||
|
||||
bindLaunchApp(event: Partial<Weapp.Event>) {
|
||||
this.$emit('launchapp', event.detail);
|
||||
},
|
||||
|
||||
bindOpenSetting(event: Partial<Weapp.Event>) {
|
||||
this.$emit('opensetting', event.detail);
|
||||
},
|
||||
|
||||
bindError(event: Partial<Weapp.Event>) {
|
||||
this.$emit('error', event.detail);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user