Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38038b9461 | ||
|
|
a50f134b25 | ||
|
|
f8140bb70b | ||
|
|
9e06f1e9b8 | ||
|
|
0a23f0e3b9 | ||
|
|
f709a8faed | ||
|
|
0f369dc42d | ||
|
|
dd303e1781 | ||
|
|
bed8b65092 |
@@ -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",
|
||||
|
||||
@@ -61,6 +61,8 @@ async function onChangeTab(value: string) {
|
||||
|
||||
`AppShell` 只负责导航形态与容器尺寸,不接管路由。`v-model` 与 `change` 都只是把点击结果交回业务,跳不跳、跳去哪里由业务决定。
|
||||
|
||||
点击未禁用的左侧导航项时,`rail-click` 会传出该项的值,包括已激活的导航项。该事件表示点击,不受 `before-change` 控制;切换是否被允许仍由 `before-change` 和 `change` 决定。
|
||||
|
||||
## 平板布局
|
||||
|
||||
`tablet` 默认 `true`——引入 `AppShell` 就意味着要手机和平板两端。真有项目只需要容器能力、暂不响应式,传 `:tablet="false"` 即可退回纯手机布局。
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,10 @@
|
||||
<template>
|
||||
<t-timeline>
|
||||
<t-timeline-item label="2026-11-11" content="提交订单" />
|
||||
<t-timeline-item label="2026-11-12" dot-color="warning">正在配送</t-timeline-item>
|
||||
<t-timeline-item label="2026-11-13" dot-color="default">等待签收</t-timeline-item>
|
||||
</t-timeline>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { Timeline as TTimeline, TimelineItem as TTimelineItem } from "timi-tdesign-mobile";
|
||||
</script>
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
"module": "./dist/timi-tdesign-mobile.mjs",
|
||||
"style": "./dist/timi-tdesign-mobile.css",
|
||||
"private": false,
|
||||
"version": "1.1.1",
|
||||
"version": "1.3.1",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "pnpm run -C docs dev",
|
||||
|
||||
@@ -6,6 +6,19 @@
|
||||
*/
|
||||
:root {
|
||||
--tui-split-duration: 320ms;
|
||||
|
||||
/**
|
||||
* 安全区统一入口,四个方向都从这里取。
|
||||
*
|
||||
* --safe-area-inset-* 由 Capacitor 原生层按 WindowInsets 注入:Android WebView
|
||||
* 不实现 env(safe-area-inset-*),恒返回 0,只有原生注入的变量才是真实值。
|
||||
* iOS / 浏览器没有这套变量,回退到 env()。
|
||||
* 使用方要自己接管安全区时,覆盖这几个 --tui-safe-* 即可。
|
||||
*/
|
||||
--tui-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
|
||||
--tui-safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
|
||||
--tui-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
|
||||
--tui-safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,6 +31,11 @@
|
||||
*
|
||||
* .tui-page-content 使用绝对定位铺满上级容器,因此上级必须是
|
||||
* PageTransition 渲染出的定位容器,不要在普通 div 中直接使用。
|
||||
*
|
||||
* 顶部安全区从 --tui-safe-top 取(定义在 :root,Capacitor 注入优先、env() 兜底)。
|
||||
* 这个取值能成立的前提是窗口真的 edge-to-edge:Android 15+ 由系统强制,
|
||||
* Android 15 以下需要在 MainActivity 里调 WindowCompat.setDecorFitsSystemWindows(false)。
|
||||
* 窗口没全屏却按全屏补安全区,顶部就会多出一条状态栏高度的空白。
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -32,7 +50,7 @@
|
||||
box-sizing: border-box;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-top: var(--tui-detail-empty-inset, calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 48px));
|
||||
padding-top: var(--tui-detail-empty-inset, calc(var(--tui-safe-top, 0px) + 48px));
|
||||
// 必须有不透明背景:切换视图时它和旧内容同时在场,
|
||||
// 透明的话提示文字会浮在还在滑出的页面上,看起来像重影。
|
||||
background: var(--tui-detail-empty-background, var(--td-bg-color-page));
|
||||
@@ -54,8 +72,8 @@
|
||||
position: absolute;
|
||||
min-height: 0;
|
||||
box-sizing: border-box;
|
||||
padding-top: calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 48px + 1rem);
|
||||
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
|
||||
padding-top: calc(var(--tui-safe-top, 0px) + 48px + 1rem);
|
||||
padding-bottom: calc(var(--tui-safe-bottom, 0px) + 1rem);
|
||||
flex-direction: column;
|
||||
|
||||
&.scroll {
|
||||
@@ -75,8 +93,8 @@
|
||||
}
|
||||
|
||||
&.tui-navbar {
|
||||
--tui-nav-height: calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 48px);
|
||||
--td-navbar-padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
|
||||
--tui-nav-height: calc(var(--tui-safe-top, 0px) + 48px);
|
||||
--td-navbar-padding-top: var(--tui-safe-top, 0px);
|
||||
|
||||
.t-navbar__content,
|
||||
.t-navbar__placeholder {
|
||||
@@ -110,7 +128,7 @@
|
||||
.tui-app-shell.is-rail {
|
||||
|
||||
.rail {
|
||||
padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
|
||||
padding-top: var(--tui-safe-top, 0px);
|
||||
}
|
||||
|
||||
.t-navbar--fixed .t-navbar__content {
|
||||
|
||||
@@ -173,7 +173,7 @@ defineExpose({
|
||||
flex: none;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
padding: var(--ai-msg-padding-top, .5rem) 1rem calc(var(--ai-chat-bottom-area-height, 4.5rem) + 1.5rem + env(safe-area-inset-bottom, 0px));
|
||||
padding: var(--ai-msg-padding-top, .5rem) 1rem calc(var(--ai-chat-bottom-area-height, 4.5rem) + 1.5rem + var(--tui-safe-bottom, 0px));
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
box-sizing: border-box;
|
||||
|
||||
@@ -215,7 +215,7 @@ defineExpose({
|
||||
flex-direction: column;
|
||||
|
||||
.bottom-area {
|
||||
inset: auto 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
|
||||
inset: auto 1rem calc(1rem + var(--tui-safe-bottom, 0px));
|
||||
width: auto;
|
||||
margin: 0 auto;
|
||||
z-index: 2;
|
||||
|
||||
@@ -90,6 +90,7 @@ const props = withDefaults(defineProps<AppShellProps>(), {
|
||||
const emit = defineEmits<{
|
||||
"update:modelValue": [value: AppShellValue];
|
||||
"change": [value: AppShellValue];
|
||||
"rail-click": [value: AppShellValue];
|
||||
}>();
|
||||
|
||||
defineSlots<{
|
||||
@@ -164,6 +165,7 @@ function onSelect(item: AppShellItem): void {
|
||||
return;
|
||||
}
|
||||
|
||||
emit("rail-click", item.value);
|
||||
void requestChange(item.value);
|
||||
}
|
||||
|
||||
@@ -209,7 +211,7 @@ function onTabChange(value: AppShellValue): void {
|
||||
position: relative;
|
||||
overflow-y: auto;
|
||||
flex-direction: column;
|
||||
padding-left: env(safe-area-inset-left, 0);
|
||||
padding-left: var(--tui-safe-left, 0);
|
||||
border-right: 1px solid var(--td-component-border);
|
||||
background: var(--tui-rail-background, var(--td-bg-color-container));
|
||||
|
||||
@@ -260,7 +262,7 @@ function onTabChange(value: AppShellValue): void {
|
||||
|
||||
.rail-extra {
|
||||
margin-top: auto;
|
||||
padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0));
|
||||
padding-bottom: calc(.75rem + var(--tui-safe-bottom, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +272,7 @@ function onTabChange(value: AppShellValue): void {
|
||||
|
||||
flex: none;
|
||||
border-top: 1px solid var(--td-component-border);
|
||||
padding-bottom: env(safe-area-inset-bottom, 0);
|
||||
padding-bottom: var(--tui-safe-bottom, 0);
|
||||
background: var(--tui-tabbar-background, var(--td-bg-color-container));
|
||||
|
||||
:deep(.t-tab-bar-item) {
|
||||
|
||||
@@ -135,7 +135,7 @@ defineSlots<BottomPopupSlots>();
|
||||
|
||||
.body {
|
||||
flex: 1;
|
||||
padding: 0 0 env(safe-area-inset-bottom, 0);
|
||||
padding: 0 0 var(--tui-safe-bottom, 0);
|
||||
overflow: auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<div class="t-timeline" :class="{ horizontal: layout === 'horizontal', reverse }">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
defineOptions({ name: "TTimeline" });
|
||||
withDefaults(defineProps<{ layout?: "vertical" | "horizontal"; reverse?: boolean }>(), {
|
||||
layout: "vertical",
|
||||
reverse: false
|
||||
});
|
||||
</script>
|
||||
<style lang="less">
|
||||
.t-timeline {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
&.reverse {
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
|
||||
&.horizontal {
|
||||
flex-direction: row;
|
||||
|
||||
&.reverse {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.t-timeline-item {
|
||||
flex: 1;
|
||||
padding: var(--t-timeline-horizontal-offset, 1.5rem) var(--t-timeline-horizontal-gap, .75rem) 0 0;
|
||||
}
|
||||
|
||||
.t-timeline-item::before {
|
||||
top: calc((var(--t-timeline-dot-size, .5rem) - var(--t-timeline-line-width, 2px)) / 2);
|
||||
left: calc(var(--t-timeline-dot-size, .5rem) + var(--t-timeline-line-gap, .25rem));
|
||||
width: calc(100% - var(--t-timeline-dot-size, .5rem) - var(--t-timeline-line-gap, .25rem) - var(--t-timeline-line-gap, .25rem));
|
||||
height: var(--t-timeline-line-width, 2px);
|
||||
}
|
||||
|
||||
.t-timeline-item .dot {
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.t-timeline-item {
|
||||
position: relative;
|
||||
padding: 0 0 var(--t-timeline-item-gap, 1rem) var(--t-timeline-content-offset, 1rem);
|
||||
|
||||
&::before {
|
||||
position: absolute;
|
||||
top: calc(1lh / 2 + var(--t-timeline-dot-size, .5rem) / 2 + var(--t-timeline-line-gap, .25rem));
|
||||
bottom: calc(var(--t-timeline-dot-size, .5rem) / 2 + var(--t-timeline-line-gap, .25rem) - 1lh / 2);
|
||||
left: calc((var(--t-timeline-dot-size, .5rem) - var(--t-timeline-line-width, 2px)) / 2);
|
||||
width: var(--t-timeline-line-width, 2px);
|
||||
content: "";
|
||||
background: var(--t-timeline-line-color, var(--td-component-border, #ddd));
|
||||
}
|
||||
|
||||
&:last-child::before {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.reverse .t-timeline-item:last-child::before {
|
||||
display: block;
|
||||
}
|
||||
|
||||
&.reverse .t-timeline-item:first-child::before {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div class="t-timeline-item" @click="onClick">
|
||||
<span class="dot" :style="{ color: color }">
|
||||
<slot name="dot" />
|
||||
</span>
|
||||
<div v-if="label || $slots.label" class="label">
|
||||
<slot name="label">
|
||||
<span v-text="label" />
|
||||
</slot>
|
||||
</div>
|
||||
<div>
|
||||
<slot name="content">
|
||||
<slot>
|
||||
<span v-text="content" />
|
||||
</slot>
|
||||
</slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
defineOptions({ name: "TTimelineItem" });
|
||||
const props = withDefaults(defineProps<{
|
||||
label?: string;
|
||||
content?: string;
|
||||
dotColor?: string
|
||||
}>(), { dotColor: "primary" });
|
||||
const emit = defineEmits<{ click: [context: { e: MouseEvent; item: typeof props }] }>();
|
||||
const colors: Record<string, string> = {
|
||||
primary: "var(--td-brand-color, #0052d9)",
|
||||
warning: "#ed7b2f",
|
||||
error: "#d54941",
|
||||
default: "#bbb"
|
||||
};
|
||||
const color = computed(() => colors[props.dotColor] ?? props.dotColor);
|
||||
|
||||
function onClick(e: MouseEvent): void {
|
||||
emit("click", { e, item: props });
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.dot {
|
||||
position: absolute;
|
||||
top: calc((1lh - var(--t-timeline-dot-size, .5rem)) / 2);
|
||||
left: 0;
|
||||
width: var(--t-timeline-dot-size, .5rem);
|
||||
height: var(--t-timeline-dot-size, .5rem);
|
||||
border: var(--t-timeline-dot-border-width, 2px) solid currentColor;
|
||||
box-sizing: border-box;
|
||||
background: var(--t-timeline-dot-background, var(--td-bg-color-container, #fff));
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.label {
|
||||
color: var(--t-timeline-label-color, var(--td-text-color-secondary, #777));
|
||||
}
|
||||
</style>
|
||||
@@ -142,7 +142,7 @@ async function onConfirm() {
|
||||
<style lang="less" scoped>
|
||||
.popup {
|
||||
margin: 0;
|
||||
padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
|
||||
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px));
|
||||
background: var(--td-bg-color-container);
|
||||
|
||||
.field {
|
||||
|
||||
@@ -101,7 +101,7 @@ function onConfirm() {
|
||||
<style lang="less" scoped>
|
||||
.link-form {
|
||||
gap: .75rem;
|
||||
padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
|
||||
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px));
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ async function onConfirm() {
|
||||
<style lang="less" scoped>
|
||||
.popup {
|
||||
margin: 0;
|
||||
padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
|
||||
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px));
|
||||
overflow-y: auto;
|
||||
background: var(--td-bg-color-container);
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ watch(() => props.active, (active) => {
|
||||
|
||||
<style lang="less" scoped>
|
||||
.table-picker {
|
||||
padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
|
||||
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px));
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
background: var(--td-bg-color-container, #fff);
|
||||
|
||||
@@ -520,7 +520,7 @@ function confirmColor() {
|
||||
|
||||
.heading-picker {
|
||||
width: min(22rem, calc(100vw - 2rem));
|
||||
padding: .5rem .75rem calc(.5rem + env(safe-area-inset-bottom));
|
||||
padding: .5rem .75rem calc(.5rem + var(--tui-safe-bottom, 0px));
|
||||
}
|
||||
|
||||
.color-picker-popup {
|
||||
|
||||
Reference in New Issue
Block a user