import { useMemo } from 'react' import { X, Palette } from 'lucide-react' import type { SubtitleStyle } from '../../types/project-model' import { DEFAULT_SUBTITLE_STYLE } from '../../types/project-model' import { selectSubtitleTrackStyleIdx, selectTracks } from './editor-selectors' import { useEditorActions, useEditorStore } from './editor-store' export function SubtitleTrackStyleEditor() { const { clearSubtitleOverridesForTrack, setSubtitleTrackStyleEditorTrack, updateSubtitleTrackStyle, } = useEditorActions() const trackIndex = useEditorStore(selectSubtitleTrackStyleIdx) const tracks = useEditorStore(selectTracks) const editorModel = useMemo(() => { if (trackIndex === null) return null const track = tracks[trackIndex] if (!track || track.type !== 'subtitle') return null return { track, trackIndex, style: { ...DEFAULT_SUBTITLE_STYLE, ...(track.subtitleStyle || {}), }, } }, [trackIndex, tracks]) if (!editorModel) return null const { track, trackIndex: activeTrackIndex, style } = editorModel const closeEditor = () => { setSubtitleTrackStyleEditorTrack() } const updateTrackStyle = (patch: Partial) => { updateSubtitleTrackStyle(activeTrackIndex, patch) } return (
e.stopPropagation()}> {/* Header */}

Track Style

{track.name} - applies to all subtitles on this track

{/* Body */}
{/* Preview */}
Preview subtitle
{/* Font size */}
Font Size
updateTrackStyle({ fontSize: parseInt(e.target.value) })} className="w-24 accent-amber-500" /> {style.fontSize}px
{/* Font family */}
Font
{/* Bold / Italic */}
Style
{/* Text color */}
Text Color updateTrackStyle({ color: e.target.value })} className="w-7 h-6 rounded cursor-pointer border border-zinc-700" />
{/* Background toggle + color */}
Background
{style.backgroundColor !== 'transparent' && ( updateTrackStyle({ backgroundColor: e.target.value + 'CC' })} className="w-7 h-6 rounded cursor-pointer border border-zinc-700" /> )}
{/* Position */}
Position
) }