diff --git a/docs/.vitepress/components.ts b/docs/.vitepress/components.ts index c90dbfe..f22b91d 100644 --- a/docs/.vitepress/components.ts +++ b/docs/.vitepress/components.ts @@ -35,6 +35,14 @@ export interface ComponentMeta { } export const COMPONENT_LIST: ComponentMeta[] = [ + { + name: "TTimeline", + title: "Timeline 时间轴", + description: "按时间顺序展示事件。", + category: "布局组件", + entry: "src/components/timeline/index.vue", + slug: "timeline" + }, // ---------- 布局组件 ---------- { name: "PageTransition", diff --git a/docs/components/timeline.md b/docs/components/timeline.md new file mode 100644 index 0000000..a06e8d3 --- /dev/null +++ b/docs/components/timeline.md @@ -0,0 +1,39 @@ +# Timeline 时间轴 + +按时间顺序展示事件,使用 `Timeline` 和 `TimelineItem` 组合。 + +:::preview 基础用法 + +demo-preview=../demos/timeline/basic.vue + +::: + +容器支持 `layout`(`vertical`、`horizontal`)和 `reverse`。节点支持 `label`、`content`、`dot-color`,以及默认、`label`、`content`、`dot` 插槽。点击节点触发 `click`,参数包含事件 `e` 和节点属性 `item`。 + +这是基础实现,暂不支持 PC 端的全部属性和布局。 + +## 样式变量 + +可在时间轴或其祖先元素上覆盖以下 CSS 变量。圆点颜色使用节点的 `dot-color` 属性设置。 + +| 变量 | 默认值 | 说明 | +| --- | --- | --- | +| `--t-timeline-dot-size` | `.5rem` | 圆点宽高 | +| `--t-timeline-dot-border-width` | `2px` | 圆点边框宽度 | +| `--t-timeline-dot-background` | `var(--td-bg-color-container, #fff)` | 圆点背景 | +| `--t-timeline-line-width` | `2px` | 连接线粗细 | +| `--t-timeline-line-color` | `var(--td-component-border, #ddd)` | 连接线颜色 | +| `--t-timeline-line-gap` | `.25rem` | 连接线与圆点的间隙 | +| `--t-timeline-item-gap` | `1rem` | 纵向节点底部间距 | +| `--t-timeline-content-offset` | `1rem` | 纵向内容左侧偏移 | +| `--t-timeline-horizontal-offset` | `1.5rem` | 横向内容顶部偏移 | +| `--t-timeline-horizontal-gap` | `.75rem` | 横向节点右侧间距 | +| `--t-timeline-label-color` | `var(--td-text-color-secondary, #777)` | 时间标签颜色 | + +```css +.my-timeline { + --t-timeline-dot-size: .625rem; + --t-timeline-line-color: #aaa; + --t-timeline-item-gap: 1.5rem; +} +``` diff --git a/docs/demos/timeline/basic.vue b/docs/demos/timeline/basic.vue new file mode 100644 index 0000000..dfafbe1 --- /dev/null +++ b/docs/demos/timeline/basic.vue @@ -0,0 +1,10 @@ + + diff --git a/package.json b/package.json index 1b8d4c7..c42dcae 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "module": "./dist/timi-tdesign-mobile.mjs", "style": "./dist/timi-tdesign-mobile.css", "private": false, - "version": "1.1.1", + "version": "1.2.0", "license": "MIT", "scripts": { "dev": "pnpm run -C docs dev", diff --git a/src/components/index.ts b/src/components/index.ts index 5717dd8..4163f67 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -16,6 +16,7 @@ import NotifyView from "./notify-view"; import BottomPopup from "./bottom-popup"; import AttachmentSelector from "./attachment-selector"; import Space from "./space"; +import { Timeline, TimelineItem } from "./timeline"; import CardContainer from "./card-container"; import { AiChatComposer, @@ -42,6 +43,8 @@ export default [ BottomPopup, AttachmentSelector, Space, + Timeline, + TimelineItem, CardContainer, AiChatComposer, AiChatMessageList, @@ -67,6 +70,8 @@ export { BottomPopup, AttachmentSelector, Space, + Timeline, + TimelineItem, CardContainer, AiChatComposer, AiChatMessageList, diff --git a/src/components/timeline/index.ts b/src/components/timeline/index.ts new file mode 100644 index 0000000..ec2c334 --- /dev/null +++ b/src/components/timeline/index.ts @@ -0,0 +1,6 @@ +import { WebToolkit } from "timi-web"; +import timeline from "./index.vue"; +import item from "./item.vue"; + +export const Timeline = WebToolkit.withInstall(timeline); +export const TimelineItem = WebToolkit.withInstall(item); diff --git a/src/components/timeline/index.vue b/src/components/timeline/index.vue new file mode 100644 index 0000000..1d94083 --- /dev/null +++ b/src/components/timeline/index.vue @@ -0,0 +1,73 @@ + + + diff --git a/src/components/timeline/item.vue b/src/components/timeline/item.vue new file mode 100644 index 0000000..172b923 --- /dev/null +++ b/src/components/timeline/item.vue @@ -0,0 +1,58 @@ + + +