Skip to content

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

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

Merged
merged 31 commits into from
May 10, 2025
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
31 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
2b99e5e
Merge branch 'master' of github.com:traPtitech/traQ_S-UI into issue4299
UnABC May 7, 2025
cbc515e
UIの調整
UnABC May 7, 2025
995cfd7
ユーザアイコン表示の上限を100→30に変更等
UnABC May 9, 2025
6e8dce7
ユーザアイコン表示の上限を100→32に変更等
UnABC May 9, 2025
167ff71
isLongHoverd判定ロジック追加等
UnABC May 9, 2025
534fe15
Merge branch 'issue4299' of github.com:traPtitech/traQ_S-UI into issu…
UnABC May 9, 2025
672c119
UIの調整
UnABC May 9, 2025
8ec935b
間隔、サイズ等の調整
UnABC May 10, 2025
ae54378
UIの微調整
UnABC May 10, 2025
974d348
コードの整理
UnABC May 10, 2025
02c6f74
コードの微調整
UnABC May 10, 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
32 changes: 19 additions & 13 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"
@add-stamp="addStamp"
@remove-stamp="removeStamp"
/>
Expand Down Expand Up @@ -136,7 +137,7 @@ const { toggleStampPicker } = useStampPickerInvoker(
&[data-show-details] {
flex-direction: column;
}
contain: content;
contain: none;
}
.stamp {
margin: {
Expand Down
53 changes: 48 additions & 5 deletions src/components/Main/MainView/MessageElement/StampElement.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<template>
<div
:class="$style.body"
:title="tooltip"
:aria-label="tooltip"
:data-include-me="$boolAttr(includeMe)"
@click="onClick"
@mouseenter="onMouseEnter"
@mouseleave="onMouseLeave"
>
<transition name="stamp-pressed" mode="out-in">
<a-stamp
Expand All @@ -15,6 +17,11 @@
</transition>
<spin-number :value="stamp.sum" :class="$style.count" />
</div>
<stamp-scaled-element
:class="$style.scaleReaction"
:show="isHovered && isLongHovered && !isDetailShown && !isMobile"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:show="isHovered && isLongHovered && !isDetailShown && !isMobile"
:v-if="isHovered && isLongHovered && !isDetailShown && !isMobile"

ここ、stamp-scaled-elementの中でv-show使って制御してると思うんですけど、v-ifでコンポーネントごと表示させないほうが大量にスタンプが付いたときに軽くなると思います。
https://ja.vuejs.org/guide/essentials/conditional#v-if-vs-v-show

:stamp="stamp"
/>
</template>

<script lang="ts" setup>
Expand All @@ -23,17 +30,22 @@ 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'
import type { MessageStampById } from '/@/lib/messageStampList'
import StampScaledElement from './StampScaledElement.vue'
import useHover from '/@/composables/dom/useHover'

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

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

const { isMobile } = useResponsiveStore()
const { stampsMap } = useStampsStore()
const { usersMap } = useUsersStore()

Expand All @@ -43,10 +55,7 @@ const stampName = computed(

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

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

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

watch(isHovered, beginHover => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このあたりの処理、useHoverを使おうと使おうとしたのは自然な判断だと思います!
ただ、今回の場合、useHoverを使うとむしろ複雑になってしまっているところがあるので、@mouseenter、@Mouseleaveの関数をここに直接書いちゃってもいいと思います!
もしくは今後何かで使うかもしれないというのを考えてuseHoverの内部にisLongHoverdの判定ロジックを組み込むのもありだと思います!

if (beginHover) {
hoverTimeout.value = setTimeout(() => {
isLongHovered.value = true
}, 500)
} else {
if (hoverTimeout.value) {
clearTimeout(hoverTimeout.value)
hoverTimeout.value = null
}
isLongHovered.value = false
}
})
</script>

<style lang="scss" module>
Expand All @@ -103,6 +130,7 @@ watch(
user-select: none;
overflow: hidden;
contain: content;
position: relative;
}

.count {
Expand All @@ -118,4 +146,19 @@ watch(
right: 4px;
}
}

.scaleReaction {
@include background-tertiary;
display: flex;
height: 3.5rem;
align-items: flex-start;
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,78 @@
<template>
<div :class="$style.container">
<div>
{{ ':' + stampName + ': が ' }}
</div>
<div v-for="user in limitedUsers" :key="user.id" :class="$style.contents">
<stamp-detail-element-content
:user-id="user.id"
:count="user.count"
:class="$style.content"
/>
<span
v-if="
(!isLastUser(user) && !isSecondLastUser(user)) ||
isOverLimitSecondUser(user)
"
:class="$style.contents"
>
</span>
<span
v-if="isSecondLastUser(user) && !isOverLimitSecondUser(user)"
:class="$style.contents"
>と</span
>
<span v-if="isOverLimitUser(user)" :class="$style.contents"
>と他{{ props.stamp.users.length - 3 }}人</span
>
<span v-if="isLastUser(user)" :class="$style.contents">
にリアクションされました
</span>
</div>
</div>
</template>

<script lang="ts" setup>
import StampDetailElementContent from './StampDetailElementContent.vue'
import { computed } from 'vue'
import { useStampsStore } from '/@/store/entities/stamps'
import type { StampUser, MessageStampById } from '/@/lib/messageStampList'

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

const { stampsMap } = useStampsStore()

const limitedUsers = computed(() => props.stamp.users.slice(0, 3))

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

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

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

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

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

<style lang="scss" module>
.container {
display: flex;
flex-wrap: wrap;
}
.contents {
display: flex;
}
.content {
padding: 0 0.2rem;
}
</style>
58 changes: 58 additions & 0 deletions src/components/Main/MainView/MessageElement/StampScaledElement.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<template>
<div v-show="show" :class="$style.scaleReaction">
<transition name="scale-reaction">
<!-- sizeを46より大きくすると見切れる -->
<a-stamp
:key="stamp.id"
:stamp-id="stamp.id"
:size="46"
:class="$style.stamp"
without-title
/>
</transition>
<stamp-detail-element :class="$style.detail" :stamp="stamp" />
</div>
</template>

<script lang="ts" setup>
import AStamp from '/@/components/UI/AStamp.vue'
import type { MessageStampById } from '/@/lib/messageStampList'
import StampDetailElement from './StampScaledDetailElement.vue'

const props = defineProps<{
stamp: MessageStampById
show: boolean
}>()
</script>

<style lang="scss" module>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここ、grid の中の item で margin を入れてて margin が 2 つ分できてしまってるので、 flex box にして gap 指定する形で margin 重複を回避できるならしたいかも

.scaleReaction {
@include color-ui-tertiary;
@include background-primary;
display: flex;
border-radius: 4px;
contain: none;
flex-wrap: wrap;
border: solid 2px $theme-ui-tertiary-default;
}
.stamp {
margin: {
right: 0.2rem;
bottom: 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