From 73d462186adb4ef65202eccf7f7c6d8a0f610d90 Mon Sep 17 00:00:00 2001 From: yangjinfeng Date: Thu, 12 Jul 2018 15:19:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[improvement]cell:=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=BB=98=E8=AE=A4slot=E5=B1=95=E7=A4=BA=E6=95=88=E6=9E=9C?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0title=E5=8C=BA=E5=9F=9F=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/pages/cell/index.js | 9 ++++++++- example/pages/cell/index.wxml | 10 ++++++++++ packages/cell/README.md | 1 + packages/cell/index.js | 2 +- packages/cell/index.pcss | 9 +++++++++ packages/cell/index.wxml | 5 ++++- 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/example/pages/cell/index.js b/example/pages/cell/index.js index 8f3b7131..576cca2a 100644 --- a/example/pages/cell/index.js +++ b/example/pages/cell/index.js @@ -3,7 +3,8 @@ var Zan = require('../../dist/index'); Page(Object.assign({}, Zan.Switch, { data: { checked: false, - show: true + show: true, + date: '' }, onLoad() { @@ -18,6 +19,12 @@ Page(Object.assign({}, Zan.Switch, { }); }, + bindDateChange(e) { + this.setData({ + date: e.detail.value + }); + }, + handleTap() { console.log('cell tapped'); } diff --git a/example/pages/cell/index.wxml b/example/pages/cell/index.wxml index a358922a..030d0995 100644 --- a/example/pages/cell/index.wxml +++ b/example/pages/cell/index.wxml @@ -18,6 +18,16 @@ + + + + + 选择日期: {{date}} + + + + + diff --git a/packages/cell/README.md b/packages/cell/README.md index db9f6ee9..51ab8e4a 100644 --- a/packages/cell/README.md +++ b/packages/cell/README.md @@ -66,3 +66,4 @@ | 类名 | 说明 | |-----------|-----------| | cell-class | 根节点自定义样式类,通过这个可以改变根节点上的样式 | +| title-class | title区域自定义样式 | diff --git a/packages/cell/index.js b/packages/cell/index.js index 9bf05606..132515ce 100644 --- a/packages/cell/index.js +++ b/packages/cell/index.js @@ -4,7 +4,7 @@ const warn = (msg, getValue) => { }; Component({ - externalClasses: ['cell-class'], + externalClasses: ['cell-class', 'title-class'], options: { multipleSlots: true }, diff --git a/packages/cell/index.pcss b/packages/cell/index.pcss index 89dae463..13101913 100644 --- a/packages/cell/index.pcss +++ b/packages/cell/index.pcss @@ -24,6 +24,15 @@ display: none } +.zan-cell__title { + min-width: 65px; + padding-right: 10px; +} + +.zan-cell__title:empty { + display: none; +} + .zan-cell__bd { flex: 1; } diff --git a/packages/cell/index.wxml b/packages/cell/index.wxml index dc94e6a6..9dd83c03 100644 --- a/packages/cell/index.wxml +++ b/packages/cell/index.wxml @@ -7,9 +7,12 @@ - + {{ title }} {{ label }} + + + From 1e25e542275a6f5c8bfc70047e4d6ab242ff5e96 Mon Sep 17 00:00:00 2001 From: yangjinfeng Date: Fri, 13 Jul 2018 16:36:10 +0800 Subject: [PATCH 2/3] =?UTF-8?q?cell-group=E6=B7=BB=E5=8A=A0titleWidth?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=95=B4=E4=BD=93=E6=8E=A7=E5=88=B6title?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cell-group/index.js | 9 +++++++++ packages/cell/README.md | 3 ++- packages/cell/index.js | 10 +++++++++- packages/cell/index.wxml | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/cell-group/index.js b/packages/cell-group/index.js index ea805902..19150663 100644 --- a/packages/cell-group/index.js +++ b/packages/cell-group/index.js @@ -2,6 +2,12 @@ const CELL_PATH = '../cell/index'; const FIELD_PATH = '../field/index' Component({ + properties: { + titleWidth: { + type: Number, + value: null + } + }, relations: { [CELL_PATH]: { type: 'child', @@ -43,10 +49,13 @@ Component({ const elementUpdateTimeout = setTimeout(() => { this.setData({ elementUpdateTimeout: 0 }); let elements = this.getRelationNodes(childPath); + const { titleWidth } = this.properties; + if (elements.length > 0) { let lastIndex = elements.length - 1; elements.forEach((cell, index) => { + titleWidth && cell.setTitleWidth(titleWidth) cell.updateIsLastElement(index === lastIndex); }); } diff --git a/packages/cell/README.md b/packages/cell/README.md index 51ab8e4a..5113c3a7 100644 --- a/packages/cell/README.md +++ b/packages/cell/README.md @@ -27,8 +27,9 @@ } ``` +`cell-group`提供`title-width`控制组内整体 cell 的 title 区域宽度 ```wxml - + diff --git a/packages/cell/index.js b/packages/cell/index.js index 132515ce..25151ac8 100644 --- a/packages/cell/index.js +++ b/packages/cell/index.js @@ -46,7 +46,8 @@ Component({ } }, data: { - isLastCell: true + isLastCell: true, + titleWidth: 'auto' }, methods: { footerTap() { @@ -72,6 +73,13 @@ Component({ // 用于被 cell-group 更新,标志是否是最后一个 cell updateIsLastElement(isLastCell) { this.setData({ isLastCell }); + }, + + // 设置统一的title区域宽度 + setTitleWidth(titleWidth) { + this.setData({ + titleWidth: `${titleWidth}px` + }); } } }); diff --git a/packages/cell/index.wxml b/packages/cell/index.wxml index 9dd83c03..db6db63d 100644 --- a/packages/cell/index.wxml +++ b/packages/cell/index.wxml @@ -7,7 +7,7 @@ - + {{ title }} {{ label }} From f906f64bc784468f49c9706bee792b482f986e06 Mon Sep 17 00:00:00 2001 From: yangjinfeng Date: Sat, 21 Jul 2018 22:50:17 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8E=BB=E6=8E=89title=E7=9A=84=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cell/index.pcss | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cell/index.pcss b/packages/cell/index.pcss index 13101913..50987e2d 100644 --- a/packages/cell/index.pcss +++ b/packages/cell/index.pcss @@ -25,7 +25,6 @@ } .zan-cell__title { - min-width: 65px; padding-right: 10px; }