mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 16:09:02 +00:00
Merge pull request #106 from shumaiOne/refactor/video-player-system-colors
refactor(webui): use system color design tokens in video player components
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import type { AttachmentInfo, CommentInfo } from '@shumai/dtos'
|
||||
import type { UserInfo } from '@shumai/dtos'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import {
|
||||
@@ -11,6 +9,7 @@ import {
|
||||
} from '@/ui/components/ui/dialog'
|
||||
import { Separator } from '@/ui/components/ui/separator'
|
||||
import { formatTimeAgo } from '@/ui/lib/time'
|
||||
import type { AttachmentInfo, CommentInfo, UserInfo } from '@shumai/dtos'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { Download, File, Terminal } from 'lucide-react'
|
||||
import React from 'react'
|
||||
@@ -191,11 +190,11 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
||||
<span className="text-xs text-muted-foreground animate-pulse">{loadingText}</span>
|
||||
</div>
|
||||
) : message.sessionId ? (
|
||||
<div className="text-sm leading-relaxed prose prose-sm dark:prose-invert max-w-none break-words">
|
||||
<div className="text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words">
|
||||
<Markdown>{preprocessMarkdown(message.message!)}</Markdown>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-sm leading-relaxed whitespace-pre-wrap break-words text-wrap break-all">
|
||||
<div className="text-sm leading-[1.8] whitespace-pre-wrap break-words text-wrap break-all">
|
||||
{renderFormattedMessage(message.message!)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -21,7 +21,6 @@ export function GuestIdentityPopup({
|
||||
onSuccess,
|
||||
children,
|
||||
}: GuestIdentityPopupProps) {
|
||||
console.log('[GuestIdentityPopup] isOpen:', isOpen)
|
||||
const [name, setName] = useState('')
|
||||
const [email, setEmail] = useState('')
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
@@ -124,7 +124,7 @@ const ProgressBar: React.FC<ProgressBarProps> = ({
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className="group relative h-1.5 w-full cursor-pointer touch-none rounded-full bg-gray-300 transition-colors duration-200 dark:bg-white/20"
|
||||
className="group relative h-1.5 w-full cursor-pointer touch-none rounded-full bg-muted transition-colors duration-200"
|
||||
onMouseMove={handleMouseMove}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
onClick={handleClick}
|
||||
@@ -145,7 +145,7 @@ const ProgressBar: React.FC<ProgressBarProps> = ({
|
||||
className="pointer-events-none absolute bottom-full z-50 mb-3 flex w-max flex-col"
|
||||
style={getTooltipStyle()}
|
||||
>
|
||||
<div className="relative overflow-hidden rounded-lg border-2 border-gray-300 bg-white shadow-2xl dark:border-white/50 dark:bg-black">
|
||||
<div className="relative overflow-hidden rounded-lg border-2 border-border bg-popover shadow-2xl">
|
||||
<video
|
||||
src={previewUrl}
|
||||
className="bg-black object-cover"
|
||||
@@ -157,7 +157,7 @@ const ProgressBar: React.FC<ProgressBarProps> = ({
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<div className="absolute bottom-0 w-full bg-white/80 py-0.5 text-center text-xs font-medium text-gray-900 dark:bg-black/60 dark:text-white">
|
||||
<div className="absolute bottom-0 w-full bg-popover/80 py-0.5 text-center text-xs font-medium text-popover-foreground">
|
||||
{formatTime(hoverPosition! * duration)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -166,25 +166,25 @@ const ProgressBar: React.FC<ProgressBarProps> = ({
|
||||
|
||||
{/* Buffered Bar */}
|
||||
<div
|
||||
className="absolute top-0 left-0 h-full rounded-full bg-gray-400 transition-all duration-200 dark:bg-white/30"
|
||||
className="absolute top-0 left-0 h-full rounded-full bg-muted-foreground/30 transition-all duration-200"
|
||||
style={{ width: `${buffered}%` }}
|
||||
/>
|
||||
|
||||
{/* Hover Highlight Bar */}
|
||||
{isHovering && (
|
||||
<div
|
||||
className="absolute top-0 left-0 h-full rounded-full bg-gray-500/40 dark:bg-white/40"
|
||||
className="absolute top-0 left-0 h-full rounded-full bg-foreground/10"
|
||||
style={{ width: `${hoverPercent}%` }}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Play Progress Bar */}
|
||||
<div
|
||||
className="relative absolute top-0 left-0 h-full rounded-full bg-blue-600 dark:bg-blue-500"
|
||||
className="relative absolute top-0 left-0 h-full rounded-full bg-primary"
|
||||
style={{ width: `${progressPercent}%` }}
|
||||
>
|
||||
{/* Thumb (Playhead) - visible on group hover or active */}
|
||||
<div className="absolute top-1/2 right-0 h-3.5 w-3.5 -translate-y-1/2 translate-x-1/2 scale-0 rounded-full border border-gray-200 bg-white shadow-md transition-transform duration-100 group-hover:scale-100 dark:border-none" />
|
||||
<div className="absolute top-1/2 right-0 h-3.5 w-3.5 -translate-y-1/2 translate-x-1/2 scale-0 rounded-full border border-border bg-background shadow-md transition-transform duration-100 group-hover:scale-100" />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -108,7 +108,7 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
||||
'transition-all duration-300 ease-in-out z-20',
|
||||
state.isFullScreen
|
||||
? 'absolute bottom-0 left-0 right-0 px-4 py-4 bg-black/60 backdrop-blur-md text-white'
|
||||
: 'relative w-full bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 px-4 py-3 z-10 transition-colors duration-200',
|
||||
: 'relative w-full bg-card border-t border-border px-4 py-3 z-10 transition-colors duration-200',
|
||||
isControlsVisible
|
||||
? 'opacity-100 translate-y-0'
|
||||
: 'opacity-0 translate-y-4 pointer-events-none',
|
||||
@@ -133,12 +133,12 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
||||
<div
|
||||
className={cn(
|
||||
'flex items-center justify-between',
|
||||
state.isFullScreen ? 'text-white/90' : 'text-gray-700 dark:text-white/90',
|
||||
state.isFullScreen ? 'text-white/90' : 'text-foreground',
|
||||
)}
|
||||
>
|
||||
{/* Left Side: Play, Vol, Time */}
|
||||
<div className="flex items-center gap-4">
|
||||
<button onClick={togglePlay} className="hover:text-blue-500 transition-colors">
|
||||
<button onClick={togglePlay} className="hover:text-primary transition-colors">
|
||||
{state.isPlaying ? (
|
||||
<Pause className="w-6 h-6 fill-current" />
|
||||
) : (
|
||||
@@ -148,14 +148,17 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
||||
|
||||
<button
|
||||
onClick={toggleLoop}
|
||||
className={cn('transition-colors', state.isLooping ? 'text-blue-500' : 'text-gray-400')}
|
||||
className={cn(
|
||||
'transition-colors',
|
||||
state.isLooping ? 'text-primary' : 'text-muted-foreground',
|
||||
)}
|
||||
title="Loop"
|
||||
>
|
||||
<Repeat className="w-5 h-5" />
|
||||
</button>
|
||||
|
||||
<div className="flex items-center gap-3 group/vol">
|
||||
<button onClick={toggleMute} className="hover:text-blue-500">
|
||||
<button onClick={toggleMute} className="hover:text-primary">
|
||||
{state.isMuted || state.volume === 0 ? (
|
||||
<VolumeX className="w-6 h-6" />
|
||||
) : (
|
||||
@@ -176,31 +179,33 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="min-w-[100px] cursor-pointer text-sm font-medium tabular-nums hover:text-blue-500"
|
||||
className="min-w-[100px] cursor-pointer text-sm font-medium tabular-nums hover:text-primary"
|
||||
onClick={() => setState((p) => ({ ...p, showFrames: !p.showFrames }))}
|
||||
title="Click to toggle Time/Frames"
|
||||
>
|
||||
{state.showFrames
|
||||
? `${formatFrame(state.currentTime, data.media.metadata.frameRate ?? 30)} / ${formatFrame(state.duration, data.media.metadata.frameRate ?? 30)}`
|
||||
: `${formatTime(state.currentTime)} / ${formatTime(state.duration)}`}
|
||||
<span className="ml-1 text-xs text-gray-400">{state.showFrames ? 'fr' : ''}</span>
|
||||
<span className="ml-1 text-xs text-muted-foreground">
|
||||
{state.showFrames ? 'fr' : ''}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right Side: Zoom, Speed, Res, Download, Fullscreen */}
|
||||
<div className="relative flex items-center gap-3">
|
||||
{/* Zoom Controls */}
|
||||
<div className="flex items-center gap-1 bg-gray-200/50 dark:bg-white/10 rounded-md p-0.5">
|
||||
<div className="flex items-center gap-1 bg-muted rounded-md p-0.5">
|
||||
<button
|
||||
onClick={() => onZoomChange(zoom * 0.8)}
|
||||
className="p-1 hover:text-blue-500 rounded"
|
||||
className="p-1 hover:text-primary rounded"
|
||||
>
|
||||
<Minus size={14} />
|
||||
</button>
|
||||
<span className="text-xs w-8 text-center tabular-nums">{Math.round(zoom * 100)}%</span>
|
||||
<button
|
||||
onClick={() => onZoomChange(zoom * 1.2)}
|
||||
className="p-1 hover:text-blue-500 rounded"
|
||||
className="p-1 hover:text-primary rounded"
|
||||
>
|
||||
<Plus size={14} />
|
||||
</button>
|
||||
@@ -209,7 +214,7 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
||||
{/* Playback Rate */}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="w-8 text-sm font-bold hover:text-blue-500">
|
||||
<button className="w-8 text-sm font-bold hover:text-primary">
|
||||
{state.playbackRate}x
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
@@ -221,8 +226,8 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
||||
className={cn(
|
||||
'rounded py-1 px-2 text-left text-xs',
|
||||
state.playbackRate === rate
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800',
|
||||
? 'bg-primary text-primary-foreground focus:bg-primary focus:text-primary-foreground'
|
||||
: 'text-foreground',
|
||||
)}
|
||||
>
|
||||
{rate}x
|
||||
@@ -234,7 +239,7 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
||||
{/* Resolution Selector */}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="flex items-center gap-1 rounded border border-gray-300 px-2 py-0.5 text-sm font-semibold hover:bg-gray-200 dark:border-white/20 dark:hover:bg-white/10">
|
||||
<button className="flex items-center gap-1 rounded border border-border px-2 py-0.5 text-sm font-semibold hover:bg-muted transition-colors">
|
||||
<Settings className="h-3.5 w-3.5" />
|
||||
<span>{state.currentResolution}</span>
|
||||
</button>
|
||||
@@ -249,12 +254,12 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
||||
className={cn(
|
||||
'flex w-full items-center justify-between',
|
||||
state.currentResolution === res.resolution
|
||||
? 'text-blue-500'
|
||||
: 'text-gray-700 dark:text-gray-300',
|
||||
? 'text-primary font-medium'
|
||||
: 'text-foreground',
|
||||
)}
|
||||
>
|
||||
<span>{res.resolution}</span>
|
||||
<span className="pl-5 text-xs text-gray-400 dark:text-gray-500">
|
||||
<span className="pl-5 text-xs text-muted-foreground">
|
||||
{res.width}x{res.height}
|
||||
</span>
|
||||
</DropdownMenuItem>
|
||||
@@ -265,7 +270,7 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
||||
{/* Download */}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="transition-colors hover:text-blue-500" title="Download">
|
||||
<button className="transition-colors hover:text-primary" title="Download">
|
||||
<Download className="h-5 w-5" />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
@@ -275,17 +280,17 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
||||
<DropdownMenuItem
|
||||
key={res.resolution}
|
||||
onClick={() => handleDownload(res.url ?? '', res.resolution)}
|
||||
className="flex w-full items-center justify-between px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"
|
||||
className="flex w-full items-center justify-between px-3 py-2 text-left text-sm text-foreground"
|
||||
>
|
||||
<span>{res.resolution}</span>
|
||||
<span className="text-xs text-gray-400 dark:text-gray-500">MP4</span>
|
||||
<span className="text-xs text-muted-foreground">MP4</span>
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
{/* Fullscreen */}
|
||||
<button onClick={toggleFullScreen} className="transition-colors hover:text-blue-500">
|
||||
<button onClick={toggleFullScreen} className="transition-colors hover:text-primary">
|
||||
{state.isFullScreen ? (
|
||||
<Minimize className="h-6 w-6" />
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user