白色主题

This commit is contained in:
2023-02-12 19:04:01 +08:00
parent d736a5912f
commit 57ab6fbb49
411 changed files with 1752 additions and 5304 deletions

View File

@@ -9,12 +9,14 @@ custom-style | String | - | `0.25.0` | N
index-list | Array | - | `0.32.0`。Typescript`string [] \| number[]` | N
list | Array | [] | `deprecated`。Typescript`ListItem[] ` `interface ListItem { title: string; index: string; children: { title: string; [key: string]: any} [] }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/indexes/type.ts) | N
sticky | Boolean | true | Typescript`Boolean` | N
sticky-offset | Number | 0 | `1.0.0` | N
### Indexes Events
name | params | description
-- | -- | --
select | `(indexes: { groupIndex: string; childrenIndex: number })` | \-
change | `(index: string \| number)` | `0.34.0`
select | `(index: string \| number)` | \-
### IndexesAnchor Props

View File

@@ -46,12 +46,14 @@ custom-style | String | - | `0.25.0`。自定义组件样式 | N
index-list | Array | - | `0.32.0`。索引字符列表。不传默认 `A-Z`。TS 类型:`string [] \| number[]` | N
list | Array | [] | 已废弃。索引列表的列表数据。每个元素包含三个子元素index(string)索引值例如123...或ABC等title(string): 索引标题可不填将默认设为索引值children(Array<{title: string}>): 子元素列表title为子元素的展示文案。。TS 类型:`ListItem[] ` `interface ListItem { title: string; index: string; children: { title: string; [key: string]: any} [] }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/indexes/type.ts) | N
sticky | Boolean | true | 索引是否吸顶默认为true。TS 类型:`Boolean` | N
sticky-offset | Number | 0 | `1.0.0`。锚点吸顶时与顶部的距离 | N
### Indexes Events
名称 | 参数 | 描述
-- | -- | --
select | `(indexes: { groupIndex: string; childrenIndex: number })` | 点击行元素时触发事件
change | `(index: string \| number)` | `0.34.0`。索引发生变更时触发事件
select | `(index: string \| number)` | 点击侧边栏时触发事件
### IndexesAnchor Props

View File

@@ -142,6 +142,9 @@ let Indexes = class Indexes extends SuperComponent {
this.preIndex = index;
this.toggleTips(true);
this.triggerEvent('select', { index: activeAnchor });
if (activeAnchor !== this.data.activeAnchor) {
this.triggerEvent('change', { index: activeAnchor });
}
},
onClick(e) {
const { index } = e.currentTarget.dataset;
@@ -175,32 +178,36 @@ let Indexes = class Indexes extends SuperComponent {
if (!this.groupTop) {
return;
}
const { sticky } = this.data;
const { sticky, stickyOffset } = this.data;
scrollTop += stickyOffset;
const curIndex = this.groupTop.findIndex((group) => scrollTop >= group.top - group.height && scrollTop <= group.top + group.totalHeight - group.height);
if (curIndex === -1)
return;
const curGroup = this.groupTop[curIndex];
if (this.data.activeAnchor !== curGroup.anchor) {
this.triggerEvent('change', { index: curGroup.anchor });
}
this.setData({
activeAnchor: curGroup.anchor,
});
if (sticky) {
const offset = curGroup.top - scrollTop;
const betwixt = offset < curGroup.height && offset > 0 && scrollTop > 0;
const betwixt = offset < curGroup.height && offset > 0 && scrollTop > stickyOffset;
this.$children.forEach((child, index) => {
if (index === curIndex) {
child.setData({
sticky: scrollTop > 0,
sticky: scrollTop > stickyOffset,
active: true,
customStyle: `height: ${curGroup.height}px`,
anchorStyle: `transform: translate3d(0, ${betwixt ? offset : 0}px, 0)`,
style: `height: ${curGroup.height}px`,
anchorStyle: `transform: translate3d(0, ${betwixt ? offset : 0}px, 0); top: ${stickyOffset}px`,
});
}
else if (index + 1 === curIndex) {
child.setData({
sticky: true,
active: true,
customStyle: `height: ${curGroup.height}px`,
anchorStyle: `transform: translate3d(0, ${betwixt ? offset - curGroup.height : 0}px, 0)`,
style: `height: ${curGroup.height}px`,
anchorStyle: `transform: translate3d(0, ${betwixt ? offset - curGroup.height : 0}px, 0); top: ${stickyOffset}px`,
});
}
else {

View File

@@ -1,6 +1,6 @@
<wxs src="../common/utils.wxs" module="_" />
<view style="{{ customStyle }}" class="{{classPrefix}} {{prefix}}-class">
<view style="{{ style }}" class="{{classPrefix}} {{prefix}}-class">
<view
class="{{classPrefix}}__sidebar {{prefix}}-class-sidebar"
id="id-{{classPrefix}}__bar"

View File

@@ -31,7 +31,7 @@
}
.t-indexes__sidebar {
position: fixed;
right: 0;
right: var(--td-indexes-sidebar-right, 16rpx);
width: var(--td-indexes-sidebar-item-size, 40rpx);
color: var(--td-indexes-sidebar-color, var(--td-font-gray-1, rgba(0, 0, 0, 0.9)));
font-size: var(--td-indexes-sidebar-font-size, 24rpx);

View File

@@ -1,5 +1,5 @@
const props = {
customStyle: {
style: {
type: String,
value: '',
},
@@ -14,5 +14,9 @@ const props = {
type: Boolean,
value: true,
},
stickyOffset: {
type: Number,
value: 0,
},
};
export default props;

View File

@@ -1,5 +1,5 @@
export interface TdIndexesProps {
customStyle?: {
style?: {
type: StringConstructor;
value?: string;
};
@@ -15,6 +15,10 @@ export interface TdIndexesProps {
type: BooleanConstructor;
value?: Boolean;
};
stickyOffset?: {
type: NumberConstructor;
value?: number;
};
}
export interface ListItem {
title: string;