2020-01-29 20:37:25 +01:00
|
|
|
<script lang="ts">
|
2020-12-12 05:06:26 +01:00
|
|
|
import { defineComponent, h, TransitionGroup } from 'vue';
|
2020-01-29 20:37:25 +01:00
|
|
|
import { faAngleUp, faAngleDown } from '@fortawesome/free-solid-svg-icons';
|
2020-12-12 05:06:26 +01:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
2020-01-29 20:37:25 +01:00
|
|
|
props: {
|
|
|
|
items: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
direction: {
|
|
|
|
type: String,
|
2020-02-21 01:11:35 +01:00
|
|
|
required: false,
|
|
|
|
default: 'down'
|
2020-02-06 06:23:01 +01:00
|
|
|
},
|
|
|
|
reversed: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-12-12 05:06:26 +01:00
|
|
|
methods: {
|
|
|
|
focus() {
|
|
|
|
this.$slots.default[0].elm.focus();
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
2020-12-12 05:06:26 +01:00
|
|
|
render() {
|
|
|
|
const getDateText = (time: string) => {
|
2020-01-29 20:37:25 +01: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 05:06:26 +01:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2020-12-12 05:06:26 +01: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 11:05:11 +01: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 05:06:26 +01: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 20:37:25 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-02-21 01:11:35 +01:00
|
|
|
<style lang="scss">
|
|
|
|
.sqadhkmv {
|
2020-07-04 14:07:45 +02:00
|
|
|
> *:not(:last-child) {
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
|
|
|
|
2020-02-21 01:11:35 +01:00
|
|
|
> .list-move {
|
|
|
|
transition: transform 0.7s cubic-bezier(0.23, 1, 0.32, 1);
|
|
|
|
}
|
|
|
|
|
2020-03-20 10:55:15 +01: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 01:11:35 +01:00
|
|
|
&[data-direction="up"] {
|
2020-10-17 13:12:00 +02:00
|
|
|
> .list-enter-from {
|
2020-02-21 01:11:35 +01:00
|
|
|
opacity: 0;
|
|
|
|
transform: translateY(64px);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&[data-direction="down"] {
|
2020-10-17 13:12:00 +02:00
|
|
|
> .list-enter-from {
|
2020-02-21 01:11:35 +01:00
|
|
|
opacity: 0;
|
|
|
|
transform: translateY(-64px);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2020-12-12 05:06:26 +01:00
|
|
|
<style lang="scss">
|
2020-01-29 20:37:25 +01: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>
|