first commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
:: BASE_DOC ::
|
||||
|
||||
## API
|
||||
### IndexesAnchor Props
|
||||
|
||||
name | type | default | description | required
|
||||
-- | -- | -- | -- | --
|
||||
external-classes | Array | - | `['t-class']` | N
|
||||
index | String / Number | - | \- | N
|
||||
|
||||
### CSS Variables
|
||||
|
||||
The component provides the following CSS variables, which can be used to customize styles.
|
||||
Name | Default Value | Description
|
||||
-- | -- | --
|
||||
--td-indexes-anchor-active-bg-color | @bg-color-container | -
|
||||
--td-indexes-anchor-active-color | @brand-color | -
|
||||
--td-indexes-anchor-active-font-weight | 600 | -
|
||||
--td-indexes-anchor-bg-color | @bg-color-secondarycontainer | -
|
||||
--td-indexes-anchor-border-color | @component-border | -
|
||||
--td-indexes-anchor-color | @text-color-primary | -
|
||||
--td-indexes-anchor-font | @font-body-medium | -
|
||||
--td-indexes-anchor-padding | 8rpx 32rpx | -
|
||||
--td-indexes-anchor-top | 0 | -
|
||||
@@ -0,0 +1,28 @@
|
||||
:: BASE_DOC ::
|
||||
|
||||
## API
|
||||
### IndexesAnchor Props
|
||||
|
||||
名称 | 类型 | 默认值 | 说明 | 必传
|
||||
-- | -- | -- | -- | --
|
||||
index | String / Number | - | 索引字符 | N
|
||||
|
||||
### IndexesAnchor 外部样式类
|
||||
类名 | 说明
|
||||
-- | --
|
||||
t-class | 根节点样式类
|
||||
|
||||
### CSS Variables
|
||||
|
||||
组件提供了下列 CSS 变量,可用于自定义样式。
|
||||
名称 | 默认值 | 描述
|
||||
-- | -- | --
|
||||
--td-indexes-anchor-active-bg-color | @bg-color-container | -
|
||||
--td-indexes-anchor-active-color | @brand-color | -
|
||||
--td-indexes-anchor-active-font-weight | 600 | -
|
||||
--td-indexes-anchor-bg-color | @bg-color-secondarycontainer | -
|
||||
--td-indexes-anchor-border-color | @component-border | -
|
||||
--td-indexes-anchor-color | @text-color-primary | -
|
||||
--td-indexes-anchor-font | @font-body-medium | -
|
||||
--td-indexes-anchor-padding | 8rpx 32rpx | -
|
||||
--td-indexes-anchor-top | 0 | -
|
||||
@@ -0,0 +1,49 @@
|
||||
.t-indexes-anchor {
|
||||
color: var(--td-indexes-anchor-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
|
||||
font: var(--td-indexes-anchor-font, var(--td-font-body-medium, 28rpx / 44rpx var(--td-font-family, PingFang SC, Microsoft YaHei, Arial Regular)));
|
||||
}
|
||||
.t-indexes-anchor__header {
|
||||
display: none;
|
||||
padding: var(--td-indexes-anchor-padding, 8rpx 32rpx);
|
||||
background-color: var(--td-indexes-anchor-bg-color, var(--td-bg-color-secondarycontainer, var(--td-gray-color-1, #f3f3f3)));
|
||||
}
|
||||
.t-indexes-anchor__header--active {
|
||||
background-color: var(--td-indexes-anchor-active-bg-color, var(--td-bg-color-container, var(--td-font-white-1, #ffffff)));
|
||||
position: relative;
|
||||
}
|
||||
.t-indexes-anchor__header--active::after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: unset;
|
||||
bottom: 0;
|
||||
left: unset;
|
||||
right: unset;
|
||||
background-color: var(--td-indexes-anchor-border-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
|
||||
}
|
||||
.t-indexes-anchor__header--active::after {
|
||||
height: 1px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
transform: scaleY(0.5);
|
||||
}
|
||||
.t-indexes-anchor__slot {
|
||||
overflow: hidden;
|
||||
}
|
||||
.t-indexes-anchor__slot:empty + .t-indexes-anchor__header {
|
||||
display: block;
|
||||
}
|
||||
.t-indexes-anchor__wrapper {
|
||||
will-change: transform;
|
||||
}
|
||||
.t-indexes-anchor__wrapper--sticky {
|
||||
position: fixed;
|
||||
top: var(--td-indexes-anchor-top, 0);
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
.t-indexes-anchor__wrapper--active {
|
||||
color: var(--td-indexes-anchor-active-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
|
||||
font-weight: var(--td-indexes-anchor-active-font-weight, 600);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<view
|
||||
:class="classPrefix + ' ' + tClass"
|
||||
:style="tools._style([customStyle])"
|
||||
>
|
||||
<view
|
||||
:class="
|
||||
tools.cls(classPrefix + '__wrapper', [
|
||||
['sticky', sticky],
|
||||
['active', active]
|
||||
])
|
||||
"
|
||||
:style="anchorStyle"
|
||||
>
|
||||
<view :class="classPrefix + '__slot'">
|
||||
<slot />
|
||||
</view>
|
||||
<view :class="tools.cls(classPrefix + '__header', [['active', active]])">
|
||||
{{ index }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { uniComponent } from '../common/src/index';
|
||||
import { prefix } from '../common/config';
|
||||
import props from './props';
|
||||
import tools from '../common/utils.wxs';
|
||||
import { ChildrenMixin, RELATION_MAP } from '../common/relation';
|
||||
|
||||
|
||||
const name = `${prefix}-indexes-anchor`;
|
||||
|
||||
|
||||
export default uniComponent({
|
||||
name,
|
||||
options: {
|
||||
styleIsolation: 'shared',
|
||||
},
|
||||
externalClasses: [
|
||||
`${prefix}-class`,
|
||||
],
|
||||
mixins: [
|
||||
ChildrenMixin(RELATION_MAP.IndexesAnchor, {
|
||||
indexKey: 'tIndex',
|
||||
}),
|
||||
],
|
||||
props: {
|
||||
...props,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
prefix,
|
||||
classPrefix: name,
|
||||
anchorStyle: '',
|
||||
sticky: false,
|
||||
active: false,
|
||||
tools,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
@import './indexes-anchor.css';
|
||||
</style>
|
||||
@@ -0,0 +1,12 @@
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
|
||||
* */
|
||||
|
||||
export default {
|
||||
/** 索引字符 */
|
||||
index: {
|
||||
type: [String, Number],
|
||||
},
|
||||
};
|
||||
12
uni_modules/tdesign-uniapp/components/indexes-anchor/type.ts
Normal file
12
uni_modules/tdesign-uniapp/components/indexes-anchor/type.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
|
||||
* */
|
||||
|
||||
export interface TdIndexesAnchorProps {
|
||||
/**
|
||||
* 索引字符
|
||||
*/
|
||||
index?: string | number;
|
||||
}
|
||||
Reference in New Issue
Block a user