Skip to content

Commit

Permalink
feat: 고정된 비디오에 대해 border가 아닌 pin 아이콘을 표시하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
simeunseo committed Dec 2, 2024
1 parent 045695b commit fbb89d1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
3 changes: 3 additions & 0 deletions apps/web/src/assets/icons/pin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 2 additions & 15 deletions apps/web/src/components/live/StreamView/List/SubVideoGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ import { useEffect, useRef, useState } from 'react';
import { StreamData } from '@/components/live/StreamView';
import VideoPlayer from '@/components/live/StreamView/List/VideoPlayer';

const highlightVariants = cva(`h-full w-full overflow-hidden rounded-lg border-2`, {
variants: {
pinned: {
true: 'border-primary',
false: 'border-transparent',
},
},
defaultVariants: {
pinned: false,
},
});

interface SubVideoGridProps {
videoStreamData: StreamData[];
pinnedVideoStreamData: StreamData | null;
Expand Down Expand Up @@ -55,9 +43,7 @@ function SubVideoGrid({
<div
key={`${streamData.socketId}${idx}`}
style={{ maxWidth: videoMaxWidth }}
className={highlightVariants({
pinned: pinnedVideoStreamData?.stream?.id === streamData.stream?.id,
})}
className="h-full w-full overflow-hidden rounded-lg"
onClick={() => streamData.stream && onVideoClick(streamData)}
>
<VideoPlayer
Expand All @@ -68,6 +54,7 @@ function SubVideoGrid({
isMicOn={streamData && getAudioMutedState(streamData)}
mediaType={streamData.consumer?.appData?.mediaTypes}
socketId={streamData.socketId}
isPinned={pinnedVideoStreamData?.stream?.id === streamData.stream?.id}
/>
</div>
))}
Expand Down
23 changes: 17 additions & 6 deletions apps/web/src/components/live/StreamView/List/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { memo, useEffect, useRef, useState } from 'react';

import MicOffIc from '@/assets/icons/mic-off.svg?react';
import MicOnIc from '@/assets/icons/mic-on.svg?react';
import PinIc from '@/assets/icons/pin.svg?react';
import Avatar from '@/components/common/Avatar';
import Badge from '@/components/common/Badge';
import Loading from '@/components/common/Loading';
Expand All @@ -20,7 +21,7 @@ const videoVariants = cva(
false: 'opacity-100',
},
isSpeaking: {
true: 'border-active border-4',
true: 'border-4 border-primary',
false: 'border-alt border-4',
},
},
Expand All @@ -39,6 +40,7 @@ export interface VideoPlayerProps {
mediaType?: string;
nickname: string;
socketId?: string;
isPinned?: boolean;
}

function VideoPlayer({
Expand All @@ -49,13 +51,14 @@ function VideoPlayer({
avatarSize = 'md',
nickname,
socketId,
isPinned = false,
}: VideoPlayerProps) {
const [isLoading, setIsLoading] = useState(true);
const videoRef = useRef<HTMLVideoElement>(null);

const { activeSocketId, createAudioLevel } = useAudioLevelDetector();
const isSpeaking = activeSocketId === socketId;
console.log(activeSocketId);

useEffect(() => {
if (!videoRef.current) return;

Expand All @@ -78,7 +81,7 @@ function VideoPlayer({
preload="metadata"
className={videoVariants({
loading: isLoading,
isSpeaking: isSpeaking,
isSpeaking,
})}
onLoadedData={onLoadedData}
>
Expand Down Expand Up @@ -112,9 +115,17 @@ function VideoPlayer({
{stream && (
<>
{mediaType === 'video' && (
<div className="absolute right-3 top-3 flex h-8 w-8 items-center justify-center rounded-full bg-altWeak p-1">
{isMicOn ? <MicOnIc className="text-white" /> : <MicOffIc className="fill-white" />}
</div>
<>
<div className="absolute right-3 top-3 flex h-8 w-8 items-center justify-center rounded-full bg-altWeak p-1">
{isMicOn ? <MicOnIc className="text-white" /> : <MicOffIc className="fill-white" />}
</div>

{isPinned && (
<div className="absolute left-3 top-3 flex h-8 w-8 items-center justify-center rounded-full bg-primary p-1">
<PinIc className="fill-white" />
</div>
)}
</>
)}
</>
)}
Expand Down
1 change: 0 additions & 1 deletion apps/web/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const tailwindConfig: Config = {
black: 'var(--black)',
alt: 'var(--grey-700)',
error: 'var(--red)',
active: 'var(--green)',
},
fill: {
primary: 'var(--purple-500)',
Expand Down

0 comments on commit fbb89d1

Please sign in to comment.