2020-01-29 21:37:25 +02:00
|
|
|
<script lang="ts">
|
2020-12-12 06:06:26 +02:00
|
|
|
import { defineComponent, h, TransitionGroup } from 'vue';
|
2020-01-29 21:37:25 +02:00
|
|
|
import { faAngleUp, faAngleDown } from '@fortawesome/free-solid-svg-icons';
|
2020-12-12 06:06:26 +02:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
export default defineComponent({
|
2020-01-29 21:37:25 +02:00
|
|
|
props: {
|
|
|
|
items: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
direction: {
|
|
|
|
type: String,
|
2020-02-21 02:11:35 +02:00
|
|
|
required: false,
|
|
|
|
default: 'down'
|
2020-02-06 07:23:01 +02:00
|
|
|
},
|
|
|
|
reversed: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-12-12 06:06:26 +02:00
|
|
|
methods: {
|
|
|
|
focus() {
|
|
|
|
this.$slots.default[0].elm.focus();
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
|
2020-12-12 06:06:26 +02:00
|
|
|
render() {
|
|
|
|
const getDateText = (time: string) => {
|
2020-01-29 21:37:25 +02:00
|
|
|
const date = new Date(time).getDate();
|
|
|
|
const month = new Date(time).getMonth() + 1;
|
|
|
|
return this.$t('monthAndDay', {
|
|
|
|
month: month.toString(),
|
|
|
|
day: date.toString()
|
|
|
|
});
|
2020-12-12 06:06:26 +02:00
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-12-12 06:06:26 +02:00
|
|
|
return h(this.$store.state.device.animation ? TransitionGroup : 'div', {
|
|
|
|
class: 'sqadhkmv _list_',
|
|
|
|
name: 'list',
|
|
|
|
tag: 'div',
|
|
|
|
'data-direction': this.direction,
|
|
|
|
'data-reversed': this.reversed ? 'true' : 'false',
|
|
|
|
}, this.items.map((item, i) => {
|
|
|
|
const el = this.$slots.default({
|
|
|
|
item: item
|
|
|
|
})[0];
|
|
|
|
el.key = item.id;
|
|
|
|
|
|
|
|
if (
|
2020-02-18 12:05:11 +02:00
|
|
|
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_ &&
|
2020-12-12 06:06:26 +02:00
|
|
|
!this.items[i + 1]._featuredId_
|
|
|
|
) {
|
|
|
|
const separator = h('div', {
|
|
|
|
class: 'separator',
|
|
|
|
key: item.id + ':separator',
|
|
|
|
}, h('p', {
|
|
|
|
class: 'date'
|
|
|
|
}, [
|
|
|
|
h('span', [
|
|
|
|
h(FontAwesomeIcon, {
|
|
|
|
class: 'icon',
|
|
|
|
icon: faAngleUp,
|
|
|
|
}),
|
|
|
|
getDateText(item.createdAt)
|
|
|
|
]),
|
|
|
|
h('span', [
|
|
|
|
getDateText(this.items[i + 1].createdAt),
|
|
|
|
h(FontAwesomeIcon, {
|
|
|
|
class: 'icon',
|
|
|
|
icon: faAngleDown,
|
|
|
|
})
|
|
|
|
])
|
|
|
|
]));
|
|
|
|
|
|
|
|
return [el, separator];
|
|
|
|
} else {
|
|
|
|
return el;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
},
|
2020-01-29 21:37:25 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-02-21 02:11:35 +02:00
|
|
|
<style lang="scss">
|
|
|
|
.sqadhkmv {
|
2020-07-04 15:07:45 +03:00
|
|
|
> *:not(:last-child) {
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
|
|
|
|
2020-02-21 02:11:35 +02:00
|
|
|
> .list-move {
|
|
|
|
transition: transform 0.7s cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
|
2020-03-20 11:55:15 +02: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 02:11:35 +02:00
|
|
|
&[data-direction="up"] {
|
2020-10-17 14:12:00 +03:00
|
|
|
> .list-enter-from {
|
2020-02-21 02:11:35 +02:00
|
|
|
opacity: 0;
|
|
|
|
transform: translateY(64px);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&[data-direction="down"] {
|
2020-10-17 14:12:00 +03:00
|
|
|
> .list-enter-from {
|
2020-02-21 02:11:35 +02:00
|
|
|
opacity: 0;
|
|
|
|
transform: translateY(-64px);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2020-12-12 06:06:26 +02:00
|
|
|
<style lang="scss">
|
2020-01-29 21:37:25 +02:00
|
|
|
.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>
|