-
Notifications
You must be signed in to change notification settings - Fork 0
deploy: 3.2.0 배포 #300
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
deploy: 3.2.0 배포 #300
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9121585
design: 비디오디테일 페이지 전반적인ui 맞추기(#297)
wonellyho e9cae40
refactor: CommentList 활용해서 삭제모달 구현(#297)
wonellyho c8da10d
feat: 모바일레이아웃 적용(#297)
wonellyho 2065f6f
feat: 이모지미리보기_리액션버블 컴포넌트 추가(#297)
wonellyho df9f9d5
Merge pull request #298 from TTORANG/design/pd-vid-ui-297
wonellyho 59ed8a7
docs: 문서 업데이트 (#000)
AndyH0ng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| /** | ||
| * @file ReactionBubble.tsx | ||
| * @description 영상 재생바 위에 현재 구간 리액션을 요약하여 보여주는 버블 컴포넌트 | ||
| * | ||
| * - 현재 재생시간 ±windowMs 범위 내 리액션을 표시 | ||
| * - 상위 3개까지 노출, 4개 이상이면 상위 3개 + "..." 로 축약 | ||
| * - "..." 클릭 시 팝오버로 전체 5종 표시 | ||
| */ | ||
| import { useCallback, useEffect, useRef, useState } from 'react'; | ||
|
|
||
| import { REACTION_CONFIG, REACTION_TYPES } from '@/constants/reaction'; | ||
| import { useVideoReactionWindow } from '@/hooks/queries/useVideoReactionQueries'; | ||
| import type { ReactionType } from '@/types/script'; | ||
|
|
||
| interface ReactionBubbleProps { | ||
| videoId: string | undefined; | ||
| currentTimeMs: number; | ||
| windowMs?: number; | ||
| } | ||
|
|
||
| export default function ReactionBubble({ | ||
| videoId, | ||
| currentTimeMs, | ||
| windowMs = 5000, | ||
| }: ReactionBubbleProps) { | ||
| const [isPopoverOpen, setIsPopoverOpen] = useState(false); | ||
| const popoverRef = useRef<HTMLDivElement>(null); | ||
|
|
||
| // 500ms 단위로 쿼리 키를 스냅하여 과도한 리패치 방지 | ||
| const snappedMs = Math.round(currentTimeMs / 500) * 500; | ||
|
|
||
| const { data: reactions } = useVideoReactionWindow(videoId, snappedMs, windowMs); | ||
|
|
||
| useEffect(() => { | ||
| if (!isPopoverOpen) return; | ||
| const handleClick = (e: MouseEvent) => { | ||
| if (popoverRef.current && !popoverRef.current.contains(e.target as Node)) { | ||
| setIsPopoverOpen(false); | ||
| } | ||
| }; | ||
| document.addEventListener('mousedown', handleClick); | ||
| return () => document.removeEventListener('mousedown', handleClick); | ||
| }, [isPopoverOpen]); | ||
|
|
||
| const handleTogglePopover = useCallback(() => { | ||
| setIsPopoverOpen((prev) => !prev); | ||
| }, []); | ||
|
|
||
| // 리액션 데이터를 정규화 | ||
| const reactionMap = new Map<ReactionType, number>(); | ||
| if (reactions) { | ||
| for (const r of reactions) { | ||
| reactionMap.set(r.emojiType, (reactionMap.get(r.emojiType) ?? 0) + r.count); | ||
| } | ||
| } | ||
|
|
||
| // count > 0인 항목만 추출, count 내림차순 | ||
| const activeReactions = REACTION_TYPES.map((type) => ({ | ||
| type, | ||
| emoji: REACTION_CONFIG[type].emoji, | ||
| count: reactionMap.get(type) ?? 0, | ||
| })) | ||
| .filter((r) => r.count > 0) | ||
| .sort((a, b) => b.count - a.count); | ||
|
|
||
| if (activeReactions.length === 0) return null; | ||
|
|
||
| const displayItems = activeReactions.slice(0, 3); | ||
| const hasMore = activeReactions.length >= 4; | ||
|
|
||
| // 전체 5종 목록 (팝오버용) | ||
| const allReactions = REACTION_TYPES.map((type) => ({ | ||
| type, | ||
| emoji: REACTION_CONFIG[type].emoji, | ||
| label: REACTION_CONFIG[type].label, | ||
| count: reactionMap.get(type) ?? 0, | ||
| })); | ||
|
|
||
| return ( | ||
| <div ref={popoverRef} className="relative inline-flex"> | ||
| <button | ||
| type="button" | ||
| onClick={hasMore ? handleTogglePopover : undefined} | ||
| className="flex items-center gap-1 md:gap-2 rounded-full bg-black/70 px-2 py-1 md:px-3 md:py-1.5 text-white backdrop-blur-sm text-caption md:text-body-s" | ||
| > | ||
| {displayItems.map((item) => ( | ||
| <span key={item.type} className="inline-flex items-center gap-0.5 md:gap-1"> | ||
| <span className="text-xs md:text-sm">{item.emoji}</span> | ||
| <span>{item.count}</span> | ||
| </span> | ||
| ))} | ||
| {hasMore && <span className="text-gray-300">···</span>} | ||
| </button> | ||
|
|
||
| {isPopoverOpen && ( | ||
| <div className="absolute bottom-full left-0 mb-2 w-40 md:w-52 rounded-lg bg-black/85 p-2 md:p-3 text-white backdrop-blur-sm shadow-lg"> | ||
| <p className="mb-1.5 md:mb-2 text-caption-bold md:text-body-s-bold text-gray-300"> | ||
| 전체 이모지 반응 보기 | ||
| </p> | ||
| <div className="flex flex-col gap-1 md:gap-1.5"> | ||
| {allReactions.map((item) => ( | ||
| <div key={item.type} className="flex items-center justify-between"> | ||
| <span className="flex items-center gap-1 md:gap-1.5"> | ||
| <span className="text-xs md:text-sm">{item.emoji}</span> | ||
| <span className="text-caption md:text-body-s text-gray-300">{item.label}</span> | ||
| </span> | ||
| <span className="text-caption-bold md:text-body-s-bold">{item.count}</span> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
팝오버 외부 클릭을 감지하는
useEffect로직은 여러 컴포넌트에서 재사용될 가능성이 높습니다. 이 로직을useOnClickOutside와 같은 커스텀 훅으로 추출하면 컴포넌트의 코드가 더 간결해지고, 다른 곳에서도 쉽게 재사용할 수 있어 유지보수성이 향상됩니다. 예를 들어,useOnClickOutside(popoverRef, () => setIsPopoverOpen(false));와 같이 사용할 수 있습니다.