better list rendering

This commit is contained in:
syuilo 2021-04-15 20:26:02 +09:00
parent a0fd3aef98
commit c2b3436770

View file

@ -24,11 +24,9 @@ export default defineComponent({
methods: { methods: {
focus() { focus() {
this.$slots.default[0].elm.focus(); this.$slots.default[0].elm.focus();
}
}, },
render() { getDateText(time: string) {
const getDateText = (time: string) => {
const date = new Date(time).getDate(); const date = new Date(time).getDate();
const month = new Date(time).getMonth() + 1; const month = new Date(time).getMonth() + 1;
return this.$t('monthAndDay', { return this.$t('monthAndDay', {
@ -36,9 +34,13 @@ export default defineComponent({
day: date.toString() day: date.toString()
}); });
} }
},
render() {
const noGap = [...document.querySelectorAll('._noGap_')].some(el => el.contains(this.$parent.$el)); const noGap = [...document.querySelectorAll('._noGap_')].some(el => el.contains(this.$parent.$el));
if (this.items.length === 0) return;
return h(this.$store.state.animation ? TransitionGroup : 'div', this.$store.state.animation ? { return h(this.$store.state.animation ? TransitionGroup : 'div', this.$store.state.animation ? {
class: 'sqadhkmv' + (noGap ? ' _block' : ''), class: 'sqadhkmv' + (noGap ? ' _block' : ''),
name: 'list', name: 'list',
@ -72,10 +74,10 @@ export default defineComponent({
class: 'icon', class: 'icon',
icon: faAngleUp, icon: faAngleUp,
}), }),
getDateText(item.createdAt) this.getDateText(item.createdAt)
]), ]),
h('span', [ h('span', [
getDateText(this.items[i + 1].createdAt), this.getDateText(this.items[i + 1].createdAt),
h(FontAwesomeIcon, { h(FontAwesomeIcon, {
class: 'icon', class: 'icon',
icon: faAngleDown, icon: faAngleDown,