Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(timeline): add label slot #2591

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/web-vue/components/timeline/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ description: Display information content in chronological or reverse order.

@import ./__demo__/label.md

@import ./__demo__/custom.md

## API


Expand Down Expand Up @@ -62,5 +64,6 @@ description: Display information content in chronological or reverse order.
|Slot Name|Description|Parameters|
|---|---|---|
|dot|Custom dot|-|
|label|Custom label|-|


3 changes: 3 additions & 0 deletions packages/web-vue/components/timeline/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ description: 按照时间顺序或倒序规则的展示信息内容。

@import ./__demo__/label.md

@import ./__demo__/custom.md

## API


Expand Down Expand Up @@ -60,5 +62,6 @@ description: 按照时间顺序或倒序规则的展示信息内容。
|插槽名|描述|参数|
|---|:---:|---|
|dot|自定义节点|-|
|label|自定义标签|-|


2 changes: 2 additions & 0 deletions packages/web-vue/components/timeline/TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ description: Display information content in chronological or reverse order.

@import ./__demo__/label.md

@import ./__demo__/custom.md

## API

%%API(timeline.tsx)%%
Expand Down
35 changes: 35 additions & 0 deletions packages/web-vue/components/timeline/__demo__/custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
```yaml
title:
zh-CN: 自定义标签
en-US: Custom Label
```

## zh-CN

可以通过 `label` 插槽自定义标签

---

## en-US

You can customize labels through the 'label' slot

---

```vue
<template>
<a-timeline>
<a-timeline-item>
Code Review
<template #label>
<a-tag>
<template #icon>
<icon-check-circle-fill />
</template>
Passed
</a-tag>
</template>
</a-timeline-item>
</a-timeline>
</template>
```
11 changes: 9 additions & 2 deletions packages/web-vue/components/timeline/item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
<slot />
</div>
<div v-if="labelPosition !== 'relative'" :class="`${prefixCls}-label`">
{{ label }}
<slot v-if="$slots.label" name="label" />
<template v-else>{{ label }}</template>
</div>
</div>
<div v-if="labelPosition === 'relative'" :class="`${prefixCls}-label`">
{{ label }}
<slot v-if="$slots.label" name="label" />
<template v-else>{{ label }}</template>
</div>
</div>
</template>
Expand Down Expand Up @@ -106,6 +108,11 @@ export default defineComponent({
* @en Custom dot
* @slot dot
*/
/**
* @zh 自定义标签
* @en Custom label
* @slot label
*/
setup(props) {
const prefixCls = getPrefixCls('timeline-item');
const instance = getCurrentInstance();
Expand Down
Loading