Skip to content

Commit 5591d44

Browse files
authored
[new feature] Tabs: add title-active-color、title-inactive-color prop (youzan#2773)
1 parent cb41279 commit 5591d44

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

packages/tab/en-US.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,14 @@ In swipeable mode, you can switch tabs with swipe gestrue in the content
151151
| Attribute | Description | Type | Default |
152152
|------|------|------|------|
153153
| v-model | Index of active tab | `String` `Number` | `0` |
154-
| color | Tab color | `String` | `#f44` |
155154
| type | Can be set to `line` `card` | `String` | `line` |
156155
| duration | Toggle tab's animation time | `Number` | `0.3` | - |
157156
| background | Background color | `String` | `white` |
158157
| line-width | Width of tab line (px) | `Number` | Width of active tab |
159158
| line-height | Height of tab line (px) | `Number` | 3 |
159+
| color | Tab color | `String` | `#f44` |
160+
| title-active-color | Title active color | `String` | - |
161+
| title-inactive-color | Title inactive color | `String` | - |
160162
| swipe-threshold | Set swipe tabs threshold | `Number` | `4` | - |
161163
| sticky | Whether to use sticky mode | `Boolean` | `false` |
162164
| offset-top | Offset top when use sticky mode | `Number` | `0` |

packages/tab/zh-CN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,14 @@ export default {
155155
| 参数 | 说明 | 类型 | 默认值 | 版本 |
156156
|------|------|------|------|------|
157157
| v-model | 当前标签的索引 | `String` `Number` | `0` | 1.0.6 |
158-
| color | 标签颜色 | `String` | `#f44` | 1.2.0 |
159158
| type | 样式类型,可选值为`card` | `String` | `line` | - |
160159
| duration | 动画时间,单位秒 | `Number` | `0.3` | - |
161160
| background | 标签栏背景色 | `String` | `white` | 1.6.5 |
162161
| line-width | 底部条宽度,单位 px | `Number` | - | 1.1.1 |
163162
| line-height | 底部条高度,单位 px | `Number` | 3 | 1.5.0 |
163+
| color | 标签主题色 | `String` | `#f44` | 1.2.0 |
164+
| title-active-color | 标题选中态颜色 | `String` | - | 1.6.5 |
165+
| title-inactive-color | 标题默认态颜色 | `String` | - | 1.6.5 |
164166
| swipeable | 是否开启手势滑动切换 | `Boolean` | `false` | 1.0.0 |
165167
| sticky | 是否使用粘性定位布局 | `Boolean` | `false` | - |
166168
| offset-top | 粘性定位布局下与顶部的最小距离,单位 px | `Number` | `0` | 1.1.15 |

packages/tabs/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export default sfc({
2121
offsetTop: Number,
2222
swipeable: Boolean,
2323
background: String,
24+
titleActiveColor: String,
25+
titleInactiveColor: String,
2426
ellipsis: {
2527
type: Boolean,
2628
default: true
@@ -362,6 +364,7 @@ export default sfc({
362364
const active = index === this.curActive;
363365
const isCard = this.type === 'card';
364366

367+
// theme color
365368
if (color) {
366369
if (!item.disabled && isCard && !active) {
367370
style.color = color;
@@ -374,6 +377,11 @@ export default sfc({
374377
}
375378
}
376379

380+
const titleColor = active ? this.titleActiveColor : this.titleInactiveColor;
381+
if (titleColor) {
382+
style.color = titleColor;
383+
}
384+
377385
if (this.scrollable && this.ellipsis) {
378386
style.flexBasis = 88 / this.swipeThreshold + '%';
379387
}

0 commit comments

Comments
 (0)