diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-01-30 04:37:25 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-30 04:37:25 +0900 |
| commit | f6154dc0af1a0d65819e87240f4385f9573095cb (patch) | |
| tree | 699a5ca07d6727b7f8497d4769f25d6d62f94b5a /src/client/components/date-separated-list.vue | |
| parent | Add Event activity-type support (#5785) (diff) | |
| download | misskey-f6154dc0af1a0d65819e87240f4385f9573095cb.tar.gz misskey-f6154dc0af1a0d65819e87240f4385f9573095cb.tar.bz2 misskey-f6154dc0af1a0d65819e87240f4385f9573095cb.zip | |
v12 (#5712)
Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com>
Co-authored-by: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com>
Diffstat (limited to 'src/client/components/date-separated-list.vue')
| -rw-r--r-- | src/client/components/date-separated-list.vue | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/client/components/date-separated-list.vue b/src/client/components/date-separated-list.vue new file mode 100644 index 0000000000..00c3cd6643 --- /dev/null +++ b/src/client/components/date-separated-list.vue @@ -0,0 +1,94 @@ +<template> +<sequential-entrance class="sqadhkmv" ref="list" :direction="direction"> + <template v-for="(item, i) in items"> + <slot :item="item" :i="i"></slot> + <div class="separator" :key="item.id + '_date'" :data-index="i" v-if="i != items.length - 1 && new Date(item.createdAt).getDate() != new Date(items[i + 1].createdAt).getDate()"> + <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> +</sequential-entrance> +</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, + required: false + } + }, + + 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() + }); + }, + + focus() { + this.$refs.list.focus(); + } + } +}); +</script> + +<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; + border-radius: 64px; + background: var(--dateLabelBg); + color: var(--dateLabelFg); + + > span { + &:first-child { + margin-right: 8px; + + > .icon { + margin-right: 8px; + } + } + + &:last-child { + margin-left: 8px; + + > .icon { + margin-left: 8px; + } + } + } + } + } +} +</style> |