diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2023-01-13 18:25:40 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-13 18:25:40 +0900 |
| commit | d2204fd5c8fb2361e9c29ed31cd0d40eb69d2f4b (patch) | |
| tree | 3479f9cde6139af5cebf94cf6de005e16c404e21 /packages/frontend/src/components/MkDateSeparatedList.vue | |
| parent | Update CHANGELOG.md (diff) | |
| download | misskey-d2204fd5c8fb2361e9c29ed31cd0d40eb69d2f4b.tar.gz misskey-d2204fd5c8fb2361e9c29ed31cd0d40eb69d2f4b.tar.bz2 misskey-d2204fd5c8fb2361e9c29ed31cd0d40eb69d2f4b.zip | |
refactor: pagination/date-separated-list系処理を良い感じに? (#8209)
* pages/messaging/messaging-room.vue
* wip
* wip
* wip???
* wip?
* :v:
* messaaging-room.form.vue rewrite to compositon api
* refactor
* 関心事でないのでとりあえず置いておく
* :art:
* :art:
* i18n.ts
* fix scroll container find function
* fix
* FIX
* :v:
* Fix scroll bottom detect
* wip
* aaaaaaaaaaa
* rename
* fix
* fix?
* :v:
* :v:
* clean up
* clena up
* refactor
* scroll event once or not
* fix
* fix once
* add safe-area-inset-bottom to spacer
* fix
* :v:
* :art:
* fix
* fix
* wip
* :v:
* clean up
* fix lint
* Update packages/client/src/components/global/sticky-container.vue
Co-authored-by: Johann150 <johann.galle@protonmail.com>
* Update packages/client/src/components/ui/pagination.vue
Co-authored-by: Johann150 <johann.galle@protonmail.com>
* Update packages/client/src/pages/messaging/messaging-room.form.vue
Co-authored-by: Johann150 <johann.galle@protonmail.com>
* clean up: single line comment
* https://github.com/misskey-dev/misskey/pull/8209#discussion_r867386077
* fix
* asobi → tolerance
* pick form
* pick message
* pick room
* fix lint
* fix scroll?
* fix scroll.ts
* fix directives/sticky-container
* update global/sticky-container.vue
* fix, :art:
* revert merge
* :v:
* fix lint errors
* :art:
* Update packages/client/src/types/date-separated-list.ts
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
* https://github.com/misskey-dev/misskey/pull/8209#discussion_r917225080
* use '
* Update packages/client/src/scripts/scroll.ts
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
* use Number.EPSILON
Co-authored-by: acid-chicken <root@acid-chicken.com>
* revert
* fix
* fix
* Use % instead of vh
* :art:
* :art:
* :art:
* wip
* wip
* css modules
Co-authored-by: Johann150 <johann.galle@protonmail.com>
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Diffstat (limited to 'packages/frontend/src/components/MkDateSeparatedList.vue')
| -rw-r--r-- | packages/frontend/src/components/MkDateSeparatedList.vue | 188 |
1 files changed, 116 insertions, 72 deletions
diff --git a/packages/frontend/src/components/MkDateSeparatedList.vue b/packages/frontend/src/components/MkDateSeparatedList.vue index 5d8e14c3c8..cb88444d34 100644 --- a/packages/frontend/src/components/MkDateSeparatedList.vue +++ b/packages/frontend/src/components/MkDateSeparatedList.vue @@ -1,13 +1,14 @@ <script lang="ts"> -import { defineComponent, h, PropType, TransitionGroup } from 'vue'; +import { defineComponent, h, PropType, TransitionGroup, useCssModule } from 'vue'; import MkAd from '@/components/global/MkAd.vue'; import { i18n } from '@/i18n'; import { defaultStore } from '@/store'; +import { MisskeyEntity } from '@/types/date-separated-list'; export default defineComponent({ props: { items: { - type: Array as PropType<{ id: string; createdAt: string; _shouldInsertAd_: boolean; }[]>, + type: Array as PropType<MisskeyEntity[]>, required: true, }, direction: { @@ -33,6 +34,7 @@ export default defineComponent({ }, setup(props, { slots, expose }) { + const $style = useCssModule(); function getDateText(time: string) { const date = new Date(time).getDate(); const month = new Date(time).getMonth() + 1; @@ -57,21 +59,25 @@ export default defineComponent({ new Date(item.createdAt).getDate() !== new Date(props.items[i + 1].createdAt).getDate() ) { const separator = h('div', { - class: 'separator', + class: $style['separator'], key: item.id + ':separator', }, h('p', { - class: 'date', + class: $style['date'], }, [ - h('span', [ + h('span', { + class: $style['date-1'], + }, [ h('i', { - class: 'ti ti-chevron-up icon', + class: `ti ti-chevron-up ${$style['date-1-icon']}`, }), getDateText(item.createdAt), ]), - h('span', [ + h('span', { + class: $style['date-2'], + }, [ getDateText(props.items[i + 1].createdAt), h('i', { - class: 'ti ti-chevron-down icon', + class: `ti ti-chevron-down ${$style['date-2-icon']}`, }), ]), ])); @@ -89,100 +95,138 @@ export default defineComponent({ } }); + function onBeforeLeave(el: HTMLElement) { + el.style.top = `${el.offsetTop}px`; + el.style.left = `${el.offsetLeft}px`; + } + function onLeaveCanceled(el: HTMLElement) { + el.style.top = ''; + el.style.left = ''; + } + return () => h( defaultStore.state.animation ? TransitionGroup : 'div', - defaultStore.state.animation ? { - class: 'sqadhkmv' + (props.noGap ? ' noGap' : ''), - name: 'list', - tag: 'div', - 'data-direction': props.direction, - 'data-reversed': props.reversed ? 'true' : 'false', - } : { - class: 'sqadhkmv' + (props.noGap ? ' noGap' : ''), + { + class: { + [$style['date-separated-list']]: true, + [$style['date-separated-list-nogap']]: props.noGap, + [$style['reversed']]: props.reversed, + [$style['direction-down']]: props.direction === 'down', + [$style['direction-up']]: props.direction === 'up', + }, + ...(defaultStore.state.animation ? { + name: 'list', + tag: 'div', + onBeforeLeave, + onLeaveCanceled, + } : {}), }, { default: renderChildren }); }, }); </script> -<style lang="scss"> -.sqadhkmv { +<style lang="scss" module> +.date-separated-list { container-type: inline-size; - > *:empty { - display: none; + &:global { + > .list-move { + transition: transform 0.7s cubic-bezier(0.23, 1, 0.32, 1); } - > *:not(:last-child) { - margin-bottom: var(--margin); + &.deny-move-transition > .list-move { + transition: none !important; } - > .list-move { - transition: transform 0.7s cubic-bezier(0.23, 1, 0.32, 1); + > .list-leave-active, + > .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); } - > .list-enter-active { + > .list-leave-from, + > .list-leave-to, + > .list-leave-active { transition: transform 0.7s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1); + position: absolute !important; } - &[data-direction="up"] { - > .list-enter-from { - opacity: 0; - transform: translateY(64px); - } + > *:empty { + display: none; } - &[data-direction="down"] { - > .list-enter-from { - opacity: 0; - transform: translateY(-64px); + > *:not(:last-child) { + margin-bottom: var(--margin); + } + } +} + +.date-separated-list-nogap { + > * { + margin: 0 !important; + border: none; + border-radius: 0; + box-shadow: none; + + &:not(:last-child) { + border-bottom: solid 0.5px var(--divider); } } +} - > .separator { - text-align: center; +.direction-up { + &:global { + > .list-enter-from, + > .list-leave-to { + opacity: 0; + transform: translateY(64px); + } + } +} +.direction-down { + &:global { + > .list-enter-from, + > .list-leave-to { + opacity: 0; + transform: translateY(-64px); + } + } +} - > .date { - display: inline-block; - position: relative; - margin: 0; - padding: 0 16px; - line-height: 32px; - text-align: center; - font-size: 12px; - color: var(--dateLabelFg); +.reversed { + display: flex; + flex-direction: column-reverse; +} - > span { - &:first-child { - margin-right: 8px; +.separator { + text-align: center; +} - > .icon { - margin-right: 8px; - } - } +.date { + display: inline-block; + position: relative; + margin: 0; + padding: 0 16px; + line-height: 32px; + text-align: center; + font-size: 12px; + color: var(--dateLabelFg); +} - &:last-child { - margin-left: 8px; +.date-1 { + margin-right: 8px; +} - > .icon { - margin-left: 8px; - } - } - } - } - } +.date-1-icon { + margin-right: 8px; +} - &.noGap { - > * { - margin: 0 !important; - border: none; - border-radius: 0; - box-shadow: none; +.date-2 { + margin-left: 8px; +} - &:not(:last-child) { - border-bottom: solid 0.5px var(--divider); - } - } - } +.date-2-icon { + margin-left: 8px; } </style> + |