From ffa3fddfae124dcd0de2b849ed072b9c799cf653 Mon Sep 17 00:00:00 2001 From: neverland <chenjiahan@buaa.edu.cn> Date: Thu, 16 Nov 2017 03:12:13 -0600 Subject: [PATCH] [bugfix] remove unnecessary props (#323) * fix: Tabbar icon line-height * [new feature] progress add showPivot prop * [new feature] TabItem support vue-router * [new feature] update document header style * [Doc] add toast english ducoment * [bugfix] Search box-sizing wrong * [Doc] update vant-demo respo * [Doc] translate theme & demo pages * [Doc] add Internationalization document * [bugfix] remove unnecessary props --- docs/demos/views/field.vue | 2 +- docs/demos/views/toast.vue | 4 +- docs/markdown/en-US/layout.md | 2 - docs/markdown/zh-CN/layout.md | 2 - package.json | 2 +- packages/actionsheet/index.vue | 18 +++++--- packages/address-edit/theme.md | 55 ------------------------ packages/area/index.vue | 31 ++++++------- packages/badge/index.vue | 17 ++------ packages/button/index.js | 9 +--- packages/card/index.vue | 2 +- packages/cell-swipe/index.vue | 8 ++-- packages/checkbox/index.vue | 5 +-- packages/col/index.vue | 24 ++++------- packages/contact-card/index.vue | 8 +--- packages/datetime-picker/index.vue | 9 +--- packages/dialog/dialog.vue | 14 ++---- packages/field/index.vue | 7 +-- packages/goods-action-big-btn/index.vue | 7 +-- packages/goods-action-mini-btn/index.vue | 10 +---- packages/icon/index.vue | 6 +-- packages/image-preview/image-preview.vue | 3 -- packages/loading/index.vue | 11 ++--- packages/notice-bar/index.vue | 10 +---- packages/panel/index.vue | 6 +-- packages/radio/index.vue | 2 +- packages/row/index.vue | 6 +-- packages/search/index.vue | 5 +-- packages/sku/containers/SkuContainer.vue | 5 +-- packages/step/index.vue | 23 ++++------ packages/steps/index.vue | 20 +++------ packages/submit-bar/index.vue | 2 +- packages/swipe/index.vue | 5 +-- packages/switch-cell/index.vue | 2 +- packages/switch/index.vue | 2 +- packages/tag/index.vue | 9 +--- packages/toast/index.js | 2 +- packages/toast/toast.vue | 19 ++------ packages/uploader/index.vue | 8 +--- packages/vant-css/src/tag.css | 32 +++++--------- test/unit/specs/deep-assign.spec.js | 2 +- yarn.lock | 6 +-- 42 files changed, 116 insertions(+), 306 deletions(-) delete mode 100644 packages/address-edit/theme.md diff --git a/docs/demos/views/field.vue b/docs/demos/views/field.vue index f0c78ea46..87057b8f1 100644 --- a/docs/demos/views/field.vue +++ b/docs/demos/views/field.vue @@ -14,7 +14,7 @@ icon="clear" :placeholder="$t('usernamePlaceholder')" required - @clickIcon="username = ''" + @click-icon="username = ''" > </van-field> diff --git a/docs/demos/views/toast.vue b/docs/demos/views/toast.vue index 61d58208f..236cb98f8 100644 --- a/docs/demos/views/toast.vue +++ b/docs/demos/views/toast.vue @@ -67,14 +67,14 @@ export default { const toast = Toast.loading({ duration: 0, forbidClick: true, - message: this.$t('text4')(3) + message: this.$t('text4', 3) }); let second = 3; const timer = setInterval(() => { second--; if (second) { - toast.message = this.$t('text4')(second); + toast.message = this.$t('text4', second); } else { clearInterval(timer); Toast.clear(); diff --git a/docs/markdown/en-US/layout.md b/docs/markdown/en-US/layout.md index 0a65a42f4..9ff9c2b05 100644 --- a/docs/markdown/en-US/layout.md +++ b/docs/markdown/en-US/layout.md @@ -56,11 +56,9 @@ Set grid spacing using `gutter` attribute. The default value is 0 | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| | gutter | grid spacing(px) | `String | Number` | - | - | -| prefix | className prefix | `String` | `van` | - | #### Column | Attribute | Description | Type | Default | Accepted Values | |-----------|-----------|-----------|-------------|-------------| | span | number of column the grid spans | `String | Number` | - | - | | offset | number of spacing on the left side of the grid | `String | Number` | - | - | -| prefix | className prefix | `String` | `van` | - | diff --git a/docs/markdown/zh-CN/layout.md b/docs/markdown/zh-CN/layout.md index c9a01eb4a..de7a665d2 100644 --- a/docs/markdown/zh-CN/layout.md +++ b/docs/markdown/zh-CN/layout.md @@ -52,11 +52,9 @@ Layout 组件提供了`24列栅格`,通过在`Col`上添加`span`属性设置 | 参数 | 说明 | 类型 | 默认值 | 可选值 | |-----------|-----------|-----------|-------------|-------------| | gutter | 列元素之间的间距(单位为px) | `String | Number` | - | - | -| prefix | className 前缀 | `String` | `van` | - | #### Column | 参数 | 说明 | 类型 | 默认值 | 可选值 | |-----------|-----------|-----------|-------------|-------------| | span | 列元素宽度 | `String | Number` | - | - | | offset | 列元素偏移距离 | `String | Number` | - | - | -| prefix | className 前缀 | `String` | `van` | - | diff --git a/package.json b/package.json index 81e4253f3..d64c2611e 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "style-loader": "^0.19.0", "uppercamelcase": "^3.0.0", "url-loader": "^0.6.2", - "vant-doc": "0.3.17", + "vant-doc": "0.3.18", "vue": "^2.5.3", "vue-loader": "^13.5.0", "vue-markdown-loader": "^2.2.3", diff --git a/packages/actionsheet/index.vue b/packages/actionsheet/index.vue index dff11f5da..753bfb55a 100644 --- a/packages/actionsheet/index.vue +++ b/packages/actionsheet/index.vue @@ -10,7 +10,8 @@ v-for="(item, index) in actions" :key="index" :class="['van-actionsheet__item', 'van-hairline--top', item.className, { 'van-actionsheet__item--loading': item.loading }]" - @click.stop="onClickItem(item)"> + @click.stop="onClickItem(item)" + > <template v-if="!item.loading"> <span class="van-actionsheet__name">{{ item.name }}</span> <span class="van-actionsheet__subname" v-if="item.subname">{{ item.subname }}</span> @@ -18,8 +19,13 @@ <van-loading v-else class="van-actionsheet__loading" type="circle" color="black" /> </li> </ul> - <div class="van-actionsheet__item van-actionsheet__cancel van-hairline--top" @click.stop="$emit('input', false)" v-if="cancelText">{{ cancelText }}</div> - <div class="van-actionsheet__content" v-else> + <div + v-if="cancelText" + v-text="cancelText" + class="van-actionsheet__item van-actionsheet__cancel van-hairline--top" + @click.stop="$emit('input', false)" + /> + <div v-else class="van-actionsheet__content"> <slot></slot> </div> </div> @@ -43,18 +49,16 @@ export default { props: { value: Boolean, + title: String, + cancelText: String, actions: { type: Array, default: () => [] }, - title: String, - cancelText: String, overlay: { - type: Boolean, default: true }, closeOnClickOverlay: { - type: Boolean, default: true } }, diff --git a/packages/address-edit/theme.md b/packages/address-edit/theme.md deleted file mode 100644 index 73cfeec5a..000000000 --- a/packages/address-edit/theme.md +++ /dev/null @@ -1,55 +0,0 @@ -## 定制主题 - -`Vant`提供了一套默认主题,CSS 命名采用 BEM 的风格,方便使用者覆盖样式。如果你想完全替换主题色或者其他样式,可以使用下面的方法: - -### 方案一. PostCSS 插件 -在项目中直接引入组件对应的 postcss 源代码,并通过 postcss 插件 [postcss-theme-variables](https://www.npmjs.com/package/postcss-theme-variables) 替换颜色变量,步骤如下: - -```javascript -// 引入基础样式 -import 'vant/packages/vant-css/src/base.css'; - -// 引入组价对应的样式 -import 'vant/packages/vant-css/src/button.css'; -import 'vant/packages/vant-css/src/checkbox.css'; -``` - -接着在 postcss.config.js 中引入所需的 postcss 插件,并根据项目需求配置颜色变量,所有可用的颜色变量请参考 [配置文件](https://github.com/youzan/vant/blob/dev/packages/vant-css/src/common/var.css) - -```javascript -module.exports = { - plugins: [ - require('postcss-easy-import')({ - extensions: ['pcss', 'css'] - }), - require('postcss-theme-variables')({ - vars: { - red: '#F60', - gray: '#CCC', - blue: '#03A9F4' - }, - prefix: '$' - }), - require('precss')(), - require('postcss-calc')(), - require('autoprefixer')({ - browsers: ['Android >= 4.0', 'iOS >= 7'] - }) - ] -}; -``` - -### 方案二. 本地构建 -可以通过在本地构建 vant-css 的方式生成所需的主题 - -```bash -# 克隆仓库 -git clone git@github.com:youzan/vant.git -cd packages/vant-css -``` - -在本地 vant-css 仓库中,修改 src/common/var.css 中的颜色变量,然后执行以下构建命令,即可生成对应的样式文件 -```bash -npm run build -``` - diff --git a/packages/area/index.vue b/packages/area/index.vue index a58731af3..a6fda18eb 100644 --- a/packages/area/index.vue +++ b/packages/area/index.vue @@ -1,6 +1,14 @@ <template> <div class="van-area"> - <van-picker ref="picker" :columns="areaColumns" value-key="name" show-toolbar @change="handleAreaChange" @confirm="handleAreaConfirm" @cancel="handleAreaCancel"></van-picker> + <van-picker + ref="picker" + showToolbar + valueKey="name" + :columns="areaColumns" + @change="onChange" + @confirm="$emit('confirm', $event)" + @cancel="$emit('cancel')" + /> </div> </template> @@ -80,12 +88,7 @@ export default { }, methods: { - /** - * 根据省市县类型和对应的`code`获取对应列表 - * - * @param {string} type 省市县类型 - * @param {string} code 对应code - */ + // 根据省市县类型和对应的`code`获取对应列表 computedAreaList(type, code) { const result = []; const curAreaList = this.areaList; @@ -107,9 +110,7 @@ export default { return result; }, - /** - * 获取对应省市县在列表中的索引 - */ + // 获取对应省市县在列表中的索引 getAreaIndex(type, code) { const compareNum = type === PROVINCE_TYPE ? 2 @@ -125,7 +126,7 @@ export default { return 0; }, - handleAreaChange(picker, values, index) { + onChange(picker, values, index) { const code = values[index].code; // 处理省变化 if (index === 0) { @@ -143,14 +144,6 @@ export default { [DEFAULT_COUNTY].concat(this.computedAreaList(COUNTY_TYPE, code.slice(0, 4))) ); } - }, - - handleAreaConfirm(values) { - this.$emit('confirm', values); - }, - - handleAreaCancel() { - this.$emit('cancel'); } } }; diff --git a/packages/badge/index.vue b/packages/badge/index.vue index 801b19e30..57ec9f34e 100644 --- a/packages/badge/index.vue +++ b/packages/badge/index.vue @@ -10,17 +10,9 @@ export default { name: 'van-badge', props: { - title: { - type: String, - required: true - }, - url: { - type: String, - default: 'javascript:;' - }, - info: { - type: String - } + url: String, + info: String, + title: String }, beforeCreate() { @@ -29,8 +21,7 @@ export default { computed: { isSelect() { - const parent = this.$parent; - return parent.badges.indexOf(this) === parent.activeKey; + return this.$parent.badges.indexOf(this) === this.$parent.activeKey; } }, diff --git a/packages/button/index.js b/packages/button/index.js index 1961b6e9f..b4a352297 100644 --- a/packages/button/index.js +++ b/packages/button/index.js @@ -1,8 +1,5 @@ import Loading from '../loading'; -const ALLOWED_SIZE = ['mini', 'small', 'normal', 'large']; -const ALLOWED_TYPE = ['default', 'danger', 'primary']; - export default { name: 'van-button', @@ -22,13 +19,11 @@ export default { }, type: { type: String, - default: 'default', - validator: value => ALLOWED_TYPE.indexOf(value) > -1 + default: 'default' }, size: { type: String, - default: 'normal', - validator: value => ALLOWED_SIZE.indexOf(value) > -1 + default: 'normal' } }, diff --git a/packages/card/index.vue b/packages/card/index.vue index b672be415..a89278613 100644 --- a/packages/card/index.vue +++ b/packages/card/index.vue @@ -34,8 +34,8 @@ export default { thumb: String, title: String, desc: String, - num: [Number, String], centered: Boolean, + num: [Number, String], price: [Number, String] } }; diff --git a/packages/cell-swipe/index.vue b/packages/cell-swipe/index.vue index 3555c55f6..be6f14fb5 100644 --- a/packages/cell-swipe/index.vue +++ b/packages/cell-swipe/index.vue @@ -82,8 +82,8 @@ export default { }, startDrag(event) { - this.startX = event.changedTouches[0].pageX; - this.startY = event.changedTouches[0].pageY; + this.startX = event.touches[0].pageX; + this.startY = event.touches[0].pageY; }, onDrag(event) { @@ -93,8 +93,8 @@ export default { return; } - const offsetTop = event.changedTouches[0].pageY - this.startY; - const offsetLeft = event.changedTouches[0].pageX - this.startX; + const offsetTop = event.touches[0].pageY - this.startY; + const offsetLeft = event.touches[0].pageX - this.startX; if ((offsetLeft < 0 && -offsetLeft > this.rightWidth) || (offsetLeft > 0 && offsetLeft > this.leftWidth) || (offsetLeft > 0 && !this.leftWidth) || diff --git a/packages/checkbox/index.vue b/packages/checkbox/index.vue index afa02367d..a0349490a 100644 --- a/packages/checkbox/index.vue +++ b/packages/checkbox/index.vue @@ -101,10 +101,9 @@ export default { methods: { onClickLabel() { - if (this.isDisabled) { - return; + if (!this.isDisabled) { + this.currentValue = !this.currentValue; } - this.currentValue = !this.currentValue; } } }; diff --git a/packages/col/index.vue b/packages/col/index.vue index 4f1ed8cfe..ca7360dc3 100644 --- a/packages/col/index.vue +++ b/packages/col/index.vue @@ -1,13 +1,11 @@ <template> <div - :class="[ - `${prefix}-col`, - { - [`${prefix}-col-${span}`]: span, - [`${prefix}-col-offset-${offset}`]: offset, - } - ]" - :style="style"> + :class="[`van-col`, { + [`van-col-${span}`]: span, + [`van-col-offset-${offset}`]: offset, + }]" + :style="style" + > <slot></slot> </div> </template> @@ -18,11 +16,7 @@ export default { props: { span: [Number, String], - offset: [Number, String], - prefix: { - type: String, - default: 'van' - } + offset: [Number, String] }, computed: { @@ -31,9 +25,7 @@ export default { }, style() { const padding = `${this.gutter / 2}px`; - return this.gutter - ? { paddingLeft: padding, paddingRight: padding } - : {}; + return this.gutter ? { paddingLeft: padding, paddingRight: padding } : {}; } } }; diff --git a/packages/contact-card/index.vue b/packages/contact-card/index.vue index aaa4bf573..e8cfdda8e 100644 --- a/packages/contact-card/index.vue +++ b/packages/contact-card/index.vue @@ -31,16 +31,12 @@ export default { }, props: { + tel: String, + name: String, addText: String, type: { type: String, default: 'add' - }, - name: { - type: String - }, - tel: { - type: String } } }; diff --git a/packages/datetime-picker/index.vue b/packages/datetime-picker/index.vue index b0fc50386..18887f69e 100644 --- a/packages/datetime-picker/index.vue +++ b/packages/datetime-picker/index.vue @@ -13,8 +13,6 @@ <script> import Picker from '../picker'; -const allowedType = ['time', 'date', 'datetime']; - export default { name: 'van-datetime-picker', @@ -25,10 +23,7 @@ export default { props: { type: { type: String, - default: 'datetime', - validator(value) { - return allowedType.indexOf(value) > -1; - } + default: 'datetime' }, format: { type: String, @@ -58,7 +53,7 @@ export default { type: Number, default: 23 }, - value: null + value: {} }, data() { diff --git a/packages/dialog/dialog.vue b/packages/dialog/dialog.vue index 9c85b75ee..2900f702a 100644 --- a/packages/dialog/dialog.vue +++ b/packages/dialog/dialog.vue @@ -44,16 +44,11 @@ export default { mixins: [Popup, i18n], props: { + title: String, + message: String, + callback: Function, confirmButtonText: String, cancelButtonText: String, - title: { - type: String, - default: '' - }, - message: { - type: String, - default: '' - }, showConfirmButton: { type: Boolean, default: true @@ -62,9 +57,6 @@ export default { type: Boolean, default: false }, - callback: { - type: Function - }, overlay: { default: true }, diff --git a/packages/field/index.vue b/packages/field/index.vue index 2f59b923d..f48d672b1 100644 --- a/packages/field/index.vue +++ b/packages/field/index.vue @@ -49,8 +49,6 @@ import Cell from '../cell'; import Icon from '../icon'; -const VALID_TYPES = ['text', 'number', 'email', 'url', 'tel', 'date', 'time', 'datetime', 'password', 'textarea']; - export default { name: 'van-field', @@ -62,15 +60,14 @@ export default { props: { type: { type: String, - default: 'text', - validator: value => VALID_TYPES.indexOf(value) > -1 + default: 'text' }, value: {}, icon: String, label: String, error: Boolean, - required: Boolean, border: Boolean, + required: Boolean, autosize: Boolean, onIconClick: { type: Function, diff --git a/packages/goods-action-big-btn/index.vue b/packages/goods-action-big-btn/index.vue index 58bf06b07..86ceb7373 100644 --- a/packages/goods-action-big-btn/index.vue +++ b/packages/goods-action-big-btn/index.vue @@ -22,11 +22,8 @@ export default { }, props: { - primary: Boolean, - url: { - type: String, - default: 'javascript:;' - } + url: String, + primary: Boolean } }; </script> diff --git a/packages/goods-action-mini-btn/index.vue b/packages/goods-action-mini-btn/index.vue index bc7ed9b0c..f48d1a46a 100644 --- a/packages/goods-action-mini-btn/index.vue +++ b/packages/goods-action-mini-btn/index.vue @@ -16,15 +16,9 @@ export default { }, props: { + url: String, icon: String, - iconClass: { - type: String, - default: '' - }, - url: { - type: String, - default: 'javascript:;' - } + iconClass: String } }; </script> diff --git a/packages/icon/index.vue b/packages/icon/index.vue index 7e3b89521..0fe1b857f 100644 --- a/packages/icon/index.vue +++ b/packages/icon/index.vue @@ -7,12 +7,8 @@ <script> export default { name: 'van-icon', - props: { - name: { - type: String, - required: true - } + name: String } }; </script> diff --git a/packages/image-preview/image-preview.vue b/packages/image-preview/image-preview.vue index 46434e058..84ecdb22e 100644 --- a/packages/image-preview/image-preview.vue +++ b/packages/image-preview/image-preview.vue @@ -34,9 +34,6 @@ export default { overlay: { default: true }, - lockOnScroll: { - default: true - }, closeOnClickOverlay: { default: true } diff --git a/packages/loading/index.vue b/packages/loading/index.vue index b263948f6..ea1857cbf 100644 --- a/packages/loading/index.vue +++ b/packages/loading/index.vue @@ -1,28 +1,23 @@ <template> <div :class="['van-loading', 'van-loading--' + type, 'van-loading--' + color]"> <span :class="['van-loading__spinner', 'van-loading__spinner--' + type, 'van-loading__spinner--' + color]"> - <i v-if="type === 'spinner'" v-for="item in 12"></i> + <i v-if="type === 'spinner'" v-for="item in 12" /> </span> </div> </template> <script> -const VALID_TYPES = ['gradient-circle', 'circle', 'spinner']; -const VALID_COLORS = ['black', 'white']; - export default { name: 'van-loading', props: { type: { type: String, - default: 'gradient-circle', - validator: value => VALID_TYPES.indexOf(value) > -1 + default: 'gradient-circle' }, color: { type: String, - default: 'black', - validator: value => VALID_COLORS.indexOf(value) > -1 + default: 'black' } } }; diff --git a/packages/notice-bar/index.vue b/packages/notice-bar/index.vue index db709a718..e9c3199b7 100644 --- a/packages/notice-bar/index.vue +++ b/packages/notice-bar/index.vue @@ -25,8 +25,6 @@ <script> import Icon from '../icon'; -const NOTICE_BAR_MODE = ['', 'closeable', 'link']; - export default { name: 'van-notice-bar', @@ -36,14 +34,10 @@ export default { props: { text: String, - leftIcon: String, + mode: String, color: String, + leftIcon: String, background: String, - mode: { - type: String, - default: '', - validator: val => NOTICE_BAR_MODE.indexOf(val) !== -1 - }, delay: { type: [String, Number], default: 1 diff --git a/packages/panel/index.vue b/packages/panel/index.vue index 4ccdabd8e..08977da36 100644 --- a/packages/panel/index.vue +++ b/packages/panel/index.vue @@ -2,9 +2,9 @@ <div class="van-panel van-hairline--top-bottom"> <div class="van-panel__header van-hairline--bottom"> <slot name="header"> - <div class="van-panel__title" v-text="title"></div> - <span class="van-panel__desc" v-if="desc" v-text="desc"></span> - <span class="van-panel__status" v-if="status" v-text="status"></span> + <div class="van-panel__title" v-text="title" /> + <span class="van-panel__desc" v-if="desc" v-text="desc" /> + <span class="van-panel__status" v-if="status" v-text="status" /> </slot> </div> <div class="van-panel__content"> diff --git a/packages/radio/index.vue b/packages/radio/index.vue index 3e0fa987b..764605c83 100644 --- a/packages/radio/index.vue +++ b/packages/radio/index.vue @@ -33,8 +33,8 @@ export default { mixins: [findParent], props: { - disabled: Boolean, value: {}, + disabled: Boolean, name: [String, Number] }, diff --git a/packages/row/index.vue b/packages/row/index.vue index 0e4a6ae69..747bf6016 100644 --- a/packages/row/index.vue +++ b/packages/row/index.vue @@ -1,5 +1,5 @@ <template> - <div :class="`${prefix}-row`" :style="style"> + <div class="van-row" :style="style"> <slot></slot> </div> </template> @@ -9,10 +9,6 @@ export default { name: 'van-row', props: { - prefix: { - type: String, - default: 'van' - }, gutter: { type: [Number, String], default: 0 diff --git a/packages/search/index.vue b/packages/search/index.vue index 0c11b0ae9..0c9e93844 100644 --- a/packages/search/index.vue +++ b/packages/search/index.vue @@ -41,11 +41,8 @@ export default { props: { value: String, + showAction: Boolean, placeholder: String, - showAction: { - type: Boolean, - default: false - }, background: { type: String, default: '#f2f2f2' diff --git a/packages/sku/containers/SkuContainer.vue b/packages/sku/containers/SkuContainer.vue index d45e1693e..550403062 100644 --- a/packages/sku/containers/SkuContainer.vue +++ b/packages/sku/containers/SkuContainer.vue @@ -116,10 +116,7 @@ export default { type: Number, default: 0 }, - hideStock: { - type: Boolean, - default: false - }, + hideStock: Boolean, showAddCartBtn: { type: Boolean, default: true diff --git a/packages/step/index.vue b/packages/step/index.vue index 62762dca1..3e1577d18 100644 --- a/packages/step/index.vue +++ b/packages/step/index.vue @@ -1,13 +1,13 @@ <template> - <div class="van-step van-hairline" :class="stepClass"> + <div class="van-step van-hairline" :class="[`van-step--${$parent.direction}`, { [`van-step--${status}`]: status }]"> <div class="van-step__circle-container"> - <i class="van-step__circle" v-if="status !== 'process'"></i> - <i class="van-icon van-icon-checked" :style="{ color: $parent.activeColor }" v-else></i> + <i class="van-step__circle" v-if="status !== 'process'" /> + <i class="van-icon van-icon-checked" :style="{ color: $parent.activeColor }" v-else /> </div> <div class="van-step__title" :style="titleStyle"> <slot></slot> </div> - <div class="van-step__line"></div> + <div class="van-step__line" /> </div> </template> @@ -30,18 +30,11 @@ export default { return 'process'; } }, - stepClass() { - const status = this.status; - const statusClass = status ? 'van-step--' + status : ''; - const directionClass = `van-step--${this.$parent.direction}`; - return [directionClass, statusClass]; - }, + titleStyle() { - if (this.status === 'process') { - return { - color: this.$parent.activeColor - }; - } + return this.status === 'process' ? { + color: this.$parent.activeColor + } : {}; } } }; diff --git a/packages/steps/index.vue b/packages/steps/index.vue index 9c01f7e84..5f8668190 100644 --- a/packages/steps/index.vue +++ b/packages/steps/index.vue @@ -3,21 +3,18 @@ <div class="van-steps__status" v-if="title || description"> <div class="van-steps__icon" v-if="icon || $slots.icon"> <slot name="icon"> - <van-icon :name="icon" :class="iconClass"></van-icon> + <van-icon :name="icon" :class="iconClass" /> </slot> </div> <div class="van-steps__message"> <div class="van-steps__message-wrapper"> - <div class="van-steps__title" v-text="title"></div> - <div class="van-steps__desc" v-text="description"></div> + <div class="van-steps__title" v-text="title" /> + <div class="van-steps__desc" v-text="description" /> </div> </div> - <slot name="message-extra"> - </slot> + <slot name="message-extra" /> </div> - <div class="van-steps__items" :class="{ - 'van-steps__items--alone': !title && !description - }"> + <div class="van-steps__items" :class="{ 'van-steps__items--alone': !title && !description }"> <slot></slot> </div> </div> @@ -34,13 +31,10 @@ export default { }, props: { - active: Number, icon: String, - iconClass: { - type: String, - default: '' - }, title: String, + active: Number, + iconClass: String, description: String, direction: { type: String, diff --git a/packages/submit-bar/index.vue b/packages/submit-bar/index.vue index f236cbfd1..670390fb8 100644 --- a/packages/submit-bar/index.vue +++ b/packages/submit-bar/index.vue @@ -1,7 +1,7 @@ <template> <div class="van-submit-bar"> <div class="van-submit-bar__tip" v-show="tip || $slots.tip"> - {{ tip }}<slot name="tip"></slot> + {{ tip }}<slot name="tip" /> </div> <div class="van-submit-bar__bar"> <div class="van-submit-bar__price"> diff --git a/packages/swipe/index.vue b/packages/swipe/index.vue index 760887a86..f1da7718f 100644 --- a/packages/swipe/index.vue +++ b/packages/swipe/index.vue @@ -12,10 +12,7 @@ > <slot></slot> </div> - <div - v-else - class="van-swipe__track" - > + <div v-else class="van-swipe__track"> <slot></slot> </div> <div class="van-swipe__indicators" v-if="showIndicators && count > 1"> diff --git a/packages/switch-cell/index.vue b/packages/switch-cell/index.vue index 911d33da5..52bb2514b 100644 --- a/packages/switch-cell/index.vue +++ b/packages/switch-cell/index.vue @@ -1,6 +1,6 @@ <template> <van-cell :title="title" class="van-switch-cell"> - <van-switch :value="value" @input="$emit('input', $event)" :disabled="disabled" :loading="loading" /> + <van-switch v-bind="$props" @input="$emit('input', $event)" /> </van-cell> </template> diff --git a/packages/switch/index.vue b/packages/switch/index.vue index 378dd9228..d007f6299 100644 --- a/packages/switch/index.vue +++ b/packages/switch/index.vue @@ -3,7 +3,7 @@ <div class="van-switch__node van-hairline-surround"> <van-loading v-if="loading" class="van-switch__loading" /> </div> - <div class="van-switch__bg"></div> + <div class="van-switch__bg" /> </div> </template> diff --git a/packages/tag/index.vue b/packages/tag/index.vue index 4fcdc1fa1..6f35a890f 100644 --- a/packages/tag/index.vue +++ b/packages/tag/index.vue @@ -1,19 +1,14 @@ <template> - <span :class="['van-tag', 'van-hairline--surround', { [`van-tag--${type}`]: type, 'is-plain': plain, 'is-mark': mark }]"> + <span :class="['van-tag', 'van-hairline--surround', { [`van-tag--${type}`]: type, 'van-tag--plain': plain, 'van-tag--mark': mark }]"> <slot></slot> </span> </template> <script> -const ALLOW_TYPE = ['danger', 'success', 'primary']; - export default { name: 'van-tag', props: { - type: { - type: String, - validator: val => ~ALLOW_TYPE.indexOf(val) - }, + type: String, mark: Boolean, plain: Boolean } diff --git a/packages/toast/index.js b/packages/toast/index.js index 8dff1d60b..9117458e1 100644 --- a/packages/toast/index.js +++ b/packages/toast/index.js @@ -6,9 +6,9 @@ let instance; const defaultOptions = { visible: true, type: 'text', + mask: false, position: 'middle', duration: 3000, - mask: false, forbidClick: false, clear: () => { instance.visible = false; diff --git a/packages/toast/toast.vue b/packages/toast/toast.vue index 6ba795c96..a1762a8a4 100644 --- a/packages/toast/toast.vue +++ b/packages/toast/toast.vue @@ -22,7 +22,6 @@ import Icon from '../icon'; import Loading from '../loading'; -const TOAST_TYPES = ['text', 'html', 'loading', 'success', 'fail']; const DEFAULT_STYLE_LIST = ['success', 'fail', 'loading']; export default { @@ -34,26 +33,16 @@ export default { }, props: { + mask: Boolean, + message: String, + forbidClick: Boolean, type: { type: String, - default: 'text', - validator: value => TOAST_TYPES.indexOf(value) > -1 - }, - message: { - type: String, - default: '' - }, - forbidClick: { - type: Boolean, - default: false + default: 'text' }, position: { type: String, default: 'middle' - }, - mask: { - type: Boolean, - default: false } }, diff --git a/packages/uploader/index.vue b/packages/uploader/index.vue index 8e7e0cc42..32cbbe594 100644 --- a/packages/uploader/index.vue +++ b/packages/uploader/index.vue @@ -10,16 +10,12 @@ export default { name: 'van-uploader', props: { - disabled: { - type: Boolean, - default: false - }, + disabled: Boolean, beforeRead: Function, afterRead: Function, resultType: { type: String, - default: 'dataUrl', - validator: value => value === 'dataUrl' || value === 'text' + default: 'dataUrl' } }, diff --git a/packages/vant-css/src/tag.css b/packages/vant-css/src/tag.css index 0973c087e..7152d432e 100644 --- a/packages/vant-css/src/tag.css +++ b/packages/vant-css/src/tag.css @@ -10,16 +10,11 @@ color: $white; &::after { - border-color: $gray; + border-color: currentColor; border-radius: 4px; } - &.is-plain { - background: $white; - color: $gray; - } - - &.is-mark { + &--mark { border-radius: 0 8px 8px 0; &::after { @@ -30,11 +25,7 @@ &--success { background: $green; - &::after { - border-color: $green; - } - - &.is-plain { + &.van-tag--plain { color: $green; } } @@ -42,11 +33,7 @@ &--danger { background: $button-danger-background-color; - &::after { - border-color: $button-danger-background-color; - } - - &.is-plain { + &.van-tag--plain { color: $button-danger-background-color; } } @@ -54,12 +41,13 @@ &--primary { background: $blue; - &::after { - border-color: $blue; - } - - &.is-plain { + &.van-tag--plain { color: $blue; } } + + &--plain { + background: $white; + color: $gray; + } } diff --git a/test/unit/specs/deep-assign.spec.js b/test/unit/specs/deep-assign.spec.js index d6b15edab..3eff8102b 100644 --- a/test/unit/specs/deep-assign.spec.js +++ b/test/unit/specs/deep-assign.spec.js @@ -1,6 +1,6 @@ import deepAssign from 'packages/utils/deep-assign'; -describe('DatetimePicker', () => { +describe('DeepAssign', () => { it('basic assign', () => { const a = { foo: 0 }; const b = { foo: 0, bar: 1 }; diff --git a/yarn.lock b/yarn.lock index a784a9a5a..c64c300fa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7755,9 +7755,9 @@ validate-npm-package-license@^3.0.1: spdx-correct "~1.0.0" spdx-expression-parse "~1.0.0" -vant-doc@0.3.17: - version "0.3.17" - resolved "https://registry.yarnpkg.com/vant-doc/-/vant-doc-0.3.17.tgz#4c3bd5e4a4299926ad3638dc1c1bd28bbb5ac34b" +vant-doc@0.3.18: + version "0.3.18" + resolved "https://registry.yarnpkg.com/vant-doc/-/vant-doc-0.3.18.tgz#86f94b931767bd1ba3e2c48015446be1729e0976" dependencies: cheerio "0.22.0" decamelize "^1.2.0"