Skip to content

Commit a8e22cd

Browse files
authored
fix(Cell): fix component style errors (#3466)
1 parent 46a0d4a commit a8e22cd

File tree

13 files changed

+88
-60
lines changed

13 files changed

+88
-60
lines changed

src/cell-group/props.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ const props: TdCellGroupProps = {
99
/** 是否显示组边框 */
1010
bordered: {
1111
type: Boolean,
12+
value: false,
1213
},
13-
/** 组件类名 */
14-
externalClasses: {
15-
type: Array,
16-
},
17-
/** 单元格风格 */
14+
/** 单元格组风格 */
1815
theme: {
1916
type: String,
2017
value: 'default',

src/cell-group/type.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,14 @@
77
export interface TdCellGroupProps {
88
/**
99
* 是否显示组边框
10+
* @default false
1011
*/
1112
bordered?: {
1213
type: BooleanConstructor;
1314
value?: boolean;
1415
};
1516
/**
16-
* 自定义组件样式
17-
* @default ''
18-
*/
19-
style?: {
20-
type: StringConstructor;
21-
value?: string;
22-
};
23-
/**
24-
* 组件类名
25-
*/
26-
externalClasses?: {
27-
type: ArrayConstructor;
28-
value?: ['t-class'];
29-
};
30-
/**
31-
* 单元格风格
17+
* 单元格组风格
3218
* @default default
3319
*/
3420
theme?: {

src/cell/README.en-US.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ url | String | - | \- | N
2727
name | params | description
2828
-- | -- | --
2929
click | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts)
30+
3031
### Cell External Classes
3132

3233
className | Description
@@ -43,6 +44,24 @@ t-class-right | \-
4344
t-class-right-icon | \-
4445
t-class-title | \-
4546

47+
48+
### CellGroup Props
49+
50+
name | type | default | description | required
51+
-- | -- | -- | -- | --
52+
style | Object | - | CSS(Cascading Style Sheets) | N
53+
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
54+
bordered | Boolean | false | \- | N
55+
theme | String | default | options: default/card | N
56+
title | String | - | \- | N
57+
58+
### CellGroup External Classes
59+
60+
className | Description
61+
-- | --
62+
t-class | \-
63+
t-class-title | \-
64+
4665
### CSS Variables
4766

4867
The component provides the following CSS variables, which can be used to customize styles.
@@ -78,4 +97,4 @@ Name | Default Value | Description
7897
--td-cell-right-icon-font-size | 48rpx | -
7998
--td-cell-title-color | @text-color-primary | -
8099
--td-cell-title-font-size | @font-size-m | -
81-
--td-cell-vertical-padding | 32rpx | -
100+
--td-cell-vertical-padding | 32rpx | -

src/cell/README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ isComponent: true
5353
-- | -- | -- | -- | --
5454
style | Object | - | 样式 | N
5555
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
56-
align | String | middle | 内容的对齐方式,默认居中对齐。可选项:top/middle/bottom | N
56+
align | String | middle | 右侧内容的对齐方式,默认居中对齐。可选项:top/middle/bottom | N
5757
arrow | Boolean / Object | false | 是否显示右侧箭头 | N
5858
bordered | Boolean | true | 是否显示下边框 | N
5959
description | String / Slot | - | 下方内容描述。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
@@ -72,6 +72,7 @@ url | String | - | 点击后跳转链接地址。如果值为空,则表示不
7272
名称 | 参数 | 描述
7373
-- | -- | --
7474
click | - | 右侧内容。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts)
75+
7576
### Cell External Classes
7677

7778
类名 | 描述
@@ -88,6 +89,24 @@ t-class-right | 右侧内容样式类
8889
t-class-right-icon | 右侧图标样式类
8990
t-class-title | 标题样式类
9091

92+
93+
### CellGroup Props
94+
95+
名称 | 类型 | 默认值 | 描述 | 必传
96+
-- | -- | -- | -- | --
97+
style | Object | - | 样式 | N
98+
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
99+
bordered | Boolean | false | 是否显示组边框 | N
100+
theme | String | default | 单元格组风格。可选项:default/card | N
101+
title | String | - | 单元格组标题 | N
102+
103+
### CellGroup External Classes
104+
105+
类名 | 描述
106+
-- | --
107+
t-class | 根节点样式类
108+
t-class-title | 标题样式类
109+
91110
### CSS Variables
92111

93112
组件提供了下列 CSS 变量,可用于自定义样式。
@@ -123,4 +142,4 @@ t-class-title | 标题样式类
123142
--td-cell-right-icon-font-size | 48rpx | -
124143
--td-cell-title-color | @text-color-primary | -
125144
--td-cell-title-font-size | @font-size-m | -
126-
--td-cell-vertical-padding | 32rpx | -
145+
--td-cell-vertical-padding | 32rpx | -

src/cell/__test__/__snapshots__/demo.test.js.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ exports[`Cell Cell base demo works fine 1`] = `
4343
arrow="{{true}}"
4444
bordered="{{false}}"
4545
hover="{{true}}"
46-
leftIcon="lock-on"
46+
leftIcon="app"
4747
title="单行标题"
4848
/>
4949
</base>
@@ -96,19 +96,19 @@ exports[`Cell Cell multiple demo works fine 1`] = `
9696
arrow="{{true}}"
9797
description="一段很长很长的内容文字"
9898
hover="{{true}}"
99-
leftIcon="lock-on"
99+
leftIcon="app"
100100
title="单行标题"
101101
/>
102102
<t-cell
103103
description="一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容"
104104
hover="{{true}}"
105-
title="多行标题"
105+
title="单行标题"
106106
/>
107107
<t-cell
108108
arrow="{{true}}"
109109
description="一段很长很长很长的内容文字"
110110
hover="{{true}}"
111-
title="多行带头像"
111+
title="单行标题"
112112
>
113113
<wx-view
114114
class="avatar"
@@ -125,7 +125,7 @@ exports[`Cell Cell multiple demo works fine 1`] = `
125125
description="一段很长很长的内容文字"
126126
hover="{{true}}"
127127
image="https://tdesign.gtimg.com/mobile/demos/avatar1.png"
128-
title="多行带图片"
128+
title="单行标题"
129129
/>
130130
</multiple>
131131
`;

src/cell/__test__/__snapshots__/index.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports[`cell :base 1`] = `
88
<wx-view
99
ariaLabel=""
1010
ariaRole=""
11-
class="class t-class t-cell t-cell--middle"
11+
class="class t-class t-cell"
1212
hoverClass=""
1313
hoverStayTime="70"
1414
style=""
@@ -31,7 +31,7 @@ exports[`cell :base 1`] = `
3131
class="t-cell__note t-class-note"
3232
/>
3333
<wx-view
34-
class="t-cell__right t-class-right"
34+
class="t-cell__right t-cell__right--middle t-class-right"
3535
/>
3636
</wx-view>
3737
</main>

src/cell/_example/base/index.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
<t-switch defaultValue="{{true}}" slot="note" />
88
</t-cell>
99
<t-cell title="单行标题" hover note="辅助信息" arrow />
10-
<t-cell title="单行标题" hover arrow leftIcon="lock-on" bordered="{{false}}" />
10+
<t-cell title="单行标题" hover arrow leftIcon="app" bordered="{{false}}" />

src/cell/_example/multiple/index.wxml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
<t-switch defaultValue="{{true}}" slot="note" />
88
</t-cell>
99
<t-cell title="单行标题" description="一段很长很长的内容文字" note="辅助信息" hover arrow />
10-
<t-cell title="单行标题" description="一段很长很长的内容文字" leftIcon="lock-on" hover arrow />
11-
<t-cell title="多行标题" description="一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容" hover />
12-
<t-cell title="多行带头像" description="一段很长很长很长的内容文字" hover arrow>
10+
<t-cell title="单行标题" description="一段很长很长的内容文字" leftIcon="app" hover arrow />
11+
<t-cell title="单行标题" description="一段很长很长的内容文字,长文本自动换行,该选项的描述是一段很长的内容" hover />
12+
<t-cell title="单行标题" description="一段很长很长很长的内容文字" hover arrow>
1313
<view class="avatar" slot="left-icon">
1414
<open-data type="userAvatarUrl" />
1515
</view>
1616
</t-cell>
1717
<t-cell
18-
title="多行带图片"
18+
title="单行标题"
1919
description="一段很长很长的内容文字"
2020
align="top"
2121
image="https://tdesign.gtimg.com/mobile/demos/avatar1.png"

src/cell/cell.less

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
font-size: @cell-note-font-size;
6666
}
6767

68+
&__title {
69+
margin-right: @spacer-2;
70+
}
71+
6872
&__title,
6973
&__note {
7074
flex: 1 1 auto;
@@ -83,13 +87,12 @@
8387

8488
&__left,
8589
&__right {
86-
display: flex;
87-
align-items: center;
90+
align-self: stretch;
8891
}
8992

9093
&__left {
9194
&:not(:empty) {
92-
margin-right: @spacer;
95+
margin-right: @spacer-1;
9396
}
9497

9598
&-icon {
@@ -103,13 +106,29 @@
103106
}
104107
}
105108

106-
&__right {
109+
&__note:not(:empty) + &__right {
107110
margin-left: calc(@spacer / 2);
111+
}
112+
113+
&__right {
114+
display: flex;
108115

109116
&-icon {
110117
color: @cell-right-icon-color;
111118
font-size: @cell-right-icon-font-size;
112119
}
120+
121+
&--middle {
122+
align-items: center;
123+
}
124+
125+
&--top {
126+
align-items: flex-start;
127+
}
128+
129+
&--bottom {
130+
align-items: flex-end;
131+
}
113132
}
114133

115134
&--hover {
@@ -120,16 +139,4 @@
120139
font-size: @cell-required-font-size;
121140
color: @cell-required-color;
122141
}
123-
124-
&--middle {
125-
align-items: center;
126-
}
127-
128-
&--top {
129-
align-items: flex-start;
130-
}
131-
132-
&--bottom {
133-
align-items: flex-end;
134-
}
135142
}

src/cell/cell.wxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<view
55
style="{{_._style([style, customStyle])}}"
6-
class="class {{prefix}}-class {{_.cls(classPrefix, [['borderless', !bordered || isLastChild], align])}}"
6+
class="class {{prefix}}-class {{_.cls(classPrefix, [['borderless', !bordered || isLastChild]])}}"
77
hover-class="{{ hover ? classPrefix + '--hover' : ''}}"
88
hover-stay-time="70"
99
bind:tap="onClick"
@@ -45,7 +45,7 @@
4545
<slot name="note" />
4646
</view>
4747

48-
<view class="{{classPrefix}}__right {{prefix}}-class-right">
48+
<view class="{{_.cls(classPrefix + '__right', [align])}} {{prefix}}-class-right">
4949
<template
5050
wx:if="{{_arrow}}"
5151
is="icon"

src/cell/props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { TdCellProps } from './type';
88
const props: TdCellProps = {
9-
/** 内容的对齐方式,默认居中对齐 */
9+
/** 右侧内容的对齐方式,默认居中对齐 */
1010
align: {
1111
type: String,
1212
value: 'middle',

src/cell/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
export interface TdCellProps {
88
/**
9-
* 内容的对齐方式,默认居中对齐
9+
* 右侧内容的对齐方式,默认居中对齐
1010
* @default middle
1111
*/
1212
align?: {

src/collapse/__test__/__snapshots__/index.test.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exports[`collapse :defaultExpandAll 1`] = `
3030
<wx-view
3131
ariaLabel=""
3232
ariaRole=""
33-
class="class t-class t-cell t-cell--middle"
33+
class="class t-class t-cell"
3434
hoverClass=""
3535
hoverStayTime="70"
3636
style=""
@@ -55,7 +55,7 @@ exports[`collapse :defaultExpandAll 1`] = `
5555
class="t-cell__note t-class-note"
5656
/>
5757
<wx-view
58-
class="t-cell__right t-class-right"
58+
class="t-cell__right t-cell__right--middle t-class-right"
5959
>
6060
<t-icon
6161
tClass="t-cell__right-icon t-class-right-icon"
@@ -116,7 +116,7 @@ exports[`collapse :defaultExpandAll 1`] = `
116116
<wx-view
117117
ariaLabel=""
118118
ariaRole=""
119-
class="class t-class t-cell t-cell--middle"
119+
class="class t-class t-cell"
120120
hoverClass=""
121121
hoverStayTime="70"
122122
style=""
@@ -141,7 +141,7 @@ exports[`collapse :defaultExpandAll 1`] = `
141141
class="t-cell__note t-class-note"
142142
/>
143143
<wx-view
144-
class="t-cell__right t-class-right"
144+
class="t-cell__right t-cell__right--middle t-class-right"
145145
>
146146
<t-icon
147147
tClass="t-cell__right-icon t-class-right-icon"

0 commit comments

Comments
 (0)