diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md index dd20fee5e..cedd6c3b0 100644 --- a/docs/markdown/changelog.zh-CN.md +++ b/docs/markdown/changelog.zh-CN.md @@ -4,7 +4,8 @@ ##### IndexBar -- 新增`sticky`参数 +- 新增`sticky`属性 +- 新增`highlight-color`属性 ##### Notify diff --git a/packages/index-anchor/index.js b/packages/index-anchor/index.js index 8524cfa61..30f32d4cc 100644 --- a/packages/index-anchor/index.js +++ b/packages/index-anchor/index.js @@ -26,6 +26,7 @@ export default sfc({ if (this.sticky) { return { top: `${this.top}px`, + color: this.parent.highlightColor, zIndex: `${this.parent.zIndex}` }; } diff --git a/packages/index-anchor/index.less b/packages/index-anchor/index.less index d563ea06d..ccfb9fa64 100644 --- a/packages/index-anchor/index.less +++ b/packages/index-anchor/index.less @@ -2,18 +2,19 @@ .van-index-anchor { padding: @index-anchor-padding; + color: @index-anchor-text-color; font-weight: @index-anchor-font-weight; font-size: @index-anchor-font-size; line-height: @index-anchor-line-height; - background-color: transparent; - transition: background-color .2s; + background-color: @index-anchor-background-color; + transition: color @index-anchor-transition-duration, + background-color @index-anchor-transition-duration; &--sticky { position: fixed; top: 0; right: 0; left: 0; - z-index: 1; - background-color: #fff; + background-color: @index-anchor-sticky-background-color; } } diff --git a/packages/index-bar/en-US.md b/packages/index-bar/en-US.md index f445267aa..bca69b2a1 100644 --- a/packages/index-bar/en-US.md +++ b/packages/index-bar/en-US.md @@ -65,7 +65,7 @@ export default { | index-list | Index List | `Array` | `A-Z` | | z-index | z-index | `Number` | `1` | | sticky | Whether to enable anchor sticky top | `Boolean` | `true` | -| highlight-color | Index character highlight color | `String` | - | - | +| highlight-color | Index character highlight color | `String` | `#07c160` | - | ### IndexAnchor Props diff --git a/packages/index-bar/index.js b/packages/index-bar/index.js index 9f5d7f3cf..4bcefdc29 100644 --- a/packages/index-bar/index.js +++ b/packages/index-bar/index.js @@ -1,6 +1,7 @@ import { use } from '../utils'; import { TouchMixin } from '../mixins/touch'; import { ParentMixin } from '../mixins/relation'; +import { GREEN } from '../utils/color'; import { on, off } from '../utils/event'; import { getScrollTop, getElementTop, getScrollEventTarget } from '../utils/scroll'; @@ -18,7 +19,10 @@ export default sfc({ type: Number, default: 1 }, - highlightColor: String, + highlightColor: { + type: String, + default: GREEN + }, indexList: { type: Array, default() { diff --git a/packages/index-bar/zh-CN.md b/packages/index-bar/zh-CN.md index 4f0428d53..a0b5b32a6 100644 --- a/packages/index-bar/zh-CN.md +++ b/packages/index-bar/zh-CN.md @@ -69,7 +69,7 @@ export default { | index-list | 索引字符列表 | `Array` | `A-Z` | - | | z-index | z-index 层级 | `Number` | `1` | - | | sticky | 是否开启锚点自动吸顶 | `Boolean` | `true` | - | -| highlight-color | 索引字符高亮颜色 | `String` | - | - | +| highlight-color | 索引字符高亮颜色 | `String` | `#07c160` | - | ### IndexAnchor Props diff --git a/packages/style/var.less b/packages/style/var.less index ac8dc3893..ff0d20c78 100644 --- a/packages/style/var.less +++ b/packages/style/var.less @@ -243,9 +243,13 @@ // IndexAnchor @index-anchor-padding: 0 15px; +@index-anchor-text-color: @text-color; @index-anchor-font-weight: 500; @index-anchor-font-size: 14px; @index-anchor-line-height: 32px; +@index-anchor-background-color: transparent; +@index-anchor-sticky-background-color: @white; +@index-anchor-transition-duration: .2s; // IndexBar @index-bar-index-font-size: 10px;