Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

リアクションをホバーしたときに拡大して表示 #4434

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c1c88b5
リアクションのホバー時に拡大表示する機能の追加
Jan 3, 2025
8d05380
ホバー時、リアクションした人も分かるように
Jan 4, 2025
acd6832
format
Pugma Jan 4, 2025
0101b00
titleを削除
Jan 5, 2025
ec87df5
aria-label属性を追加(フォーマットはDiscordに合わせた)
Jan 5, 2025
e50a748
rum formatで引っかかったので修正
Jan 5, 2025
6bbdefe
コードを整形
Jan 5, 2025
7c3878d
ポップアップが画面の端に来ると表示が壊れる不具合の修正およびポップアップがツールバーより上に来るように修正
UnABC Jan 6, 2025
dfe59a5
リアクションした人数が多い場合に「他n人」と圧縮
UnABC Jan 12, 2025
2544496
リアクションした人一覧で余分な空白が出来る問題を軽減
UnABC Jan 12, 2025
862f88f
ホバーした0.5秒後にポップアップが出るように調整
UnABC Jan 13, 2025
5ee9bac
formatの調整
UnABC Jan 13, 2025
108c4c1
モバイル版においてホバーによる拡大を無効化
Jan 14, 2025
b5850d4
StampScaledDetailElementのspan要素をscript部で記述など
UnABC Jan 15, 2025
3a771c4
ポップアップをDiscordと同じような感じに変更
UnABC Jan 18, 2025
646c014
conflictの解消
UnABC Jan 18, 2025
f19b322
拡大表示内容に誤りがあったので修正
UnABC Jan 19, 2025
5087384
format
UnABC Jan 19, 2025
e379fa0
画面端で見切れる問題を修正、UIの微調整
UnABC Feb 15, 2025
b84cbfa
Merge branch 'master' into issue4299
Pugma Feb 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<div v-for="stamp in stampList" :key="stamp.id" :class="$style.stamp">
<stamp-element
:stamp="stamp"
:is-detail-shown="isDetailShown"

Check warning on line 20 in src/components/Main/MainView/MessageElement/MessageStampList.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/MessageStampList.vue#L20

Added line #L20 was not covered by tests
@add-stamp="addStamp"
@remove-stamp="removeStamp"
/>
Expand Down
59 changes: 52 additions & 7 deletions src/components/Main/MainView/MessageElement/StampElement.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<template>
<div
ref="stampRoot"

Check warning on line 3 in src/components/Main/MainView/MessageElement/StampElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampElement.vue#L3

Added line #L3 was not covered by tests
:class="$style.body"
:title="tooltip"
:aria-label="tooltip"

Check warning on line 5 in src/components/Main/MainView/MessageElement/StampElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampElement.vue#L5

Added line #L5 was not covered by tests
:data-include-me="$boolAttr(includeMe)"
@click="onClick"
@mouseenter="onMouseEnter"
@mouseleave="onMouseLeave"

Check warning on line 9 in src/components/Main/MainView/MessageElement/StampElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampElement.vue#L8-L9

Added lines #L8 - L9 were not covered by tests
>
<transition name="stamp-pressed" mode="out-in">
<a-stamp
Expand All @@ -15,38 +18,44 @@
</transition>
<spin-number :value="stamp.sum" :class="$style.count" />
</div>
<stamp-scaled-element
:class="$style.scaleReaction"
:show="isHovered && isLongHovered && !isDetailShown && !isMobile"
:stamp="stamp"
:target-rect="hoveredRect"
/>

Check warning on line 26 in src/components/Main/MainView/MessageElement/StampElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampElement.vue#L21-L26

Added lines #L21 - L26 were not covered by tests
</template>

<script lang="ts" setup>
import SpinNumber from '/@/components/UI/SpinNumber.vue'
import AStamp from '/@/components/UI/AStamp.vue'
import { ref, computed, watch, onMounted } from 'vue'
import { useStampsStore } from '/@/store/entities/stamps'
import { useUsersStore } from '/@/store/entities/users'
import { useResponsiveStore } from '/@/store/ui/responsive'

Check warning on line 34 in src/components/Main/MainView/MessageElement/StampElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampElement.vue#L34

Added line #L34 was not covered by tests
import type { MessageStampById } from '/@/lib/messageStampList'
import StampScaledElement from './StampScaledElement.vue'
import useHover from '/@/composables/dom/useHover'

Check warning on line 37 in src/components/Main/MainView/MessageElement/StampElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampElement.vue#L36-L37

Added lines #L36 - L37 were not covered by tests

const props = defineProps<{
stamp: MessageStampById
isDetailShown: boolean
}>()

const emit = defineEmits<{
(e: 'addStamp', _stampId: string): void
(e: 'removeStamp', _stampId: string): void
}>()

const { isMobile } = useResponsiveStore()

Check warning on line 49 in src/components/Main/MainView/MessageElement/StampElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampElement.vue#L49

Added line #L49 was not covered by tests
const { stampsMap } = useStampsStore()
const { usersMap } = useUsersStore()

const stampName = computed(
() => stampsMap.value.get(props.stamp.id)?.name ?? ''
)

const tooltip = computed(() =>
[
`:${stampName.value}:`,
...props.stamp.users.map(
u => `${usersMap.value.get(u.id)?.displayName ?? ''}(${u.count})`
)
`${stampName.value}, ${props.stamp.sum}件のリアクション, クリック/タップでリアクションを削除`

Check warning on line 58 in src/components/Main/MainView/MessageElement/StampElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampElement.vue#L58

Added line #L58 was not covered by tests
].join(' ')
)

Expand Down Expand Up @@ -85,6 +94,28 @@
isProgress.value = false
}
)

const { isHovered, onMouseEnter, onMouseLeave } = useHover()
const hoverTimeout = ref<ReturnType<typeof setTimeout> | null>(null)
const isLongHovered = ref(false)
const stampRoot = ref<HTMLElement | null>(null)
const hoveredRect = ref<DOMRect | undefined>(undefined)

Check warning on line 102 in src/components/Main/MainView/MessageElement/StampElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampElement.vue#L98-L102

Added lines #L98 - L102 were not covered by tests

watch(isHovered, beginHover => {
if (beginHover) {
hoveredRect.value = stampRoot.value?.getBoundingClientRect() ?? undefined
hoverTimeout.value = setTimeout(() => {
isLongHovered.value = true
}, 500)
} else {
hoveredRect.value = undefined
if (hoverTimeout.value) {
clearTimeout(hoverTimeout.value)
hoverTimeout.value = null
}
isLongHovered.value = false
}
})

Check warning on line 118 in src/components/Main/MainView/MessageElement/StampElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampElement.vue#L104-L118

Added lines #L104 - L118 were not covered by tests
</script>

<style lang="scss" module>
Expand Down Expand Up @@ -118,4 +149,18 @@
right: 4px;
}
}

.scaleReaction {
@include background-tertiary;
display: flex;
align-items: center;
padding: 0.125rem 0.25rem;
border-radius: 0.25rem;
user-select: none;
overflow: visible;
contain: content;
position: absolute;
bottom: 105%;
z-index: $z-index-message-element-scaled-stamp;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<div :class="$style.container">
{{ detailContents }}
</div>

Check warning on line 4 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L2-L4

Added lines #L2 - L4 were not covered by tests
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import { useStampsStore } from '/@/store/entities/stamps'

Check warning on line 9 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L8-L9

Added lines #L8 - L9 were not covered by tests
import type { StampUser, MessageStampById } from '/@/lib/messageStampList'
import { useUsersStore } from '/@/store/entities/users'

Check warning on line 11 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L11

Added line #L11 was not covered by tests

const props = defineProps<{

Check warning on line 13 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L13

Added line #L13 was not covered by tests
stamp: MessageStampById
}>()

const { stampsMap } = useStampsStore()

Check warning on line 17 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L17

Added line #L17 was not covered by tests

const limitedUsers = computed(() => props.stamp.users.slice(0, 3))
const { usersMap } = useUsersStore()

Check warning on line 20 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L19-L20

Added lines #L19 - L20 were not covered by tests

const stampName = computed(
() => stampsMap.value.get(props.stamp.id)?.name ?? ''
)

Check warning on line 24 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L22-L24

Added lines #L22 - L24 were not covered by tests

const isLastUser = (user: StampUser) =>
user === props.stamp.users[Math.min(props.stamp.users.length - 1, 2)]

Check warning on line 27 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L26-L27

Added lines #L26 - L27 were not covered by tests

const isSecondLastUser = (user: StampUser) =>
user === props.stamp.users[Math.min(props.stamp.users.length - 2, 1)]

Check warning on line 30 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L29-L30

Added lines #L29 - L30 were not covered by tests

const isOverLimitUser = (user: StampUser) =>
user === props.stamp.users[2] && props.stamp.users.length > 3

Check warning on line 33 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L32-L33

Added lines #L32 - L33 were not covered by tests

const isOverLimitSecondUser = (user: StampUser) =>
user === props.stamp.users[1] && props.stamp.users.length > 3

Check warning on line 36 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L35-L36

Added lines #L35 - L36 were not covered by tests

const detailContents = computed(() => {
let message = `:${stampName.value}: が `
limitedUsers.value.forEach((user, index) => {
message += `${usersMap.value.get(user.id)?.displayName ?? 'unknown'}`
message += user.count > 1 ? `(${user.count})` : ''
if (
(!isLastUser(user) && !isSecondLastUser(user)) ||
isOverLimitSecondUser(user)
) {
message += '、'
} else if (isSecondLastUser(user) && !isOverLimitSecondUser(user)) {
message += 'と'
} else if (isOverLimitUser(user)) {
message += `と他${props.stamp.users.length - 3}人`
}
if (isLastUser(user)) {
message += 'にリアクションされました'
}
})
return message
})

Check warning on line 58 in src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledDetailElement.vue#L38-L58

Added lines #L38 - L58 were not covered by tests
</script>

<style lang="scss" module>
.container {
display: flex;
flex-wrap: wrap;
}
.contents {
display: flex;
}
.content {
padding: 0 0.2rem;
}
</style>
87 changes: 87 additions & 0 deletions src/components/Main/MainView/MessageElement/StampScaledElement.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<template>
<teleport to="#stamp-picker-popup">
<div
v-show="show"
ref="containerEle"
:class="$style.scaleReaction"
:style="stylePosition"

Check warning on line 7 in src/components/Main/MainView/MessageElement/StampScaledElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledElement.vue#L2-L7

Added lines #L2 - L7 were not covered by tests
>
<transition name="scale-reaction">

Check warning on line 9 in src/components/Main/MainView/MessageElement/StampScaledElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledElement.vue#L9

Added line #L9 was not covered by tests
<!-- sizeを46より大きくすると見切れる -->
<a-stamp
:key="stamp.id"
:stamp-id="stamp.id"
:size="50"
:class="$style.stamp"
without-title
/>
</transition>
<stamp-detail-element :class="$style.detail" :stamp="stamp" />
</div>
</teleport>

Check warning on line 21 in src/components/Main/MainView/MessageElement/StampScaledElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledElement.vue#L11-L21

Added lines #L11 - L21 were not covered by tests
</template>

<script lang="ts" setup>
import { computed, ref } from 'vue'
import AStamp from '/@/components/UI/AStamp.vue'

Check warning on line 26 in src/components/Main/MainView/MessageElement/StampScaledElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledElement.vue#L25-L26

Added lines #L25 - L26 were not covered by tests
import type { MessageStampById } from '/@/lib/messageStampList'
import StampDetailElement from './StampScaledDetailElement.vue'
const props = defineProps<{

Check warning on line 29 in src/components/Main/MainView/MessageElement/StampScaledElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledElement.vue#L28-L29

Added lines #L28 - L29 were not covered by tests
stamp: MessageStampById
show: boolean
targetRect?: DOMRect
}>()

const containerEle = ref<HTMLDivElement>()
const stylePosition = computed(() => {
if (!props.targetRect) return { display: 'none' }
const width = 340
return {
top: `${props.targetRect.top}px`,
left: `min(calc(100% - ${width}px), ${props.targetRect.left}px)`,
transform: 'translateY(-105%) translateX(-30%)'
}
})

Check warning on line 44 in src/components/Main/MainView/MessageElement/StampScaledElement.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageElement/StampScaledElement.vue#L35-L44

Added lines #L35 - L44 were not covered by tests
</script>

<style lang="scss" module>
.scaleReaction {
@include color-ui-tertiary;
@include background-primary;
display: flex;
border-radius: 4px;
max-width: 500px;
align-items: center;
contain: none;
flex-wrap: wrap;
border: solid 2px $theme-ui-tertiary-default;
position: absolute;
animation: transformAnimation 0.15s ease-in;
}

@keyframes transformAnimation {
from {
transform: translateY(-125%) translateX(-30%);
}
to {
transform: translateY(-105%) translateX(-30%);
}
}
.stamp {
margin: 0.2rem;
display: flex;
}

.detail {
color: var(--specific-count-text);
@include color-ui-primary;
flex: 1 1 0;
min-width: 0;
overflow: hidden;
overflow: clip;
margin: {
left: 6px;
right: 4px;
}
}
</style>
1 change: 1 addition & 0 deletions src/styles/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $z-index-message-loading: 2;

$z-index-message-element-tools: 3;
$z-index-message-element-tools-menu: 5;
$z-index-message-element-scaled-stamp: 7;

$z-index-main-view-wrapper: 10;
$z-index-sidebar-wrapper: 11;
Expand Down
Loading