Skip to content

Commit

Permalink
feat: improve cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Jan 11, 2020
1 parent 5cbb9e2 commit 2eb6807
Show file tree
Hide file tree
Showing 33 changed files with 97 additions and 24 deletions.
10 changes: 10 additions & 0 deletions src/action-sheet/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
text-align: center;
background-color: @action-sheet-item-background;
border: none;
cursor: pointer;

&:active {
background-color: @active-color;
Expand All @@ -23,13 +24,22 @@
&__item {
height: @action-sheet-item-height;

&--loading,
&--disabled {
color: @action-sheet-item-disabled-text-color;

&:active {
background-color: @action-sheet-item-background;
}
}

&--disabled {
cursor: not-allowed;
}

&--loading {
cursor: default;
}
}

&__subname {
Expand Down
12 changes: 6 additions & 6 deletions src/action-sheet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ function ActionSheet(
}

function Option(item: ActionSheetItem, index: number) {
const disabled = item.disabled || item.loading;
const { disabled, loading, callback } = item;

function onClickOption(event: MouseEvent) {
event.stopPropagation();

if (item.disabled || item.loading) {
if (disabled || loading) {
return;
}

if (item.callback) {
item.callback(item);
if (callback) {
callback(item);
}

emit(ctx, 'select', item, index);
Expand All @@ -91,7 +91,7 @@ function ActionSheet(
}

function OptionContent() {
if (item.loading) {
if (loading) {
return <Loading size="20px" />;
}

Expand All @@ -104,7 +104,7 @@ function ActionSheet(
return (
<button
type="button"
class={[bem('item', { disabled }), item.className, BORDER_TOP]}
class={[bem('item', { disabled, loading }), item.className, BORDER_TOP]}
style={{ color: item.color }}
onClick={onClickOption}
>
Expand Down
2 changes: 1 addition & 1 deletion src/action-sheet/test/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`callback events 1`] = `
<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom"><button type="button" class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span></button><button type="button" class="van-action-sheet__item van-action-sheet__item--disabled van-hairline--top"><span class="van-action-sheet__name">Option</span></button><button type="button" class="van-action-sheet__item van-action-sheet__item--disabled van-hairline--top">
<div class="van-popup van-popup--round van-popup--bottom van-popup--safe-area-inset-bottom van-action-sheet" name="van-popup-slide-bottom"><button type="button" class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span></button><button type="button" class="van-action-sheet__item van-action-sheet__item--disabled van-hairline--top"><span class="van-action-sheet__name">Option</span></button><button type="button" class="van-action-sheet__item van-action-sheet__item--loading van-hairline--top">
<div class="van-loading van-loading--circular"><span class="van-loading__spinner van-loading__spinner--circular" style="width: 20px; height: 20px;"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span></div>
</button><button type="button" class="van-action-sheet__item van-hairline--top"><span class="van-action-sheet__name">Option</span><span class="van-action-sheet__subname">Subname</span></button><button type="button" class="van-action-sheet__cancel">Cancel</button></div>
`;
Expand Down
2 changes: 2 additions & 0 deletions src/collapse-item/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
}

&--disabled {
cursor: not-allowed;

&,
& .van-cell__right-icon {
color: @collapse-item-title-disabled-color;
Expand Down
1 change: 1 addition & 0 deletions src/dropdown-menu/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
align-items: center;
justify-content: center;
min-width: 0; // hack for flex ellipsis
cursor: pointer;

&:active {
opacity: @active-opacity;
Expand Down
1 change: 1 addition & 0 deletions src/field/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
&__clear {
color: @field-clear-icon-color;
font-size: @field-clear-icon-size;
cursor: pointer;
}

&__left-icon .van-icon,
Expand Down
1 change: 1 addition & 0 deletions src/goods-action-icon/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
line-height: 1;
text-align: center;
background-color: @white;
cursor: pointer;

&:active {
background-color: @goods-action-icon-active-color;
Expand Down
8 changes: 6 additions & 2 deletions src/grid-item/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@
}
}

&--clickable:active {
background-color: @grid-item-content-active-color;
&--clickable {
cursor: pointer;

&:active {
background-color: @grid-item-content-active-color;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/index-bar/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
flex-direction: column;
text-align: center;
transform: translateY(-50%);
cursor: pointer;
user-select: none;
}

Expand Down
1 change: 1 addition & 0 deletions src/nav-bar/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
position: absolute;
bottom: 0;
font-size: @font-size-md;
cursor: pointer;
}

&__left {
Expand Down
1 change: 1 addition & 0 deletions src/notice-bar/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

&__right-icon {
text-align: right;
cursor: pointer;
}

&__wrap {
Expand Down
2 changes: 2 additions & 0 deletions src/number-keyboard/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
padding: @number-keyboard-close-padding;
color: @number-keyboard-close-color;
font-size: @number-keyboard-close-font-size;
cursor: pointer;

&:active {
background-color: @number-keyboard-key-active-color;
Expand Down Expand Up @@ -69,6 +70,7 @@
line-height: @number-keyboard-key-height;
text-align: center;
vertical-align: middle;
cursor: pointer;

&::after {
border-width: @border-width-base @border-width-base 0 0;
Expand Down
2 changes: 1 addition & 1 deletion src/pagination/demo/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {
i18n: {
'zh-CN': {
title2: '简单模式',
title3: '',
title3: '显示省略号',
prevText: '上一页',
nextText: '下一页'
},
Expand Down
19 changes: 12 additions & 7 deletions src/pagination/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
height: @pagination-height;
color: @pagination-item-default-color;
background-color: @pagination-background-color;
cursor: pointer;
user-select: none;

&:active {
Expand All @@ -28,13 +29,6 @@
border-right-width: @border-width-base;
}

&--disabled,
&--disabled:active {
color: @pagination-item-disabled-color;
background-color: @pagination-item-disabled-background-color;
opacity: @pagination-disabled-opacity;
}

&--active {
color: @white;
background-color: @pagination-item-default-color;
Expand All @@ -44,6 +38,17 @@
&__prev,
&__next {
padding: 0 @padding-base;
cursor: pointer;
}

&__item--disabled {
&,
&:active {
color: @pagination-item-disabled-color;
background-color: @pagination-item-disabled-background-color;
cursor: not-allowed;
opacity: @pagination-disabled-opacity;
}
}

&__page {
Expand Down
1 change: 1 addition & 0 deletions src/password-input/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
display: flex;
width: 100%;
height: @password-input-height;
cursor: pointer;

&::after {
border-radius: @password-input-border-radius;
Expand Down
2 changes: 1 addition & 1 deletion src/picker/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
&__columns {
position: relative;
display: flex;
cursor: pointer;
cursor: grab;
}

&__loading {
Expand Down
9 changes: 8 additions & 1 deletion src/rate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,14 @@ export default createComponent({

render() {
return (
<div class={bem()} tabindex="0" role="radiogroup">
<div
class={bem({
readonly: this.readonly,
disabled: this.disabled
})}
tabindex="0"
role="radiogroup"
>
{this.list.map((status, index) => this.genStar(status, index))}
</div>
);
Expand Down
9 changes: 9 additions & 0 deletions src/rate/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.van-rate {
display: inline-flex;
cursor: pointer;
user-select: none;

&__item {
Expand All @@ -25,4 +26,12 @@
overflow: hidden;
}
}

&--disabled {
cursor: not-allowed;
}

&--readonly {
cursor: default;
}
}
4 changes: 2 additions & 2 deletions src/rate/test/__snapshots__/demo.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ exports[`renders demo correctly 1`] = `
</div>
</div>
<div>
<div tabindex="0" role="radiogroup" class="van-rate">
<div tabindex="0" role="radiogroup" class="van-rate van-rate--disabled">
<div role="radio" tabindex="0" aria-setsize="5" aria-posinset="1" aria-checked="true" class="van-rate__item"><i data-score="1" class="van-icon van-icon-star van-rate__icon" style="color: rgb(189, 189, 189);">
<!----></i></div>
<div role="radio" tabindex="0" aria-setsize="5" aria-posinset="2" aria-checked="true" class="van-rate__item"><i data-score="2" class="van-icon van-icon-star van-rate__icon" style="color: rgb(189, 189, 189);">
Expand All @@ -94,7 +94,7 @@ exports[`renders demo correctly 1`] = `
</div>
</div>
<div>
<div tabindex="0" role="radiogroup" class="van-rate">
<div tabindex="0" role="radiogroup" class="van-rate van-rate--readonly">
<div role="radio" tabindex="0" aria-setsize="5" aria-posinset="1" aria-checked="true" class="van-rate__item"><i data-score="1" class="van-icon van-icon-star van-rate__icon" style="color: rgb(255, 210, 30);">
<!----></i></div>
<div role="radio" tabindex="0" aria-setsize="5" aria-posinset="2" aria-checked="true" class="van-rate__item"><i data-score="2" class="van-icon van-icon-star van-rate__icon" style="color: rgb(255, 210, 30);">
Expand Down
2 changes: 2 additions & 0 deletions src/search/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
color: @search-action-text-color;
font-size: @search-action-font-size;
line-height: @search-input-height;
cursor: pointer;
user-select: none;

&:active {
background-color: @active-color;
Expand Down
2 changes: 2 additions & 0 deletions src/sidebar-item/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
word-wrap: break-word;
background-color: @sidebar-background-color;
border-left: 3px solid transparent;
cursor: pointer;
user-select: none;

&__text {
Expand Down Expand Up @@ -43,6 +44,7 @@

&--disabled {
color: @sidebar-disabled-text-color;
cursor: not-allowed;

&:active {
background-color: @sidebar-background-color;
Expand Down
2 changes: 2 additions & 0 deletions src/sku/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
line-height: 16px;
vertical-align: middle;
border-radius: @border-radius-md;
cursor: pointer;

&::before {
position: absolute;
Expand Down Expand Up @@ -184,6 +185,7 @@
&--disabled {
color: @gray-5;
background: @active-color;
cursor: not-allowed;

.van-sku-row__item-img {
opacity: .3;
Expand Down
7 changes: 7 additions & 0 deletions src/slider/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
position: relative;
background-color: @slider-inactive-background-color;
border-radius: @border-radius-max;
cursor: pointer;

// use pseudo element to expand click area
&::before {
Expand Down Expand Up @@ -34,11 +35,17 @@
top: 50%;
right: 0;
transform: translate3d(50%, -50%, 0);
cursor: grab;
}
}

&--disabled {
cursor: not-allowed;
opacity: @slider-disabled-opacity;

.van-slider__button-wrapper {
cursor: not-allowed;
}
}

&--vertical {
Expand Down
2 changes: 2 additions & 0 deletions src/stepper/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
vertical-align: middle;
background-color: @stepper-background-color;
border: 0;
cursor: pointer;

&::before {
width: 13px;
Expand Down Expand Up @@ -46,6 +47,7 @@
&--disabled {
color: @stepper-button-disabled-icon-color;
background-color: @stepper-button-disabled-color;
cursor: not-allowed;

&:active {
background-color: @stepper-button-disabled-color;
Expand Down
1 change: 1 addition & 0 deletions src/swipe-cell/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.van-swipe-cell {
position: relative;
overflow: hidden;
cursor: grab;

&__wrapper {
transition-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/swipe/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.van-swipe {
position: relative;
overflow: hidden;
cursor: pointer;
cursor: grab;
user-select: none;

&__track {
Expand Down
2 changes: 1 addition & 1 deletion src/switch-cell/test/__snapshots__/demo.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports[`renders demo correctly 1`] = `
<div class="van-cell van-cell--center van-switch-cell">
<div class="van-cell__title"><span>标题</span></div>
<div class="van-cell__value">
<div role="switch" aria-checked="true" class="van-switch van-switch--on" style="font-size: 24px;">
<div role="switch" aria-checked="true" class="van-switch van-switch--on van-switch--loading" style="font-size: 24px;">
<div class="van-switch__node">
<div class="van-loading van-loading--circular van-switch__loading"><span class="van-loading__spinner van-loading__spinner--circular" style="color: rgb(25, 137, 250);"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span></div>
</div>
Expand Down
Loading

0 comments on commit 2eb6807

Please sign in to comment.