import React, { useCallback } from 'react'; import { X, Stamp, Image as ImageIcon, Type, AtSign, Globe, Instagram } from 'lucide-react'; import { useEditor } from '../../context/EditorContext'; import { FileDropZone } from '../ui/FileDropZone'; import { TimelineElement } from '../../types'; interface StickersPanelProps { onClose: () => void; } /** * Panel for brand assets: branded text presets, social handles, stickers. * Text presets use the brand font, color, and name from designMD. */ export const StickersPanel: React.FC = ({ onClose }) => { const { designMD, brandContent, layers, setLayers, activeLayerId, setActiveLayerId, setTimelineElements, setSelectedElementId, playerRef, durationInFrames, } = useEditor(); const brandName = designMD.brandName || 'Mi Marca'; const font = designMD.baseFont || 'system-ui'; const color = designMD.textColor || '#ffffff'; const social = designMD.socialHandles || {}; const brandContentThumbnails = (brandContent || []) .filter(p => p.thumbnail) .map(p => ({ src: p.thumbnail!, name: p.name, id: p.id })); const legacyStickers = designMD.brandStickers || []; // Add branded text element to a visual layer const addBrandText = useCallback((content: string, fontSize?: number, y?: number) => { const currentFrame = playerRef.current?.getCurrentFrame() || 0; const newId = 'el-' + Date.now(); let targetLayerId = activeLayerId; const activeLayer = layers.find(l => l.id === activeLayerId); if (!activeLayer || activeLayer.type === 'brand' || activeLayer.type === 'video' || activeLayer.type === 'audio') { let visualLayer = layers.find(l => l.type === 'visual' || l.type == null); if (!visualLayer) { visualLayer = { id: 'layer-' + Date.now(), name: 'Capa Gráfica 1', type: 'visual' }; setLayers(prev => [...prev, visualLayer!]); } targetLayerId = visualLayer.id; setActiveLayerId(targetLayerId); } const newElement: TimelineElement = { id: newId, layerId: targetLayerId, type: 'text', content, startFrame: currentFrame, endFrame: Math.min(durationInFrames, currentFrame + 100), x: 50, y: y ?? 50, fontSize, fontFamily: font, color: color, useBranding: true, }; setTimelineElements(prev => [...prev, newElement]); setSelectedElementId(newId); }, [layers, activeLayerId, playerRef, durationInFrames, setTimelineElements, setSelectedElementId, setLayers, setActiveLayerId, font, color]); // Build social text presets const socialPresets: { label: string; content: string; icon: React.ReactNode }[] = []; if (social.instagram) socialPresets.push({ label: 'Instagram', content: social.instagram, icon: }); if (social.tiktok) socialPresets.push({ label: 'TikTok', content: social.tiktok, icon: }); if (social.twitter) socialPresets.push({ label: 'Twitter/X', content: social.twitter, icon: }); if (social.youtube) socialPresets.push({ label: 'YouTube', content: social.youtube, icon: }); if (social.website) socialPresets.push({ label: 'Web', content: social.website, icon: }); return (

Marca

{/* ═══ Textos de Marca ═══ */}
Textos de Marca
{/* Brand name — large */} {/* Brand name — subtitle */} {/* Brand name — small watermark */}
{/* ═══ Redes Sociales ═══ */} {socialPresets.length > 0 && (
Redes Sociales
{socialPresets.map((sp) => ( ))}
)} {/* ═══ Contenido Visual de Marca ═══ */} {brandContentThumbnails.length > 0 && (
Contenido Visual
{brandContentThumbnails.map(item => (
{ e.dataTransfer.setData('text/plain', item.src); e.dataTransfer.setData('application/json', JSON.stringify({ type: 'sticker', src: item.src, brandContentId: item.id })); e.dataTransfer.effectAllowed = 'copy'; }} > {item.name}
Arrastrar {item.name}
))}
)} {/* Legacy Stickers */} {legacyStickers.length > 0 && (
Stickers
{legacyStickers.map((src, i) => (
{ e.dataTransfer.setData('text/plain', src); e.dataTransfer.setData('application/json', JSON.stringify({ type: 'sticker', src })); e.dataTransfer.effectAllowed = 'copy'; }} > Sticker
Arrastrar
))}
)} {/* Upload */} {}} label="Subir assets de marca" sublabel="PNG con transparencia" />
); };