2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2020-03-20 09:55:15 +00:00
|
|
|
<component :is="$store.state.device.animation ? 'transition-group' : 'div'" class="sqadhkmv" name="list" tag="div" :data-direction="direction" :data-reversed="reversed ? 'true' : 'false'">
|
2020-01-29 19:37:25 +00:00
|
|
|
<template v-for="(item, i) in items">
|
|
|
|
<slot :item="item" :i="i"></slot>
|
2020-02-18 10:05:11 +00:00
|
|
|
<div class="separator" :key="item.id + '_date'" v-if="showDate(i, item)">
|
2020-01-29 19:37:25 +00:00
|
|
|
<p class="date">
|
|
|
|
<span><fa class="icon" :icon="faAngleUp"/>{{ getDateText(item.createdAt) }}</span>
|
|
|
|
<span>{{ getDateText(items[i + 1].createdAt) }}<fa class="icon" :icon="faAngleDown"/></span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</template>
|
2020-02-21 00:11:35 +00:00
|
|
|
</component>
|
2020-01-29 19:37:25 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import { faAngleUp, faAngleDown } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import i18n from '../i18n';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
i18n,
|
|
|
|
|
|
|
|
props: {
|
|
|
|
items: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
direction: {
|
|
|
|
type: String,
|
2020-02-21 00:11:35 +00:00
|
|
|
required: false,
|
|
|
|
default: 'down'
|
2020-02-06 05:23:01 +00:00
|
|
|
},
|
|
|
|
reversed: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
faAngleUp, faAngleDown
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
getDateText(time: string) {
|
|
|
|
const date = new Date(time).getDate();
|
|
|
|
const month = new Date(time).getMonth() + 1;
|
|
|
|
return this.$t('monthAndDay', {
|
|
|
|
month: month.toString(),
|
|
|
|
day: date.toString()
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-02-18 10:05:11 +00:00
|
|
|
showDate(i, item) {
|
|
|
|
return (
|
|
|
|
i != this.items.length - 1 &&
|
|
|
|
new Date(item.createdAt).getDate() != new Date(this.items[i + 1].createdAt).getDate() &&
|
|
|
|
!item._prId_ &&
|
|
|
|
!this.items[i + 1]._prId_ &&
|
|
|
|
!item._featuredId_ &&
|
|
|
|
!this.items[i + 1]._featuredId_);
|
|
|
|
},
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
focus() {
|
2020-02-21 00:11:35 +00:00
|
|
|
this.$slots.default[0].elm.focus();
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-02-21 00:11:35 +00:00
|
|
|
<style lang="scss">
|
|
|
|
.sqadhkmv {
|
|
|
|
> .list-move {
|
|
|
|
transition: transform 0.7s cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
|
2020-03-20 09:55:15 +00:00
|
|
|
> .list-enter-active {
|
|
|
|
transition: transform 0.7s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
|
2020-02-21 00:11:35 +00:00
|
|
|
&[data-direction="up"] {
|
|
|
|
> .list-enter {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateY(64px);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&[data-direction="down"] {
|
|
|
|
> .list-enter {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateY(-64px);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.sqadhkmv {
|
|
|
|
> .separator {
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
> .date {
|
|
|
|
display: inline-block;
|
|
|
|
position: relative;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0 16px;
|
|
|
|
line-height: 32px;
|
|
|
|
text-align: center;
|
|
|
|
font-size: 12px;
|
|
|
|
color: var(--dateLabelFg);
|
|
|
|
|
|
|
|
> span {
|
|
|
|
&:first-child {
|
|
|
|
margin-right: 8px;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
margin-left: 8px;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
margin-left: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|