diff --git a/packages/vant-css/package.json b/packages/vant-css/package.json
index 832ee920c..2d1d27332 100644
--- a/packages/vant-css/package.json
+++ b/packages/vant-css/package.json
@@ -1,6 +1,6 @@
{
"name": "vant-css",
- "version": "0.6.2",
+ "version": "0.6.5",
"description": "vant css.",
"main": "lib/index.css",
"style": "lib/index.css",
diff --git a/packages/vant-css/src/card.css b/packages/vant-css/src/card.css
index 7cd6a1bc0..31916fd60 100644
--- a/packages/vant-css/src/card.css
+++ b/packages/vant-css/src/card.css
@@ -1,93 +1,93 @@
@import './mixins/ellipsis.css';
-@component-namespace van {
- @b card {
- padding: 5px 15px 5px 115px;
- height: 90px;
- background: #FAFAFA;
- overflow: hidden;
- position: relative;
+.van-card {
+ color: #333;
+ height: 90px;
+ background: #fafafa;
+ position: relative;
+ padding: 5px 15px 5px 115px;
+
+ &:not(:first-child) {
margin-top: 10px;
+ }
- &:first-child {
- margin-top: 0;
+ &--center,
+ &__thumb {
+ align-items: center;
+ justify-content: center;
+ }
+
+ &__thumb {
+ top: 5px;
+ left: 15px;
+ width: 90px;
+ height: 90px;
+ position: absolute;
+
+ img {
+ border: none;
+ max-width: 100%;
+ max-height: 100%;
}
+ }
- @e img {
- width: 90px;
- height: auto;
- border: 0;
- position: absolute;
- top: 5px;
- left: 15px;
+ &,
+ &__thumb,
+ &__row {
+ display: flex;
+ }
+
+ &__content {
+ width: 100%;
+
+ &--center {
+ height: 90px;
+ align-items: center;
}
+ }
- @e content {
- display: table;
- width: 100%;
+ &__title,
+ &__desc {
+ line-height: 20px;
+ word-break: break-all;
+ }
- @m center {
- display: table;
- height: 90px;
+ &__title {
+ max-height: 40px;
+ @mixin multi-ellipsis 2;
+ }
- .van-card__info {
- display: table-cell;
- vertical-align: middle;
- }
- }
- }
+ &__desc {
+ color: #666;
+ font-size: 12px;
+ max-height: 20px;
+ @mixin multi-ellipsis 1;
+ }
- @e row {
- overflow: hidden;
- padding-right: 80px;
- position: relative;
- }
+ &__price,
+ &__num {
+ flex: 1;
+ min-width: 80px;
+ line-height: 20px;
+ text-align: right;
+ }
- @e title {
- line-height: 20px;
- color: #333;
- max-height: 40px;
- margin-bottom: 5px;
- word-break: break-all;
- @mixin multi-ellipsis 2;
- }
+ &__price {
+ font-size: 14px;
+ }
- @e desc {
- font-size: 12px;
- color: #666;
- max-height: 20px;
- word-break: break-all;
- @mixin multi-ellipsis 1;
- }
+ &__num {
+ color: #666;
+ font-size: 12px;
+ }
- @e price {
- position: absolute;
- top: 0;
- right: 0;
- width: 80px;
- text-align: right;
- font-size: 14px;
- color: #333;
- }
+ &__footer {
+ right: 15px;
+ bottom: 5px;
+ position: absolute;
- @e num {
- position: absolute;
- top: 0;
- right: 0;
- width: 80px;
- text-align: right;
- font-size: 12px;
- color: #666;
- }
-
- @e footer {
- position: absolute;
- right: 15px;
- bottom: 5px;
-
- .van-button {
- margin-left: 5px;
- }
+ .van-button {
+ margin-left: 5px;
}
}
}
diff --git a/packages/vant-css/src/steps.css b/packages/vant-css/src/steps.css
index f2b16ba8f..f5f25eddd 100644
--- a/packages/vant-css/src/steps.css
+++ b/packages/vant-css/src/steps.css
@@ -1,13 +1,32 @@
@import './common/var.css';
@import './mixins/ellipsis.css';
@import './icon.css';
+@import './mixins/border_retina.css';
@component-namespace van {
@b steps {
overflow: hidden;
- padding: 0 10px;
background-color: #fff;
+ @m horizontal {
+ padding: 0 10px;
+
+ .van-steps__items {
+ margin: 0 0 10px;
+ overflow: hidden;
+ position: relative;
+ padding-bottom: 22px;
+
+ &.van-steps__items--alone {
+ padding-top: 10px;
+ }
+ }
+ }
+
+ @m vertical {
+ padding: 0 0 0 35px;
+ }
+
@m 4 {
.van-step {
width: 33.2%;
@@ -53,86 +72,94 @@
max-height: 18px;
@mixin multi-ellipsis 1;
}
-
- @e items {
- margin: 0 0 10px;
- overflow: hidden;
- position: relative;
- padding-bottom: 20px;
-
- @m alone {
- padding-top: 10px;
- }
- }
}
@b step {
font-size: 14px;
- float: left;
position: relative;
color: $c-gray-dark;
+
+ @m horizontal {
+ float: left;
- @m finish {
- color: $c-black;
-
- .van-step__circle,
- .van-step__line {
- background-color: $c-green;
+ &:first-child {
+ .van-step__title {
+ transform: none;
+ margin-left: 0;
+ }
}
- }
- @m process {
- color: $c-black;
+ &:last-child {
+ position: absolute;
+ right: 10px;
+ width: auto;
+
+ .van-step__title {
+ transform: none;
+ margin-left: 0;
+ }
+
+ .van-step__circle-container {
+ left: auto;
+ right: -9px;
+ }
+
+ .van-step__line {
+ width: 0;
+ }
+ }
.van-step__circle-container {
- top: 24px;
+ position: absolute;
+ top: 28px;
+ left: -8px;
+ padding: 0 8px;
+ background-color: #fff;
+ z-index: 1;
}
- .van-icon {
+ .van-step__title {
font-size: 12px;
- color: $c-green;
- line-height: 1;
- display: block;
- }
- }
-
- &:first-child {
- .van-step__title {
- transform: none;
- margin-left: 0;
- }
- }
-
- &:last-child {
- position: absolute;
- right: 10px;
- width: auto;
-
- .van-step__title {
- transform: none;
- margin-left: 0;
- }
-
- .van-step__circle-container {
- left: auto;
- right: -9px;
+ transform: translate3d(-50%, 0, 0);
+ display: inline-block;
+ margin-left: 3px;
}
.van-step__line {
- width: 0;
+ position: absolute;
+ left: 0px;
+ top: 30px;
+ width: 100%;
+ height: 1px;
+ background-color: $c-gray-light;
+ }
+
+ &.van-step--finish {
+ color: $c-black;
+
+ .van-step__circle,
+ .van-step__line {
+ background-color: $c-green;
+ }
+ }
+
+ &.van-step--process {
+ color: $c-black;
+
+ .van-step__circle-container {
+ top: 24px;
+ }
+
+ .van-icon {
+ font-size: 12px;
+ color: $c-green;
+ line-height: 1;
+ display: block;
+ }
}
}
- .van-step__circle-container {
- position: absolute;
- top: 28px;
- left: -8px;
- padding: 0 8px;
- background-color: #fff;
- z-index: 1;
- }
-
- @e circle {
+ .van-step__circle {
display: block;
width: 5px;
height: 5px;
@@ -140,20 +167,59 @@
border-radius: 50%;
}
- @e title {
- font-size: 12px;
- transform: translate3d(-50%, 0, 0);
- display: inline-block;
- margin-left: 3px;
- }
+ @m vertical {
+ float: none;
+ display: block;
+ font-size: 14px;
+ line-height: 18px;
+ padding: 10px 10px 10px 0;
- @e line {
- position: absolute;
- left: 0px;
- top: 30px;
- width: 100%;
- height: 1px;
- background-color: $c-gray-light;
+ &::after {
+ @mixin border-retina (bottom);
+ }
+
+ &:first-child {
+ &::before {
+ content: '';
+ position: absolute;
+ width: 1px;
+ height: 20px;
+ background-color: #fff;
+ top: 0;
+ left: -15px;
+ z-index: 1;
+ }
+ }
+
+ &:last-child::after {
+ display: none;
+ }
+
+ .van-step__circle-container > i {
+ position: absolute;
+ z-index: 2;
+ }
+
+ .van-icon-checked {
+ top: 12px;
+ left: -20px;
+ line-height: 1;
+ font-size: 12px;
+ }
+
+ .van-step__circle {
+ top: 16px;
+ left: -17px;
+ }
+
+ .van-step__line {
+ position: absolute;
+ top: 0;
+ left: -15px;
+ width: 1px;
+ height: 100%;
+ background-color: $c-gray-light;
+ }
}
}
}
diff --git a/packages/vant-css/src/tab.css b/packages/vant-css/src/tab.css
index 2fe518cfe..f7ace23fe 100644
--- a/packages/vant-css/src/tab.css
+++ b/packages/vant-css/src/tab.css
@@ -5,27 +5,20 @@
@b tabs {
position: relative;
- @m col-2 {
- .van-tab {
- width: 50%;
- }
+ @e nav-wrap {
+ overflow: hidden;
}
- @m col-3 {
- .van-tab {
- width: 33.33333333333333%;
- }
- }
+ @e swipe {
+ user-select: none;
+ transition: transform ease .3s;
- @m col-4 {
.van-tab {
- width: 25%;
+ flex: 0 0 22%;
}
- }
- @m col-5 {
- .van-tab {
- width: 20%;
+ .van-tabs__nav {
+ overflow: visible;
}
}
@@ -33,16 +26,15 @@
overflow: hidden;
transition: transform .5s cubic-bezier(.645, .045, .355, 1);
position: relative;
+ display: flex;
@m line {
height: 44px;
- background-color: $c-white;
- &::after {
- @mixin border-retina (top);
- @mixin border-retina (bottom);
- }
- @b tabs-nav-bar {
- display: block;
+
+ .van-tab {
+ &::after {
+ @mixin border-retina (top, bottom);
+ }
}
}
@@ -55,14 +47,16 @@
overflow: hidden;
.van-tab {
- color: #666666;
+ color: #666;
line-height: 28px;
- border-right: 1px solid #666666;
+ border-right: 1px solid #666;
+
&:last-child {
border-right: none;
}
+
&.van-tab--active {
- background-color: #666666;
+ background-color: #666;
color: $c-white;
}
}
@@ -82,13 +76,16 @@
}
@b tab {
+ position: relative;
color: $c-black;
+ background-color: $c-white;
font-size: 14px;
line-height: 44px;
box-sizing: border-box;
cursor: pointer;
text-align: center;
- float: left;
+ flex: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
@m active {
color: #FF4444;
diff --git a/src/index.js b/src/index.js
index 8f9fa42b5..1e512bef2 100644
--- a/src/index.js
+++ b/src/index.js
@@ -83,7 +83,7 @@ if (typeof window !== 'undefined' && window.Vue) {
module.exports = {
install,
- version: '0.6.2',
+ version: '0.6.5',
Button,
Switch,
Field,
diff --git a/src/utils/clickoutside.js b/src/utils/clickoutside.js
index db5e6a871..28c8f36a9 100644
--- a/src/utils/clickoutside.js
+++ b/src/utils/clickoutside.js
@@ -6,6 +6,8 @@
*
* ```
*/
+import Vue from 'vue';
+const isServer = Vue.prototype.$isServer;
const clickoutsideContext = '@@clickoutsideContext';
export default {
@@ -20,7 +22,7 @@ export default {
methodName: binding.expression,
arg: binding.arg || 'click'
};
- document.addEventListener(el[clickoutsideContext].arg, documentHandler);
+ !isServer && document.addEventListener(el[clickoutsideContext].arg, documentHandler);
},
update(el, binding) {
@@ -28,7 +30,7 @@ export default {
},
unbind(el) {
- document.removeEventListener(
+ !isServer && document.removeEventListener(
el[clickoutsideContext].arg,
el[clickoutsideContext].documentHandler);
},
diff --git a/src/utils/dom.js b/src/utils/dom.js
index b5c2550a6..45f9e385b 100644
--- a/src/utils/dom.js
+++ b/src/utils/dom.js
@@ -1,3 +1,6 @@
+import Vue from 'vue';
+const isServer = Vue.prototype.$isServer;
+
const trim = function(string) {
return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
};
@@ -66,7 +69,7 @@ export const once = function(el, event, fn) {
};
export const on = (function() {
- if (document.addEventListener) {
+ if (!isServer && document.addEventListener) {
return function(element, event, handler) {
if (element && event && handler) {
element.addEventListener(event, handler, false);
@@ -82,7 +85,7 @@ export const on = (function() {
})();
export const off = (function() {
- if (document.removeEventListener) {
+ if (!isServer && document.removeEventListener) {
return function(element, event, handler) {
if (element && event) {
element.removeEventListener(event, handler, false);
diff --git a/test/unit/components/more-tabs.vue b/test/unit/components/more-tabs.vue
new file mode 100644
index 000000000..6313f92ca
--- /dev/null
+++ b/test/unit/components/more-tabs.vue
@@ -0,0 +1,28 @@
+
+
+ 内容一
+ 内容二
+ 内容三
+ 内容四
+ 内容五
+ 内容六
+ 内容七
+ 内容八
+
+
+
+
diff --git a/test/unit/components/tabs.vue b/test/unit/components/tabs.vue
index df871ba68..a63a15b0d 100644
--- a/test/unit/components/tabs.vue
+++ b/test/unit/components/tabs.vue
@@ -4,7 +4,6 @@
内容二
内容三
内容四
- 内容五
diff --git a/test/unit/specs/dialog.spec.js b/test/unit/specs/dialog.spec.js
index 2fad23a13..aa006b88f 100644
--- a/test/unit/specs/dialog.spec.js
+++ b/test/unit/specs/dialog.spec.js
@@ -1,4 +1,5 @@
import Dialog from 'packages/dialog';
+import Vue from 'vue';
describe('Dialog', () => {
afterEach(() => {
@@ -51,6 +52,6 @@ describe('Dialog', () => {
document.querySelector('.van-dialog__cancel').click();
expect(dialogAction).to.equal('cancel');
done();
- }, 50);
+ }, 500);
});
});
diff --git a/test/unit/specs/image-preview.spec.js b/test/unit/specs/image-preview.spec.js
index 6475f4b81..d6ad06931 100644
--- a/test/unit/specs/image-preview.spec.js
+++ b/test/unit/specs/image-preview.spec.js
@@ -16,6 +16,7 @@ describe('ImagePreview', () => {
it('create a image preview', (done) => {
ImagePreview([
+ 'https://img.yzcdn.cn/upload_files/2017/03/15/FkubrzN7AgGwLlTeb1E89-T_ZjBg.png',
'https://img.yzcdn.cn/upload_files/2017/03/14/FmTPs0SeyQaAOSK1rRe1sL8RcwSY.jpeg',
'https://img.yzcdn.cn/upload_files/2017/03/15/FvexrWlG_WxtCE9Omo5l27n_mAG_.jpeg'
]);
@@ -40,6 +41,7 @@ describe('ImagePreview', () => {
document.body.style.overflow = 'hidden';
ImagePreview([
+ 'https://img.yzcdn.cn/upload_files/2017/03/15/FkubrzN7AgGwLlTeb1E89-T_ZjBg.png',
'https://img.yzcdn.cn/upload_files/2017/03/14/FmTPs0SeyQaAOSK1rRe1sL8RcwSY.jpeg',
'https://img.yzcdn.cn/upload_files/2017/03/15/FvexrWlG_WxtCE9Omo5l27n_mAG_.jpeg'
]);
diff --git a/test/unit/specs/steps.spec.js b/test/unit/specs/steps.spec.js
index 905971554..9416e8a21 100644
--- a/test/unit/specs/steps.spec.js
+++ b/test/unit/specs/steps.spec.js
@@ -21,8 +21,21 @@ describe('Steps', () => {
const finishStep = wrapper.find('.van-step')[0];
expect(finishStep.hasClass('van-step--finish')).to.be.true;
+ expect(finishStep.hasClass('van-step--horizontal')).to.be.true;
const proccessStep = wrapper.find('.van-step')[1];
expect(proccessStep.hasClass('van-step--process')).to.be.true;
});
+
+ it('create a vertical step', () => {
+ wrapper = mount(Steps, {
+ propsData: {
+ direction: 'vertical'
+ }
+ });
+
+ expect(wrapper.hasClass('van-steps')).to.be.true;
+ expect(wrapper.hasClass('van-steps--vertical')).to.be.true;
+ expect(wrapper.data().steps.length).to.equal(0);
+ });
});
diff --git a/test/unit/specs/tabs.spec.js b/test/unit/specs/tabs.spec.js
index 377ada337..eb6252a12 100644
--- a/test/unit/specs/tabs.spec.js
+++ b/test/unit/specs/tabs.spec.js
@@ -1,6 +1,7 @@
import Tabs from 'packages/tabs';
import { mount } from 'avoriaz';
import TabsTestComponent from '../components/tabs';
+import MoreTabsTestComponent from '../components/more-tabs';
describe('Tabs', () => {
let wrapper;
@@ -74,4 +75,75 @@ describe('Tabs', () => {
expect(wrapper.style.transitionDuration != '').to.be.true;
});
+
+ it('create a tabs greater then 4', (done) => {
+ wrapper = mount(MoreTabsTestComponent, {
+ attachToDocument: true
+ });
+
+ wrapper.vm.$nextTick(() => {
+ const nTab = wrapper.find('.van-tab')[4];
+ nTab.trigger('click');
+ done();
+ });
+ });
+
+ it('create a tabs greater then 4 then click last tab', (done) => {
+ wrapper = mount(MoreTabsTestComponent, {
+ attachToDocument: true,
+ propsData: {
+ active: 7
+ }
+ });
+
+ wrapper.vm.$nextTick(() => {
+ const nTab = wrapper.find('.van-tab')[6];
+ nTab.trigger('click');
+ done();
+ });
+ });
+
+ it('test swipe', (done) => {
+ wrapper = mount(MoreTabsTestComponent, {
+ attachToDocument: true
+ });
+
+ setTimeout(() => {
+ const nSwipe = wrapper.find('.van-tabs__swipe')[0];
+
+ const eventMouseObject = new window.Event('mousedown');
+ eventMouseObject.pageX = 200;
+ nSwipe.element.dispatchEvent(eventMouseObject);
+
+ const eventTouchObject = new window.Event('touchstart');
+ eventTouchObject.changedTouches = [{ pageX: 200 }];
+ nSwipe.element.dispatchEvent(eventTouchObject);
+ }, 500);
+
+ setTimeout(() => {
+ const nSwipe = wrapper.find('.van-tabs__swipe')[0];
+
+ const eventMouseMoveObject = new window.Event('mousemove');
+ eventMouseMoveObject.pageX = 0;
+ document.dispatchEvent(eventMouseMoveObject);
+
+ const eventObject = new window.Event('touchmove');
+ eventObject.changedTouches = [{ pageX: 0 }];
+ nSwipe.element.dispatchEvent(eventObject);
+
+ // 结束滑动
+ const eventMouseUpObject = new window.Event('mouseup');
+ document.dispatchEvent(eventMouseUpObject);
+ const eventEndObject = new window.Event('touchend');
+ eventEndObject.changedTouches = [{}];
+ nSwipe.element.dispatchEvent(eventEndObject);
+ }, 1000);
+
+ setTimeout(() => {
+ const nItem = wrapper.find('.van-tab')[0];
+ expect(nItem.hasClass('van-tab--active')).to.be.true;
+
+ done();
+ }, 1200);
+ });
});
diff --git a/test/unit/specs/tag.spec.js b/test/unit/specs/tag.spec.js
index c077e93ab..984beab2e 100644
--- a/test/unit/specs/tag.spec.js
+++ b/test/unit/specs/tag.spec.js
@@ -18,12 +18,4 @@ describe('Tag', () => {
}
})
});
-
- it('create with wrong typeProps', () => {
- wrapper = mount(Tag, {
- propsData: {
- type: 'wrong'
- }
- })
- });
});