Refactor #4124 - Timeline pt context improvements
parent
cdc12de61b
commit
4e68875032
|
@ -1,18 +1,18 @@
|
|||
<template>
|
||||
<div :class="cx('root')" v-bind="ptm('root')" data-pc-name="timeline">
|
||||
<div v-for="(item, index) of value" :key="getKey(item, index)" :class="cx('event')" v-bind="ptm('event')">
|
||||
<div :class="cx('opposite')" v-bind="ptm('opposite')">
|
||||
<div v-for="(item, index) of value" :key="getKey(item, index)" :class="cx('event')" v-bind="getPTOptions('event', index)">
|
||||
<div :class="cx('opposite', { index })" v-bind="getPTOptions('opposite', index)">
|
||||
<slot name="opposite" :item="item" :index="index"></slot>
|
||||
</div>
|
||||
<div :class="cx('separator')" v-bind="ptm('separator')">
|
||||
<div :class="cx('separator')" v-bind="getPTOptions('separator', index)">
|
||||
<slot name="marker" :item="item" :index="index">
|
||||
<div :class="cx('marker')" v-bind="ptm('marker')"></div>
|
||||
<div :class="cx('marker')" v-bind="getPTOptions('marker', index)"></div>
|
||||
</slot>
|
||||
<slot v-if="index !== value.length - 1" name="connector" :item="item" :index="index">
|
||||
<div :class="cx('connector')" v-bind="ptm('connector')"></div>
|
||||
<div :class="cx('connector')" v-bind="getPTOptions('connector', index)"></div>
|
||||
</slot>
|
||||
</div>
|
||||
<div :class="cx('content')" v-bind="ptm('content')">
|
||||
<div :class="cx('content')" v-bind="getPTOptions('content', index)">
|
||||
<slot name="content" :item="item" :index="index"></slot>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -29,6 +29,14 @@ export default {
|
|||
methods: {
|
||||
getKey(item, index) {
|
||||
return this.dataKey ? ObjectUtils.resolveFieldData(item, this.dataKey) : index;
|
||||
},
|
||||
getPTOptions(key, index) {
|
||||
return this.ptm(key, {
|
||||
context: {
|
||||
index,
|
||||
count: this.value.length
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue