Browse Source

Merge branch 'v2' of https://github.com/jdf2e/nutui into v2

unknown 7 years ago
parent
commit
e05215f901

+ 3 - 3
src/packages/actionsheet/actionsheet.vue

@@ -11,11 +11,11 @@
                 v-show="isVisible"
             >
                 <div class="nut-actionsheet-custom"  v-if="$slots.custom">
-                    <slot name="custom">{{custom}}</slot>
+                    <slot name="custom" v-html="custom"></slot>
                 </div>
                 <dl class="nut-actionsheet-modal" v-if="$slots.title || $slots.subTitle ">
-                    <dt class="nut-actionsheet-title"><slot name="title">{{title}}</slot></dt>
-                    <dd class="nut-actionsheet-sub-title"><slot name="sub-title">{{subTitle}}</slot></dd>
+                    <dt class="nut-actionsheet-title"><slot name="title" v-html="title"></slot></dt>
+                    <dd class="nut-actionsheet-sub-title"><slot name="sub-title" v-html="subTitle"></slot></dd>
                 </dl>
                 <ul class="nut-actionsheet-menu" >
                     <li class="nut-actionsheet-item" 

+ 1 - 1
src/packages/badge/badge.vue

@@ -15,7 +15,7 @@ export default {
   name: 'nut-badge',
   props: {
     value: {
-      type: String
+      type: [String,Number]
     },
     max: {
       type: Number,

+ 105 - 0
src/packages/button/__test__/button.spec.js

@@ -0,0 +1,105 @@
+import { shallowMount, mount } from '@vue/test-utils'
+import Button from '../button.vue';
+import Vue from 'vue';
+
+describe('Button.vue', () => {
+    it('设置type', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            },
+            propsData:{
+                type: 'light'
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.attributes('class')).toContain('light');
+        })
+    });
+    it('设置slot', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('去结算');
+        })
+    });
+    it('设置disabled', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            },
+            propsData:{
+                disabled: true
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('去结算');
+            expect(wrapper.attributes('disabled')).toContain('disabled');
+        })
+    });
+    it('设置shape', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            },
+            propsData:{
+                shape: 'circle'
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('去结算');
+            expect(wrapper.attributes('class')).toContain('circle');
+        })
+    });
+    it('设置small', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            },
+            propsData:{
+                small: true
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('去结算');
+            expect(wrapper.attributes('class')).toContain('small');
+        })
+    });
+    it('设置icon', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '全部100万'
+            },
+            propsData:{
+                type: 'actived',
+                icon: 'tick'
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('全部100万');
+            expect(wrapper.contains('.txt-icon')).toBe(true);
+            expect(wrapper.find('.txt-icon').attributes('type')).toBe('tick');            
+            expect(wrapper.find('span').text()).toBe('全部100万');
+        })
+    });
+    it('设置color', () => {
+        let wrapper = shallowMount(Button, {
+            slots: {
+                default: '去结算'
+            },
+            propsData:{
+                icon: 'tick',
+                color: '#fff'
+            }
+        });
+        return Vue.nextTick().then(function () {
+            expect(wrapper.text()).toBe('去结算');
+            expect(wrapper.find('span').attributes('style')).toBe('color: rgb(255, 255, 255);');
+            expect(wrapper.find('.txt-icon').attributes('color')).toBe('#fff');
+        })
+    });
+
+});

+ 6 - 6
src/packages/buttongroup/demo.vue

@@ -1,23 +1,23 @@
 <template>
     <div>
       <h4>常规按钮组</h4>
-      <nut-button-group>
+      <nut-buttongroup>
         <nut-button type="light">重置</nut-button>
         <nut-button>确定</nut-button>
-      </nut-button-group>
+      </nut-buttongroup>
     <h4>圆角按钮组</h4>
-    <nut-button-group shape="circle">
+    <nut-buttongroup shape="circle">
       <nut-button type="light">重置</nut-button>
       <nut-button>确定</nut-button>
-    </nut-button-group>
+    </nut-buttongroup>
     <h4>页面底部功能,配合Badge使用</h4>
-      <nut-button-group type="menu">
+      <nut-buttongroup type="menu">
         <nut-button type="light" icon="action" color="#000">关于</nut-button>
         <nut-button type="light" icon="more" color="#000">更多</nut-button>
         <nut-button type="light" icon="search" color="#000">关闭</nut-button>
         <nut-badge value="2" top="0.5rem" right="2rem"><nut-button type="light" icon="trolley" color="#f00">购物车</nut-button></nut-badge>      
         <nut-button type="light" icon="tick" color="#000">成功</nut-button>
-      </nut-button-group>
+      </nut-buttongroup>
     </div>
 </template>
 

+ 2 - 2
src/packages/calendar/calendar.scss

@@ -36,10 +36,10 @@
         line-height: 40px;
     }
     .nut-calendar-confirm-btn{
-        right: 0;
+        left: 0;
     }
     .nut-calendar-cancel-btn{
-        left: 0;
+        right: 0;
     }
     .nut-calendar-title{
         margin: 0 60px;

+ 3 - 3
src/packages/calendar/calendar.vue

@@ -2,7 +2,7 @@
     <transition :name="animation">
         <div class="nut-calendar" v-show="isVisible">
             <div class="nut-calendar-control">
-                <span class="nut-calendar-confirm-btn" @click="confirm" v-if="(type == 'change' && currDate && currDate.length == 2) || type != 'change'">{{nutTranslate('lang.okBtnTxt')}}</span>
+                <span class="nut-calendar-confirm-btn" @click="confirm" v-if="(type == 'range' && currDate && currDate.length == 2) || type != 'range'">{{nutTranslate('lang.okBtnTxt')}}</span>
                 <span class="nut-calendar-cancel-btn"  @click="closeActionSheet">{{nutTranslate('lang.cancelText')}}</span>
                 <div class="nut-calendar-title">{{title || nutTranslate('lang.calendar.title')}}</div>
                 <div class="nut-calendar-week">
@@ -44,7 +44,7 @@ export default {
         },
         animation: {
             type: String,
-            default: 'nutSlideRight'
+            default: 'nutSlideUp'
         },
         isAutoBackFill: {
             type: Boolean,
@@ -162,7 +162,7 @@ export default {
                     this.monthsData.push(monthInfo);
                 } else {
                     this.unLoadNext = true;
-                }
+                }   
             } else {
                 if (!this.startData || Utils.compareDate(`${this.startData[0]}-${this.startData[1]}-01`,`${curData[0]}-${curData[1]}-${curData[2]}`)) {
                     this.monthsData.unshift(monthInfo);

+ 1 - 1
src/packages/cell/index.js

@@ -5,4 +5,4 @@ Cell.install = function(Vue) {
   Vue.component(Cell.name, Cell);
 };
 
-export default Cell
+export default Cell;

+ 2 - 2
src/packages/col/index.js

@@ -3,6 +3,6 @@ import './col.scss';
 
 Col.install = function(Vue) {
     Vue.component(Col.name, Col);
-}
+};
 
-export default Col
+export default Col;

+ 2 - 1
src/packages/flex/index.js

@@ -4,6 +4,7 @@ import './flex.scss';
 Row.install = function(Vue) {
   Vue.component(Flex.name, Row);
 };
+
 Col.install = function(Vue) {
   Vue.component(Flex.name, Col);
 };
@@ -11,4 +12,4 @@ Col.install = function(Vue) {
 export default {
 	Row,
 	Col
-}
+};

+ 1 - 1
src/packages/noticebar/demo.vue

@@ -5,7 +5,7 @@
       <h4>禁用滚动</h4>
       <nut-noticebar text="华为畅享9新品即将上市,活动期间0元预约可参与抽奖,赢HUAWEI WATCH等好礼,更多产品信息请持续关注!" :scrollable="false"></nut-noticebar>
       <h4>通告栏模式--关闭模式</h4>
-      <nut-noticebar mode="true" @click="hello">华为畅享9新品即将上市,活动期间0元预约可参与抽奖,赢HUAWEI WATCH等好礼,更多产品信息请持续关注!</nut-noticebar>
+      <nut-noticebar :mode="true" @click="hello">华为畅享9新品即将上市,活动期间0元预约可参与抽奖,赢HUAWEI WATCH等好礼,更多产品信息请持续关注!</nut-noticebar>
       <h4>通告栏模式--链接模式</h4>
       <nut-noticebar
         text="华为畅享9新品即将上市,活动期间0元预约可参与抽奖,赢HUAWEI WATCH等好礼,更多产品信息请持续关注!"

+ 1 - 1
src/packages/progress/progress.vue

@@ -11,7 +11,7 @@
                      {{percentage}}%
                 </template>
                 <template v-else-if="status=='success' || 'wrong'">
-                    <icon :class="statusIcon"></icon>
+                    <i :class="statusIcon"></i>
                 </template>
             </slot>
         </div>

+ 3 - 3
src/packages/range/range.vue

@@ -10,7 +10,7 @@
 								background: mainColor
 							}">
 						</div>
-            <Movebar 
+            <nut-range-bar 
                 :initLeft="initLeft1" 
                 @getPos="getPosLeft"
                 :showLabelAlways="showLabelAlways"
@@ -18,7 +18,7 @@
                 :current="currentLeft"
                 :ani.sync="ani"
 								:mainColor="mainColor"/>
-            <Movebar 
+            <nut-range-bar 
                 :initLeft="initLeft2" 
                 @getPos="getPosRight"
                 :showLabelAlways="showLabelAlways"
@@ -51,7 +51,7 @@ function toRGBA(c, opacity) {
 export default {
   name: "nut-range",
   components: {
-    Movebar
+    [Movebar.name]: Movebar
   },
   props: {
     rangeValues: {

File diff suppressed because it is too large
+ 1 - 0
src/packages/rating/rating.scss


+ 2 - 2
src/packages/stepper/doc.md

@@ -56,10 +56,10 @@
 
 | 字段 | 说明 | 类型 | 默认值 
 | ----- | ----- | ----- | ----- 
-| init | 初始值 | Number | 1
+| init | 初始值 | Number, String | 1
 | min | 最小值 | Number, String | 0
 | max | 最大值 | Number, String | Infinity
-| step | 步长 | Number | 1
+| step | 步长 | Number, String | 1
 | readonly | 是否只读 | Boolean | false
 | transition | 是否需要过渡效果 | Boolean | true
 | simple | 是否显示简单版 | Boolean | true

+ 1 - 1
src/packages/stepper/stepper.vue

@@ -60,7 +60,7 @@ export default {
             default: Infinity,
         },
         step: {
-            type: Number,
+            type: [Number, String],
             default: 1
         },
         readonly: {

+ 0 - 2
src/packages/swiper/swiper.vue

@@ -305,9 +305,7 @@ export default {
             let requestAniFrame = this._requestAniFrame();
             let imgLazyLoadEl;
             requestAniFrame(()=>{
-                console.log(232323);
                 imgLazyLoadEl = this.swiperWrap.querySelectorAll('.nut-img-lazyload');
-                console.log(imgLazyLoadEl);
                 if(type == 1){
                     imgLazyLoadEl = this.slideEls[this.currentPage - 1].querySelectorAll('.nut-img-lazyload');
                 }