mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 06:54:28 +00:00
feat(video): resize transcripts and follow playback earlier
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
|
||||
interface ResizeHandleProps {
|
||||
interface ResizeHandleProps extends Omit<
|
||||
React.ComponentProps<'div'>,
|
||||
'children' | 'onMouseDown' | 'onResize'
|
||||
> {
|
||||
onResize: (delta: number) => void
|
||||
className?: string
|
||||
hitAreaClassName?: string
|
||||
}
|
||||
|
||||
export const ResizeHandle: React.FC<ResizeHandleProps> = ({
|
||||
onResize,
|
||||
|
||||
hitAreaClassName,
|
||||
className = '',
|
||||
...props
|
||||
}) => {
|
||||
const [isDragging, setIsDragging] = useState(false)
|
||||
const startXref = useRef(0)
|
||||
@@ -50,36 +55,39 @@ export const ResizeHandle: React.FC<ResizeHandleProps> = ({
|
||||
startXref.current = e.clientX
|
||||
}
|
||||
|
||||
// Common hit area that is always larger than the visible element for usability
|
||||
const HitArea = () => (
|
||||
<div className="absolute inset-y-0 -left-4 -right-4 z-20 cursor-col-resize touch-none" />
|
||||
)
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`group relative z-20 flex h-full w-[2px] cursor-col-resize items-center justify-center bg-border transition-all hover:bg-transparent ${className}`}
|
||||
{...props}
|
||||
data-slot="resize-handle"
|
||||
className={`group/resize relative z-20 flex h-full w-[2px] cursor-col-resize items-center justify-center bg-border transition-all hover:bg-transparent ${className}`}
|
||||
onMouseDown={handleMouseDown}
|
||||
>
|
||||
<HitArea />
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
'absolute inset-y-0 -left-4 -right-4 z-20 cursor-col-resize touch-none',
|
||||
hitAreaClassName,
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* The glowing vertical line */}
|
||||
<div
|
||||
className={`absolute inset-y-0 w-[2px] transition-all duration-300 ease-out
|
||||
className={`pointer-events-none absolute inset-y-0 w-[2px] transition-all duration-300 ease-out
|
||||
${
|
||||
isDragging
|
||||
? 'bg-blue-600 shadow-[0_0_15px_rgba(37,99,235,0.6)] opacity-100'
|
||||
: 'bg-blue-400 opacity-0 group-hover:opacity-100 group-hover:shadow-[0_0_8px_rgba(96,165,250,0.5)]'
|
||||
: 'bg-blue-400 opacity-0 group-hover/resize:opacity-100 group-hover/resize:shadow-[0_0_8px_rgba(96,165,250,0.5)]'
|
||||
}
|
||||
`}
|
||||
/>
|
||||
|
||||
{/* The central drag handle (Pill) */}
|
||||
<div
|
||||
className={`absolute top-1/2 left-1/2 h-10 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-blue-600 transition-all duration-300 ease-out
|
||||
className={`pointer-events-none absolute top-1/2 left-1/2 h-10 w-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-blue-600 transition-all duration-300 ease-out
|
||||
${
|
||||
isDragging
|
||||
? 'opacity-100 scale-100 shadow-[0_0_10px_rgba(37,99,235,0.5)]'
|
||||
: 'opacity-0 scale-75 group-hover:opacity-100 group-hover:scale-100'
|
||||
: 'opacity-0 scale-75 group-hover/resize:opacity-100 group-hover/resize:scale-100'
|
||||
}`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user