From 7e071fdafee90dd9dab3a592ce50f2f490833dce Mon Sep 17 00:00:00 2001 From: Donald Shen <825870831@qq.com> Date: Tue, 12 Nov 2019 14:50:36 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20grid-item=E7=94=A8icon=E6=8F=92?= =?UTF-8?q?=E6=A7=BD=E6=97=B6=E4=B9=9F=E8=83=BD=E7=94=A8info=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/grid-item/index.js | 23 +++++++++++++---------- src/grid/README.md | 3 +++ src/grid/README.zh-CN.md | 5 ++++- src/grid/demo/index.vue | 3 +++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/grid-item/index.js b/src/grid-item/index.js index 5dad92519d4..d3c2495c1e1 100644 --- a/src/grid-item/index.js +++ b/src/grid-item/index.js @@ -3,6 +3,7 @@ import { BORDER } from '../utils/constant'; import { ChildrenMixin } from '../mixins/relation'; import { route, routeProps } from '../utils/router'; import Icon from '../icon'; +import Info from '../info'; const [createComponent, bem] = createNamespace('grid-item'); @@ -67,18 +68,20 @@ export default createComponent({ if (slot) { return slot; } + const slotIcon = this.slots('icon'); return [ - this.slots('icon') || - (this.icon && ( - - )), + slotIcon && slotIcon, + slotIcon && , + !slotIcon && this.icon && ( + + ), this.slots('text') || (this.text && {this.text}) ]; } diff --git a/src/grid/README.md b/src/grid/README.md index d19bc8d82a9..556708e6351 100644 --- a/src/grid/README.md +++ b/src/grid/README.md @@ -92,6 +92,9 @@ Vue.use(Grid).use(GridItem); + + slot=icon + ``` diff --git a/src/grid/README.zh-CN.md b/src/grid/README.zh-CN.md index 1c1ff1fc576..17e4ff6d772 100644 --- a/src/grid/README.zh-CN.md +++ b/src/grid/README.zh-CN.md @@ -104,12 +104,15 @@ Vue.use(Grid).use(GridItem); ### 提示信息 -设置`dot`属性后,会在图标右上角展示一个小红点。设置`info`属性后,会在图标右上角展示相应的徽标 +设置`dot`属性后,会在图标右上角展示一个小红点。设置`info`属性后,会在图标右上角展示相应的徽标。注意使用icon插槽时,需要自行调整info位置 ```html + + slot=icon + ``` diff --git a/src/grid/demo/index.vue b/src/grid/demo/index.vue index 4833886b2c8..7631e0f0c6f 100644 --- a/src/grid/demo/index.vue +++ b/src/grid/demo/index.vue @@ -49,6 +49,9 @@ + + slot=icon + From 06e87a730381808bb816819b6a8eb73c9c112363 Mon Sep 17 00:00:00 2001 From: Donald Shen <825870831@qq.com> Date: Tue, 12 Nov 2019 14:59:56 +0800 Subject: [PATCH 2/4] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0snapshot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/__snapshots__/demo.spec.js.snap | 12 +++--------- .../test/__snapshots__/index.spec.js.snap | 8 ++------ src/grid/test/__snapshots__/demo.spec.js.snap | 4 ++++ src/select/test/__snapshots__/demo.spec.js.snap | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/address-list/test/__snapshots__/demo.spec.js.snap b/src/address-list/test/__snapshots__/demo.spec.js.snap index deb69f0b5a2..df53e0618ae 100644 --- a/src/address-list/test/__snapshots__/demo.spec.js.snap +++ b/src/address-list/test/__snapshots__/demo.spec.js.snap @@ -16,9 +16,7 @@ exports[`renders demo correctly 1`] = `
设为默认 -
- -
+
@@ -33,9 +31,7 @@ exports[`renders demo correctly 1`] = `
设为默认 -
- -
+
@@ -52,9 +48,7 @@ exports[`renders demo correctly 1`] = `
设为默认 -
- -
+
diff --git a/src/address-list/test/__snapshots__/index.spec.js.snap b/src/address-list/test/__snapshots__/index.spec.js.snap index 40b7cbd61eb..e704931166e 100644 --- a/src/address-list/test/__snapshots__/index.spec.js.snap +++ b/src/address-list/test/__snapshots__/index.spec.js.snap @@ -14,9 +14,7 @@ exports[`unswitchable 1`] = `
设为默认 -
- -
+
@@ -31,9 +29,7 @@ exports[`unswitchable 1`] = `
设为默认 -
- -
+
diff --git a/src/grid/test/__snapshots__/demo.spec.js.snap b/src/grid/test/__snapshots__/demo.spec.js.snap index 69390c9b170..fbfbc7dcc79 100644 --- a/src/grid/test/__snapshots__/demo.spec.js.snap +++ b/src/grid/test/__snapshots__/demo.spec.js.snap @@ -174,6 +174,10 @@ exports[`renders demo correctly 1`] = `
99+
文字 +
+
slot=icon +
99+
文字
+
diff --git a/src/select/test/__snapshots__/demo.spec.js.snap b/src/select/test/__snapshots__/demo.spec.js.snap index 530720f9cb2..20b8ffd0698 100644 --- a/src/select/test/__snapshots__/demo.spec.js.snap +++ b/src/select/test/__snapshots__/demo.spec.js.snap @@ -4,7 +4,7 @@ exports[`renders demo correctly 1`] = `
-
+
基本用法
From 8ef3aee8602a1cb64fc547908f6b86e6f46043c5 Mon Sep 17 00:00:00 2001 From: Donald Shen <825870831@qq.com> Date: Tue, 12 Nov 2019 15:04:16 +0800 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20push=E6=97=B6=E8=BF=90=E8=A1=8Ctes?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 39406809b09..e5126960382 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "husky": { "hooks": { "pre-commit": "lint-staged", - "commit-msg": "vant commit-lint" + "commit-msg": "vant commit-lint", + "pre-push": "yarn test" } }, "lint-staged": { From 709b459fc6de182f54eba93edfde98205af606ae Mon Sep 17 00:00:00 2001 From: Donald Shen <825870831@qq.com> Date: Tue, 12 Nov 2019 15:46:15 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=E6=9B=B4=E5=A5=BD=E7=9A=84slot?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/grid-item/index.js | 19 +- src/grid/README.zh-CN.md | 2 +- src/grid/test/__snapshots__/demo.spec.js.snap | 245 +++++++++++++----- .../test/__snapshots__/index.spec.js.snap | 26 +- 4 files changed, 212 insertions(+), 80 deletions(-) diff --git a/src/grid-item/index.js b/src/grid-item/index.js index d3c2495c1e1..50c2a4a7f3e 100644 --- a/src/grid-item/index.js +++ b/src/grid-item/index.js @@ -68,20 +68,15 @@ export default createComponent({ if (slot) { return slot; } - const slotIcon = this.slots('icon'); return [ - slotIcon && slotIcon, - slotIcon && , - !slotIcon && this.icon && ( - - ), +
+ {this.slots('icon') || + (this.icon && ( + + ))} + +
, this.slots('text') || (this.text && {this.text}) ]; } diff --git a/src/grid/README.zh-CN.md b/src/grid/README.zh-CN.md index 17e4ff6d772..01d652a8c1e 100644 --- a/src/grid/README.zh-CN.md +++ b/src/grid/README.zh-CN.md @@ -104,7 +104,7 @@ Vue.use(Grid).use(GridItem); ### 提示信息 -设置`dot`属性后,会在图标右上角展示一个小红点。设置`info`属性后,会在图标右上角展示相应的徽标。注意使用icon插槽时,需要自行调整info位置 +设置`dot`属性后,会在图标右上角展示一个小红点。设置`info`属性后,会在图标右上角展示相应的徽标 ```html diff --git a/src/grid/test/__snapshots__/demo.spec.js.snap b/src/grid/test/__snapshots__/demo.spec.js.snap index fbfbc7dcc79..88b7b57a19e 100644 --- a/src/grid/test/__snapshots__/demo.spec.js.snap +++ b/src/grid/test/__snapshots__/demo.spec.js.snap @@ -5,48 +5,88 @@ exports[`renders demo correctly 1`] = `
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
@@ -81,102 +121,183 @@ exports[`renders demo correctly 1`] = `
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 文字
+
+
+ + +
文字 +
-
- 路由跳转
+
+
+ + +
路由跳转 +
-
- URL 跳转
+
+
+ + +
URL 跳转 +
-
+
+
+
-
文字
+
文字 +
-
+
+
+
99+
-
文字
+
文字 +
-
slot=icon -
99+
文字
+
+
slot=icon +
99+
+
文字 +
diff --git a/src/grid/test/__snapshots__/index.spec.js.snap b/src/grid/test/__snapshots__/index.spec.js.snap index a66e337fb3e..d940f64af6a 100644 --- a/src/grid/test/__snapshots__/index.spec.js.snap +++ b/src/grid/test/__snapshots__/index.spec.js.snap @@ -3,8 +3,12 @@ exports[`icon-size prop 1`] = `
-
-
+
+
+ + +
+
`; @@ -12,13 +16,25 @@ exports[`icon-size prop 1`] = ` exports[`sqaure and set gutter 1`] = `
-
+
+
+ +
+
-
+
+
+ +
+
-
+
+
+ +
+
`;