[improvement]: 使用 hover-class 定义点击态样式

This commit is contained in:
rex 2019-02-03 21:25:58 +08:00 committed by GitHub
parent f07c4754db
commit 0e699d950e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 144 additions and 179 deletions

View File

@ -4,6 +4,17 @@
max-height: 90% !important; max-height: 90% !important;
color: @text-color; color: @text-color;
&__cancel {
height: 60px;
&::before {
display: block;
height: 10px;
background-color: @background-color;
content: ' ';
}
}
&__item, &__item,
&__cancel { &__cancel {
height: 50px; height: 50px;
@ -12,28 +23,17 @@
text-align: center; text-align: center;
background-color: @white; background-color: @white;
&:active { &--hover {
background-color: @active-color; background-color: @active-color;
} }
} }
&__cancel {
height: 60px;
&::before {
display: block;
content: ' ';
height: 10px;
background-color: @background-color;
}
}
&__item--disabled { &__item--disabled {
color: @gray; color: @gray;
&:active {
background-color: @white;
} }
&__item--disabled&__item--hover {
background-color: @white;
} }
&__subname { &__subname {

View File

@ -1,3 +1,5 @@
<wxs src="../wxs/utils.wxs" module="utils" />
<van-popup <van-popup
show="{{ show }}" show="{{ show }}"
position="bottom" position="bottom"
@ -22,7 +24,8 @@
wx:for="{{ actions }}" wx:for="{{ actions }}"
wx:key="index" wx:key="index"
open-type="{{ item.openType }}" open-type="{{ item.openType }}"
class="van-action-sheet__item van-hairline--top {{ item.disabled || item.loading ? 'van-action-sheet__item--disabled' : '' }} {{ item.className || '' }}" class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} van-hairline--top {{ item.className || '' }}"
hover-class="van-action-sheet__item--hover"
data-index="{{ index }}" data-index="{{ index }}"
bind:tap="onSelect" bind:tap="onSelect"
> >
@ -36,6 +39,8 @@
<view <view
wx:if="{{ cancelText }}" wx:if="{{ cancelText }}"
class="van-action-sheet__cancel" class="van-action-sheet__cancel"
hover-class="van-action-sheet__cancel--hover"
hover-stay-time="70"
bind:tap="onCancel" bind:tap="onCancel"
> >
{{ cancelText }} {{ cancelText }}

View File

@ -16,7 +16,7 @@
通过在`van-badge-group`上设置`active`属性来控制选中的`badge` 通过在`van-badge-group`上设置`active`属性来控制选中的`badge`
```html ```html
<van-badge-group :active="active" bind:change="onChange"> <van-badge-group active="{{ active }}" bind:change="onChange">
<van-badge title="标签名称" /> <van-badge title="标签名称" />
<van-badge title="标签名称" info="8" /> <van-badge title="标签名称" info="8" />
<van-badge title="标签名称" info="99" /> <van-badge title="标签名称" info="99" />

View File

@ -2,18 +2,18 @@
.van-badge { .van-badge {
display: block; display: block;
padding: 20px 12px 20px 9px;
overflow: hidden; overflow: hidden;
font-size: 14px; font-size: 14px;
line-height: 1.4; line-height: 1.4;
user-select: none;
color: @gray-darker; color: @gray-darker;
word-break: break-all; word-break: break-all;
box-sizing: border-box;
padding: 20px 12px 20px 9px;
background-color: @background-color; background-color: @background-color;
border-left: 3px solid transparent; border-left: 3px solid transparent;
box-sizing: border-box;
user-select: none;
&:active { &--hover {
background-color: @active-color; background-color: @active-color;
} }
@ -29,11 +29,11 @@
&::after { &::after {
border-right-width: 1px; border-right-width: 1px;
} }
&,
&:active {
background-color: @white;
} }
&--active,
&--active&--hover {
background-color: @white;
} }
&__text { &__text {

View File

@ -1,4 +1,11 @@
<view class="van-badge van-hairline custom-class {{ active ? 'van-badge--active' : '' }}" bind:tap="onClick"> <wxs src="../wxs/utils.wxs" module="utils" />
<view
class="{{ utils.bem('badge', { active }) }} van-hairline custom-class"
hover-class="van-badge--hover"
hover-stay-time="70"
bind:tap="onClick"
>
<view class="van-badge__text"> <view class="van-badge__text">
<van-info <van-info
wx:if="{{ info !== null }}" wx:if="{{ info !== null }}"

View File

@ -1,16 +1,16 @@
@import '../common/style/var.less'; @import '../common/style/var.less';
@import "../common/style/mixins/hairline.less"; @import '../common/style/mixins/hairline.less';
.van-cell { .van-cell {
width: 100%;
display: flex;
padding: 10px 15px;
box-sizing: border-box;
line-height: 24px;
position: relative; position: relative;
background-color: @white; display: flex;
color: @text-color; width: 100%;
padding: 10px 15px;
font-size: 14px; font-size: 14px;
line-height: 24px;
color: @text-color;
background-color: @white;
box-sizing: border-box;
&::after { &::after {
.hairline-bottom(@border-color, 15px); .hairline-bottom(@border-color, 15px);
@ -25,10 +25,17 @@
} }
&__label { &__label {
color: @gray-dark;
font-size: 12px;
margin-top: 3px; margin-top: 3px;
font-size: 12px;
line-height: 18px; line-height: 18px;
color: @gray-dark;
}
&__value {
overflow: hidden;
color: @gray-dark;
text-align: right;
vertical-align: middle;
} }
&__title, &__title,
@ -40,19 +47,12 @@
} }
} }
&__value {
color: @gray-dark;
overflow: hidden;
text-align: right;
vertical-align: middle;
}
&__left-icon-wrap, &__left-icon-wrap,
&__right-icon-wrap { &__right-icon-wrap {
display: flex; display: flex;
align-items: center;
height: 24px; height: 24px;
font-size: 16px; font-size: 16px;
align-items: center;
} }
&__left-icon-wrap { &__left-icon-wrap {
@ -73,21 +73,19 @@
line-height: 24px; line-height: 24px;
} }
&--clickable { &--clickable&--hover {
&:active {
background-color: @active-color; background-color: @active-color;
} }
}
&--required { &--required {
overflow: visible; overflow: visible;
&::before { &::before {
content: '*';
position: absolute; position: absolute;
left: 7px; left: 7px;
font-size: 14px; font-size: 14px;
color: @red; color: @red;
content: '*';
} }
} }

View File

@ -6,7 +6,8 @@ VantComponent({
'title-class', 'title-class',
'label-class', 'label-class',
'value-class', 'value-class',
'right-icon-class' 'right-icon-class',
'hover-class'
], ],
mixins: [link], mixins: [link],

View File

@ -2,6 +2,8 @@
<view <view
class="custom-class {{ utils.bem('cell', [size, { center, required, borderless: !border, clickable: isLink || clickable }]) }}" class="custom-class {{ utils.bem('cell', [size, { center, required, borderless: !border, clickable: isLink || clickable }]) }}"
hover-class="van-cell--hover hover-class"
hover-stay-time="70"
style="{{ customStyle }}" style="{{ customStyle }}"
bind:tap="onClick" bind:tap="onClick"
> >

View File

@ -19,7 +19,7 @@
color: @collapse-item-title-disabled-color !important; color: @collapse-item-title-disabled-color !important;
} }
.van-cell:active { .van-cell--hover {
background-color: @white !important; background-color: @white !important;
} }
} }
@ -30,10 +30,10 @@
} }
&__content { &__content {
color: @collapse-item-content-text-color;
padding: @collapse-item-content-padding; padding: @collapse-item-content-padding;
font-size: @collapse-item-content-font-size; font-size: @collapse-item-content-font-size;
line-height: @collapse-item-content-line-height; line-height: @collapse-item-content-line-height;
color: @collapse-item-content-text-color;
background-color: @collapse-item-content-background-color; background-color: @collapse-item-content-background-color;
} }
} }

View File

@ -12,6 +12,7 @@
class="{{ utils.bem('collapse-item__title', { disabled, expanded }) }}" class="{{ utils.bem('collapse-item__title', { disabled, expanded }) }}"
right-icon-class="van-cell__right-icon" right-icon-class="van-cell__right-icon"
custom-class="van-cell" custom-class="van-cell"
hover-class="van-cell--hover"
bind:click="onClick" bind:click="onClick"
> >
<slot <slot

View File

@ -1,72 +0,0 @@
@import '../common/style/var.less';
.van-picker {
-webkit-text-size-adjust: 100%; /* avoid iOS text size adjust */
position: relative;
overflow: hidden;
background-color: @white;
user-select: none;
&__toolbar {
display: flex;
justify-content: space-between;
height: 44px;
line-height: 44px;
}
&__cancel,
&__confirm {
color: @blue;
padding: 0 15px;
font-size: 14px;
&:active {
background-color: @active-color;
}
}
&__title {
max-width: 50%;
font-size: 16px;
font-weight: 500;
text-align: center;
}
&__columns {
position: relative;
}
&__loading {
display: flex;
z-index: 4;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
align-items: center;
justify-content: center;
background-color: rgba(255, 255, 255, .9);
}
&-column {
flex: 1;
overflow: hidden;
font-size: 16px;
text-align: center;
&__item {
padding: 0 5px;
color: @gray-dark;
&--selected {
font-weight: 500;
color: @text-color;
}
&--disabled {
opacity: .3;
}
}
}
}

View File

@ -2,14 +2,14 @@
.van-dialog { .van-dialog {
width: 85%; width: 85%;
font-size: 16px;
overflow: hidden; overflow: hidden;
border-radius: 4px; font-size: 16px;
background-color: @white; background-color: @white;
border-radius: 4px;
&__header { &__header {
font-weight: 500;
padding-top: 25px; padding-top: 25px;
font-weight: 500;
text-align: center; text-align: center;
&--isolated { &--isolated {
@ -18,11 +18,11 @@
} }
&__message { &__message {
max-height: 60vh;
padding: 25px; padding: 25px;
overflow-y: auto;
font-size: 14px; font-size: 14px;
line-height: 1.5; line-height: 1.5;
max-height: 60vh;
overflow-y: auto;
text-align: center; text-align: center;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
@ -54,11 +54,8 @@
} }
&__confirm { &__confirm {
&,
&:active {
color: @blue !important; color: @blue !important;
} }
}
&-bounce-enter { &-bounce-enter {
opacity: 0; opacity: 0;

View File

@ -1,42 +1,54 @@
@import '../common/style/var.less'; @import '../common/style/var.less';
.van-nav-bar { .van-nav-bar {
height: 46px;
position: relative; position: relative;
user-select: none; height: 46px;
text-align: center;
line-height: 46px; line-height: 46px;
text-align: center;
background-color: @white; background-color: @white;
user-select: none;
&__text {
display: inline-block;
padding: 0 15px;
margin: 0 -15px;
color: @blue;
vertical-align: middle;
&--hover {
background-color: @active-color;
}
}
&__arrow { &__arrow {
color: @blue; color: @blue;
vertical-align: middle; vertical-align: middle;
+ .van-nav-bar__text { + .van-nav-bar__text {
margin-left: -20px;
padding-left: 25px; padding-left: 25px;
margin-left: -20px;
} }
} }
&--fixed { &--fixed {
position: fixed;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
position: fixed;
} }
&__title { &__title {
margin: 0 auto;
max-width: 60%; max-width: 60%;
margin: 0 auto;
font-size: 16px; font-size: 16px;
font-weight: 500; font-weight: 500;
} }
&__left, &__left,
&__right { &__right {
position: absolute;
bottom: 0; bottom: 0;
font-size: 14px; font-size: 14px;
position: absolute;
} }
&__left { &__left {
@ -46,16 +58,4 @@
&__right { &__right {
right: 15px; right: 15px;
} }
&__text {
color: @blue;
margin: 0 -15px;
padding: 0 15px;
display: inline-block;
vertical-align: middle;
&:active {
background-color: @active-color;
}
}
} }

View File

@ -10,7 +10,12 @@
name="arrow-left" name="arrow-left"
custom-class="van-nav-bar__arrow" custom-class="van-nav-bar__arrow"
/> />
<view wx:if="{{ leftText }}" class="van-nav-bar__text">{{ leftText }}</view> <view
wx:if="{{ leftText }}"
class="van-nav-bar__text"
hover-class="van-nav-bar__text--hover"
hover-stay-time="70"
>{{ leftText }}</view>
</block> </block>
<slot wx:else name="left" /> <slot wx:else name="left" />
</view> </view>
@ -19,7 +24,12 @@
<slot wx:else name="title" /> <slot wx:else name="title" />
</view> </view>
<view class="van-nav-bar__right" bind:tap="onClickRight"> <view class="van-nav-bar__right" bind:tap="onClickRight">
<view wx:if="{{ rightText }}" class="van-nav-bar__text">{{ rightText }}</view> <view
wx:if="{{ rightText }}"
class="van-nav-bar__text"
hover-class="van-nav-bar__text--hover"
hover-stay-time="70"
>{{ rightText }}</view>
<slot wx:else name="right" /> <slot wx:else name="right" />
</view> </view>
</view> </view>

View File

@ -20,7 +20,7 @@
font-size: 14px; font-size: 14px;
color: @blue; color: @blue;
&:active { &--hover {
background-color: @active-color; background-color: @active-color;
} }
} }

View File

@ -3,11 +3,23 @@
wx:if="{{ showToolbar }}" wx:if="{{ showToolbar }}"
class="van-picker__toolbar van-hairline--top-bottom toolbar-class" class="van-picker__toolbar van-hairline--top-bottom toolbar-class"
> >
<view class="van-picker__cancel" data-type="cancel" bindtap="emit"> <view
class="van-picker__cancel"
hover-class="van-picker__cancel--hover"
hover-stay-time="70"
data-type="cancel"
bindtap="emit"
>
{{ cancelButtonText || '取消' }} {{ cancelButtonText || '取消' }}
</view> </view>
<view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{ title }}</view> <view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{ title }}</view>
<view class="van-picker__confirm" data-type="confirm" bindtap="emit"> <view
class="van-picker__confirm"
hover-class="van-picker__confirm--hover"
hover-stay-time="70"
data-type="confirm"
bindtap="emit"
>
{{ confirmButtonText || '确认' }} {{ confirmButtonText || '确认' }}
</view> </view>
</view> </view>

View File

@ -35,7 +35,7 @@
line-height: 30px; line-height: 30px;
color: @gray-darker; color: @gray-darker;
&:active { &--hover {
background-color: @active-color; background-color: @active-color;
} }
} }

View File

@ -26,7 +26,12 @@
bind:confirm="onSearch" bind:confirm="onSearch"
bind:clear="onClear" bind:clear="onClear"
/> />
<view wx:if="{{ showAction || useActionSlot }}" class="van-search__action"> <view
wx:if="{{ showAction || useActionSlot }}"
class="van-search__action"
hover-class="van-search__action--hover"
hover-stay-time="70"
>
<slot wx:if="{{ useActionSlot }}" name="action" /> <slot wx:if="{{ useActionSlot }}" name="action" />
<view wx:else bind:tap="onCancel" class="cancel-class">取消</view> <view wx:else bind:tap="onCancel" class="cancel-class">取消</view>
</view> </view>

View File

@ -11,6 +11,18 @@
background-color: @white; background-color: @white;
} }
&__minus {
border-radius: 2px 0 0 2px;
&::after {
display: none;
}
}
&__plus {
border-radius: 0 2px 2px 0;
}
&__minus, &__minus,
&__plus { &__plus {
position: relative; position: relative;
@ -42,7 +54,7 @@
content: ''; content: '';
} }
&:active { &--hover {
background-color: @active-color; background-color: @active-color;
} }
@ -55,23 +67,11 @@
} }
} }
&--disabled:active { &--disabled&--hover {
background-color: @background-color; background-color: @background-color;
} }
} }
&__minus {
border-radius: 2px 0 0 2px;
&::after {
display: none;
}
}
&__plus {
border-radius: 0 2px 2px 0;
}
&__input-wrapper { &__input-wrapper {
position: relative; position: relative;
width: 35px; width: 35px;

View File

@ -1,6 +1,8 @@
<view class="van-stepper custom-class"> <view class="van-stepper custom-class">
<view <view
class="minus-class van-stepper__minus {{ minusDisabled ? 'van-stepper__minus--disabled' : '' }}" class="minus-class van-stepper__minus {{ minusDisabled ? 'van-stepper__minus--disabled' : '' }}"
hover-class="van-stepper__minus--hover"
hover-stay-time="70"
bind:tap="onMinus" bind:tap="onMinus"
/> />
<view class="input-class van-stepper__input-wrapper {{ disabled || disableInput ? 'van-stepper__input-wrapper--disabled' : '' }}" bindtap="onFocus"> <view class="input-class van-stepper__input-wrapper {{ disabled || disableInput ? 'van-stepper__input-wrapper--disabled' : '' }}" bindtap="onFocus">
@ -16,6 +18,8 @@
</view> </view>
<view <view
class="plus-class van-stepper__plus {{ plusDisabled ? 'van-stepper__plus--disabled' : '' }}" class="plus-class van-stepper__plus {{ plusDisabled ? 'van-stepper__plus--disabled' : '' }}"
hover-class="van-stepper__plus--hover"
hover-stay-time="70"
bind:tap="onPlus" bind:tap="onPlus"
/> />
</view> </view>

View File

@ -38,10 +38,6 @@
&--disabled { &--disabled {
color: @gray-dark; color: @gray-dark;
} }
&--disabled:active::after {
display: none;
}
} }
&__content { &__content {
@ -61,8 +57,7 @@
color: @red; color: @red;
} }
&--disabled, &--disabled {
&--disabled:active {
color: @gray-dark; color: @gray-dark;
} }
} }