codebydante / components /StyleSettingsPanel.tsx
codebybrody's picture
Upload 61 files
03aff49 verified
Raw History Blame Contribute Delete
54.5 kB
import React from 'react';
import { Settings, X, Check, Save } from 'lucide-react';
import { StyleConfig } from '../services/codeStyleService';
import { CustomBlockquote } from './CustomBlockquote';
interface StyleSettingsPanelProps {
styleConfig: StyleConfig;
onUpdateConfig: (newConfig: StyleConfig) => void;
activeTab: 'code' | 'quote' | 'link' | 'general' | 'button' | 'codeblock';
onTabChange: (tab: 'code' | 'quote' | 'link' | 'general' | 'button' | 'codeblock') => void;
onClose: () => void;
onConfirm?: (config: StyleConfig) => void;
previewContent?: string;
hideTabs?: boolean;
cardStyle?: 'bordered' | 'transparent' | 'filled';
onCardStyleChange?: (style: 'bordered' | 'transparent' | 'filled') => void;
}
export const StyleSettingsPanel: React.FC<StyleSettingsPanelProps> = ({
styleConfig,
onUpdateConfig,
activeTab,
onTabChange,
onClose,
onConfirm,
previewContent,
hideTabs = false,
cardStyle,
onCardStyleChange
}) => {
console.log('[StyleSettingsPanel] Render. onCardStyleChange present?', !!onCardStyleChange, 'activeTab:', activeTab, 'cardStyle:', cardStyle);
const [localConfig, setLocalConfig] = React.useState<StyleConfig>(styleConfig);
// Update local config when prop changes, but only if not dirty?
// Actually, usually we want to reset if the prop changes from outside.
React.useEffect(() => {
setLocalConfig(styleConfig);
}, [styleConfig]);
if (!localConfig || !localConfig.general || !localConfig.quote || !localConfig.code || !localConfig.button) {
return null;
}
const rgbToHex = (rgba: string): string => {
const match = rgba.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
if (!match) return '#555555';
const r = parseInt(match[1]);
const g = parseInt(match[2]);
const b = parseInt(match[3]);
return '#' + [r, g, b].map(x => {
const hex = x.toString(16);
return hex.length === 1 ? '0' + hex : hex;
}).join('');
};
const handleQuoteBgColorChange = (color: string) => {
// Extract current opacity from current bg color
const currentBg = localConfig.quote.bgColor;
let opacity = 1;
const rgbaMatch = currentBg.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
if (rgbaMatch && rgbaMatch[4]) {
opacity = parseFloat(rgbaMatch[4]);
}
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(color);
if (result) {
const r = parseInt(result[1], 16);
const g = parseInt(result[2], 16);
const b = parseInt(result[3], 16);
const newBgColor = `rgba(${r}, ${g}, ${b}, ${opacity})`;
setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, bgColor: newBgColor }
});
}
};
const handleQuoteOpacityChange = (opacity: number) => {
const currentBg = localConfig.quote.bgColor;
const rgbaMatch = currentBg.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
let r = 0, g = 0, b = 0;
if (rgbaMatch) {
r = parseInt(rgbaMatch[1]);
g = parseInt(rgbaMatch[2]);
b = parseInt(rgbaMatch[3]);
} else {
// Fallback if it was hex or something else, though we try to keep it rgba
// Try to parse hex if needed, or default to gray
r = 85; g = 85; b = 85;
}
const newBgColor = `rgba(${r}, ${g}, ${b}, ${opacity})`;
setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, bgColor: newBgColor }
});
};
const getQuoteOpacity = (): number => {
const match = localConfig.quote.bgColor.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
if (match && match[4]) {
return parseFloat(match[4]);
}
return 1;
};
return (
<div className="flex flex-col h-full overflow-hidden">
<div className="p-4 border-b border-white/5 bg-white/5 flex items-center justify-between">
<h3 className="text-white font-bold flex items-center gap-2 text-sm">
<Settings size={16} className="text-primary" />
Configuraci贸n de Estilos
</h3>
<button
type="button"
onClick={onClose}
className="text-gray-500 hover:text-white transition-colors"
>
<X size={16} />
</button>
</div>
{!hideTabs && (
<div className="flex border-b border-white/5 overflow-x-auto custom-scrollbar">
<button
onClick={() => onTabChange('general')}
className={`flex-1 px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap ${activeTab === 'general'
? 'bg-primary/10 text-primary border-b-2 border-primary'
: 'text-gray-400 hover:text-white hover:bg-white/5'
}`}
>
General
</button>
<button
onClick={() => onTabChange('code')}
className={`flex-1 px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap ${activeTab === 'code'
? 'bg-primary/10 text-primary border-b-2 border-primary'
: 'text-gray-400 hover:text-white hover:bg-white/5'
}`}
>
C贸digo
</button>
<button
onClick={() => onTabChange('codeblock')}
className={`flex-1 px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap ${activeTab === 'codeblock'
? 'bg-primary/10 text-primary border-b-2 border-primary'
: 'text-gray-400 hover:text-white hover:bg-white/5'
}`}
>
Bloque de C贸digo
</button>
<button
onClick={() => onTabChange('quote')}
className={`flex-1 px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap ${activeTab === 'quote'
? 'bg-primary/10 text-primary border-b-2 border-primary'
: 'text-gray-400 hover:text-white hover:bg-white/5'
}`}
>
Citas
</button>
<button
onClick={() => onTabChange('link')}
className={`flex-1 px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap ${activeTab === 'link'
? 'bg-primary/10 text-primary border-b-2 border-primary'
: 'text-gray-400 hover:text-white hover:bg-white/5'
}`}
>
Enlaces
</button>
<button
onClick={() => onTabChange('button')}
className={`flex-1 px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap ${activeTab === 'button'
? 'bg-primary/10 text-primary border-b-2 border-primary'
: 'text-gray-400 hover:text-white hover:bg-white/5'
}`}
>
Botones
</button>
</div>
)}
<div className="overflow-y-auto flex-1 p-5 space-y-5 custom-scrollbar pb-10">
{activeTab === 'general' && (
<div className="space-y-6">
{/* Typography Control */}
<div className="bg-white/5 rounded-lg p-4 border border-white/5 space-y-4">
<h4 className="text-sm font-medium text-white mb-2">Tipograf铆a de Tarjeta</h4>
<div className="space-y-4">
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Tama帽o T铆tulo</label>
<span className="text-xs text-primary font-mono">{localConfig.general.cardTitleSize}</span>
</div>
<input
type="range"
min="10"
max="32"
step="1"
value={parseInt(localConfig.general.cardTitleSize) || 16}
onChange={(e) => {
setLocalConfig({
...localConfig,
general: { ...localConfig.general, cardTitleSize: `${e.target.value}px` }
});
}}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Tama帽o Texto</label>
<span className="text-xs text-primary font-mono">{localConfig.general.cardFontSize}</span>
</div>
<input
type="range"
min="8"
max="24"
step="1"
value={parseInt(localConfig.general.cardFontSize) || 12}
onChange={(e) => {
setLocalConfig({
...localConfig,
general: { ...localConfig.general, cardFontSize: `${e.target.value}px` }
});
}}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
</div>
</div>
{/* Card Style Config */}
<div className="bg-white/5 rounded-lg p-4 border border-white/5">
<h4 className="text-sm font-medium text-white mb-2">Estilo de Tarjeta</h4>
<p className="text-xs text-gray-400 mb-4">
Personaliza la apariencia de esta tarjeta.
</p>
{!onCardStyleChange && (
<div className="mb-3 p-2 bg-yellow-500/10 border border-yellow-500/20 rounded text-xs text-yellow-500">
Esta opci贸n no est谩 disponible en este contexto.
</div>
)}
<div className="grid grid-cols-1 gap-3">
<label className={`flex items-center justify-between p-3 rounded-lg border transition-all ${!onCardStyleChange ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'} ${cardStyle === 'bordered'
? 'bg-primary/10 border-primary'
: 'bg-black/20 border-white/5 hover:bg-white/5'
}`}>
<div className="flex flex-col">
<span className={`text-sm font-medium ${cardStyle === 'bordered' ? 'text-white' : 'text-gray-300'}`}>Borde y Sin Fondo</span>
<span className="text-[10px] text-gray-500">Solo borde visible, fondo transparente.</span>
</div>
<input
type="radio"
name="cardStyle"
value="bordered"
checked={cardStyle === 'bordered'}
onChange={() => onCardStyleChange && onCardStyleChange('bordered')}
disabled={!onCardStyleChange}
className="w-4 h-4 accent-primary"
/>
</label>
<label className={`flex items-center justify-between p-3 rounded-lg border transition-all ${!onCardStyleChange ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'} ${cardStyle === 'transparent'
? 'bg-primary/10 border-primary'
: 'bg-black/20 border-white/5 hover:bg-white/5'
}`}>
<div className="flex flex-col">
<span className={`text-sm font-medium ${cardStyle === 'transparent' ? 'text-white' : 'text-gray-300'}`}>Sin Fondo</span>
<span className="text-[10px] text-gray-500">Completamente transparente, sin borde.</span>
</div>
<input
type="radio"
name="cardStyle"
value="transparent"
checked={cardStyle === 'transparent'}
onChange={() => onCardStyleChange && onCardStyleChange('transparent')}
disabled={!onCardStyleChange}
className="w-4 h-4 accent-primary"
/>
</label>
<label className={`flex items-center justify-between p-3 rounded-lg border transition-all ${!onCardStyleChange ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'} ${cardStyle === 'filled'
? 'bg-primary/10 border-primary'
: 'bg-black/20 border-white/5 hover:bg-white/5'
}`}>
<div className="flex flex-col">
<span className={`text-sm font-medium ${cardStyle === 'filled' ? 'text-white' : 'text-gray-300'}`}>Con Fondo</span>
<span className="text-[10px] text-gray-500">Fondo s贸lido visible.</span>
</div>
<input
type="radio"
name="cardStyle"
value="filled"
checked={cardStyle === 'filled'}
onChange={() => onCardStyleChange && onCardStyleChange('filled')}
disabled={!onCardStyleChange}
className="w-4 h-4 accent-primary"
/>
</label>
</div>
</div>
</div>
)}
{activeTab === 'code' && (
<>
{/* Code tab content omitted for brevity as we are focusing on Quote tab improvements requested by user.
In a real scenario we would keep it or refactor.
For this task, I will assume we keep the existing code tab logic but using localConfig.
However, since I'm replacing the whole component body, I need to be careful.
The user asked to update the component. I should probably keep the code tab functional.
*/}
<div className="space-y-2">
<label className="block text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Vista Previa</label>
<div className="bg-[#121212] rounded-lg p-4 border border-white/5 text-sm text-gray-300 leading-relaxed">
{previewContent ? (
<code style={{
backgroundColor: localConfig.code.bgColor,
color: localConfig.code.textColor,
fontSize: localConfig.code.fontSize,
borderRadius: localConfig.code.borderRadius,
padding: '0px 2px',
minWidth: localConfig.code.width !== 'auto' ? localConfig.code.width : undefined,
maxWidth: '100%',
minHeight: localConfig.code.height !== 'auto' ? localConfig.code.height : undefined,
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
border: '1px solid rgba(255,255,255,0.05)',
fontFamily: localConfig.code.fontFamily || "'Consolas', 'Monaco', monospace",
lineHeight: 1,
margin: '0 1px'
}}>{previewContent}</code>
) : (
<span>Vista previa de c贸digo...</span>
)}
</div>
</div>
<div className="space-y-4 mt-4">
<div className="flex items-center justify-between p-3 bg-white/5 rounded-lg border border-white/5">
<div className="flex flex-col">
<span className="text-sm text-gray-300 font-medium">Mostrar fondo</span>
<span className="text-[10px] text-gray-500">Aplica solo a nuevos bloques de c贸digo</span>
</div>
<button
onClick={() => setLocalConfig({
...localConfig,
code: { ...localConfig.code, showBackground: !localConfig.code.showBackground }
})}
className={`w-12 h-6 rounded-full transition-colors relative ${localConfig.code.showBackground ? 'bg-primary' : 'bg-white/10'}`}
>
<span className={`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${localConfig.code.showBackground ? 'translate-x-6' : 'translate-x-0'}`} />
</button>
</div>
</div>
<div className="text-gray-500 text-xs italic mt-4">Configuraci贸n para c贸digo inline.</div>
</>
)}
{activeTab === 'codeblock' && (
<>
{console.log('StyleSettingsPanel Render. onCardStyleChange:', !!onCardStyleChange, onCardStyleChange)}
<div className="space-y-4 mt-4">
<h4 className="text-sm font-medium text-white mb-2">Comportamiento de Bloques de C贸digo</h4>
<div className="flex items-center justify-between p-3 bg-white/5 rounded-lg border border-white/5">
<div className="flex flex-col">
<span className="text-sm text-gray-300 font-medium">Colapsar texto largo</span>
<span className="text-[10px] text-gray-500">Aplica solo a nuevos bloques de c贸digo</span>
</div>
<button
onClick={() => setLocalConfig({
...localConfig,
code: { ...localConfig.code, collapsible: !localConfig.code.collapsible }
})}
className={`w-12 h-6 rounded-full transition-colors relative ${localConfig.code.collapsible ? 'bg-primary' : 'bg-white/10'}`}
>
<span className={`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${localConfig.code.collapsible ? 'translate-x-6' : 'translate-x-0'}`} />
</button>
</div>
<div className="flex items-center justify-between p-3 bg-white/5 rounded-lg border border-white/5">
<div className="flex flex-col">
<span className="text-sm text-gray-300 font-medium">N煤meros de l铆nea</span>
<span className="text-[10px] text-gray-500">Mostrar n煤meros de l铆nea en el margen izquierdo</span>
</div>
<button
onClick={() => setLocalConfig({
...localConfig,
code: { ...localConfig.code, showLineNumbers: !localConfig.code.showLineNumbers }
})}
className={`w-12 h-6 rounded-full transition-colors relative ${localConfig.code.showLineNumbers ? 'bg-primary' : 'bg-white/10'}`}
>
<span className={`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${localConfig.code.showLineNumbers ? 'translate-x-6' : 'translate-x-0'}`} />
</button>
</div>
<div className="flex items-center justify-between p-3 bg-white/5 rounded-lg border border-white/5">
<div className="flex flex-col">
<span className="text-sm text-gray-300 font-medium">Ajuste de l铆nea</span>
<span className="text-[10px] text-gray-500">Ver todo el c贸digo sin scroll horizontal</span>
</div>
<button
onClick={() => setLocalConfig({
...localConfig,
code: { ...localConfig.code, wrapText: !localConfig.code.wrapText }
})}
className={`w-12 h-6 rounded-full transition-colors relative ${localConfig.code.wrapText ? 'bg-primary' : 'bg-white/10'}`}
>
<span className={`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${localConfig.code.wrapText ? 'translate-x-6' : 'translate-x-0'}`} />
</button>
</div>
</div>
<div className="text-gray-500 text-xs italic mt-4">Configuraci贸n para bloques de c贸digo largos.</div>
</>
)}
{activeTab === 'quote' && (
<>
<div className="space-y-2">
<label className="block text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Vista Previa</label>
<div className="bg-[#121212] rounded-lg p-4 border border-white/5 text-sm text-gray-300 leading-relaxed">
<CustomBlockquote
key={JSON.stringify(localConfig.quote)}
style={{
backgroundColor: localConfig.quote.bgColor,
color: localConfig.quote.textColor,
borderLeftWidth: localConfig.quote.borderWidth,
borderLeftStyle: 'solid',
borderLeftColor: localConfig.quote.borderColor,
padding: localConfig.quote.padding,
fontSize: localConfig.quote.fontSize,
borderRadius: localConfig.quote.borderRadius,
fontFamily: localConfig.quote.isCodeFont ? 'monospace' : (localConfig.quote.fontFamily || 'inherit'),
fontStyle: localConfig.quote.italic ? 'italic' : 'normal',
width: localConfig.quote.width !== 'auto' ? localConfig.quote.width : '100%',
maxWidth: '100%',
minHeight: localConfig.quote.height !== 'auto' ? localConfig.quote.height : undefined,
overflow: 'visible',
position: 'relative',
marginBottom: '1rem',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
wordBreak: 'break-word'
}}
data-show-copy={localConfig.quote.showCopyButton}
data-show-download={localConfig.quote.showDownloadButton}
>
{previewContent || 'Esta es una cita de ejemplo que muestra el estilo configurado.'}
</CustomBlockquote>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<label className="block text-[10px] text-gray-500 uppercase tracking-widest font-semibold mb-2">Color Texto</label>
<div className="flex items-center gap-2 bg-white/5 p-1 rounded-lg border border-white/5">
<input
type="color"
value={localConfig.quote.textColor}
onChange={(e) => setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, textColor: e.target.value }
})}
className="w-8 h-8 rounded cursor-pointer bg-transparent border-none p-0"
/>
<span className="text-xs text-gray-400 font-mono">{localConfig.quote.textColor}</span>
</div>
</div>
<div>
<label className="block text-[10px] text-gray-500 uppercase tracking-widest font-semibold mb-2">Color Fondo</label>
<div className="flex items-center gap-2 bg-white/5 p-1 rounded-lg border border-white/5">
<input
type="color"
value={rgbToHex(localConfig.quote.bgColor)}
onChange={(e) => handleQuoteBgColorChange(e.target.value)}
className="w-8 h-8 rounded cursor-pointer bg-transparent border-none p-0"
/>
<span className="text-xs text-gray-400 font-mono">{rgbToHex(localConfig.quote.bgColor)}</span>
</div>
</div>
</div>
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Opacidad Fondo</label>
<span className="text-xs text-primary font-mono">{Math.round(getQuoteOpacity() * 100)}%</span>
</div>
<input
type="range"
min="0"
max="1"
step="0.01"
value={getQuoteOpacity()}
onChange={(e) => handleQuoteOpacityChange(parseFloat(e.target.value))}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<label className="block text-[10px] text-gray-500 uppercase tracking-widest font-semibold mb-2">Color Borde</label>
<div className="flex items-center gap-2 bg-white/5 p-1 rounded-lg border border-white/5">
<input
type="color"
value={localConfig.quote.borderColor}
onChange={(e) => setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, borderColor: e.target.value }
})}
className="w-8 h-8 rounded cursor-pointer bg-transparent border-none p-0"
/>
<span className="text-xs text-gray-400 font-mono">{localConfig.quote.borderColor}</span>
</div>
</div>
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Grosor Borde</label>
<span className="text-xs text-primary font-mono">{localConfig.quote.borderWidth}</span>
</div>
<input
type="range"
min="0"
max="20"
value={parseInt(localConfig.quote.borderWidth) || 0}
onChange={(e) => {
const val = parseInt(e.target.value);
setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, borderWidth: `${val}px` }
});
}}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
</div>
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Padding</label>
<span className="text-xs text-primary font-mono">{localConfig.quote.padding}</span>
</div>
<input
type="range"
min="0"
max="50"
value={parseInt(localConfig.quote.padding) || 0}
onChange={(e) => {
const val = parseInt(e.target.value);
setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, padding: `${val}px` }
});
}}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Borde Redondeado</label>
<span className="text-xs text-primary font-mono">{localConfig.quote.borderRadius}</span>
</div>
<input
type="range"
min="0"
max="20"
value={parseInt(localConfig.quote.borderRadius) || 0}
onChange={(e) => {
const val = parseInt(e.target.value);
setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, borderRadius: `${val}px` }
});
}}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Tama帽o Fuente</label>
<span className="text-xs text-primary font-mono">{localConfig.quote.fontSize}</span>
</div>
<input
type="range"
min="0.5"
max="2"
step="0.05"
value={parseFloat(localConfig.quote.fontSize) || 1}
onChange={(e) => {
const val = parseFloat(e.target.value);
setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, fontSize: `${val}em` }
});
}}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Ancho</label>
<span className="text-xs text-primary font-mono">{localConfig.quote.width || '100%'}</span>
</div>
<input
type="range"
min="20"
max="100"
step="5"
value={parseInt(localConfig.quote.width) || 100}
onChange={(e) => setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, width: `${e.target.value}%` }
})}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Alto</label>
<span className="text-xs text-primary font-mono">{localConfig.quote.height === 'auto' ? 'Auto' : localConfig.quote.height}</span>
</div>
<input
type="range"
min="0"
max="500"
step="1"
value={localConfig.quote.height === 'auto' ? 0 : parseInt(localConfig.quote.height) || 0}
onChange={(e) => {
const val = parseInt(e.target.value);
setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, height: val === 0 ? 'auto' : `${val}px` }
});
}}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div className="flex items-center justify-between p-3 bg-white/5 rounded-lg border border-white/5">
<label className="text-sm text-gray-300 font-medium">Tipograf铆a C贸digo</label>
<button
onClick={() => setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, isCodeFont: !localConfig.quote.isCodeFont }
})}
className={`w-12 h-6 rounded-full transition-colors relative ${localConfig.quote.isCodeFont ? 'bg-primary' : 'bg-white/10'}`}
>
<span className={`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${localConfig.quote.isCodeFont ? 'translate-x-6' : 'translate-x-0'}`} />
</button>
</div>
<div className="flex items-center justify-between p-3 bg-white/5 rounded-lg border border-white/5">
<label className="text-sm text-gray-300 font-medium">Bot贸n Copiar</label>
<button
onClick={() => setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, showCopyButton: !localConfig.quote.showCopyButton }
})}
className={`w-12 h-6 rounded-full transition-colors relative ${localConfig.quote.showCopyButton ? 'bg-primary' : 'bg-white/10'}`}
>
<span className={`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${localConfig.quote.showCopyButton ? 'translate-x-6' : 'translate-x-0'}`} />
</button>
</div>
<div className="flex items-center justify-between p-3 bg-white/5 rounded-lg border border-white/5">
<label className="text-sm text-gray-300 font-medium">Bot贸n Descargar</label>
<button
onClick={() => setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, showDownloadButton: !localConfig.quote.showDownloadButton }
})}
className={`w-12 h-6 rounded-full transition-colors relative ${localConfig.quote.showDownloadButton ? 'bg-primary' : 'bg-white/10'}`}
>
<span className={`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${localConfig.quote.showDownloadButton ? 'translate-x-6' : 'translate-x-0'}`} />
</button>
</div>
<div className="flex items-center justify-between p-3 bg-white/5 rounded-lg border border-white/5">
<label className="text-sm text-gray-300 font-medium">Colapsar texto largo</label>
<button
onClick={() => setLocalConfig({
...localConfig,
quote: { ...localConfig.quote, collapsible: !localConfig.quote.collapsible }
})}
className={`w-12 h-6 rounded-full transition-colors relative ${localConfig.quote.collapsible ? 'bg-primary' : 'bg-white/10'}`}
>
<span className={`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${localConfig.quote.collapsible ? 'translate-x-6' : 'translate-x-0'}`} />
</button>
</div>
</div>
</>
)}
{activeTab === 'link' && (
<div className="space-y-6">
<div className="bg-white/5 rounded-lg p-4 border border-white/5">
<h4 className="text-sm font-medium text-white mb-2">Comportamiento de Enlaces</h4>
<p className="text-xs text-gray-400 mb-4">
Configura c贸mo se comportan los enlaces al crearlos.
</p>
<div className="flex items-center justify-between p-3 bg-black/20 rounded-lg border border-white/5">
<div className="flex flex-col">
<span className="text-sm text-gray-200 font-medium">Subrayar enlaces por defecto</span>
<span className="text-[10px] text-gray-500">Si est谩 desactivado, los nuevos enlaces no tendr谩n subrayado.</span>
</div>
<button
onClick={() => setLocalConfig({
...localConfig,
link: { ...localConfig.link, underlineEnabled: !localConfig.link?.underlineEnabled }
})}
className={`w-12 h-6 rounded-full transition-colors relative ${localConfig.link?.underlineEnabled ? 'bg-primary' : 'bg-white/10'}`}
>
<span className={`absolute top-1 left-1 w-4 h-4 rounded-full bg-white transition-transform ${localConfig.link?.underlineEnabled ? 'translate-x-6' : 'translate-x-0'}`} />
</button>
</div>
</div>
</div>
)}
{activeTab === 'button' && (
<div className="space-y-6">
<div className="space-y-2">
<label className="block text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Vista Previa</label>
<div className="bg-[#121212] rounded-lg p-8 border border-white/5 flex justify-center items-center">
<button
style={{
width: localConfig.button?.width === 'auto' ? 'auto' : localConfig.button?.width,
maxWidth: '100%', // Prevent overflow
height: localConfig.button?.height === 'auto' ? 'auto' : localConfig.button?.height,
backgroundColor: 'transparent',
color: localConfig.button?.backgroundColor,
borderRadius: localConfig.button?.borderRadius,
border: `1px solid ${localConfig.button?.backgroundColor}`,
boxShadow: `0 0 10px ${localConfig.button?.backgroundColor}40`,
padding: '8px 16px',
cursor: 'default'
}}
className="font-medium text-sm transition-all duration-200"
>
Bot贸n de Ejemplo
</button>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Ancho</label>
<span className="text-xs text-primary font-mono">{localConfig.button?.width || 'Auto'}</span>
</div>
<input
type="range"
min="0"
max="1000"
step="10"
value={localConfig.button?.width === 'auto' ? 0 : parseInt(localConfig.button?.width) || 0}
onChange={(e) => {
const val = parseInt(e.target.value);
setLocalConfig({
...localConfig,
button: { ...localConfig.button, width: val === 0 ? 'auto' : `${val}px` }
});
}}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
<div>
<div className="flex justify-between mb-2">
<label className="text-[10px] text-gray-500 uppercase tracking-widest font-semibold">Alto</label>
<span className="text-xs text-primary font-mono">{localConfig.button?.height || 'Auto'}</span>
</div>
<input
type="range"
min="0"
max="100"
step="2"
value={localConfig.button?.height === 'auto' ? 0 : parseInt(localConfig.button?.height) || 0}
onChange={(e) => {
const val = parseInt(e.target.value);
setLocalConfig({
...localConfig,
button: { ...localConfig.button, height: val === 0 ? 'auto' : `${val}px` }
});
}}
className="w-full h-1 bg-white/10 rounded-lg appearance-none cursor-pointer accent-primary"
/>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<label className="block text-[10px] text-gray-500 uppercase tracking-widest font-semibold mb-2">Color Borde</label>
<div className="flex items-center gap-2 bg-white/5 p-1 rounded-lg border border-white/5">
<input
type="color"
value={localConfig.button?.backgroundColor || '#bb86fc'}
onChange={(e) => setLocalConfig({
...localConfig,
button: { ...localConfig.button, backgroundColor: e.target.value }
})}
className="w-8 h-8 rounded cursor-pointer bg-transparent border-none p-0"
/>
<span className="text-xs text-gray-400 font-mono">{localConfig.button?.backgroundColor}</span>
</div>
</div>
<div>
<label className="block text-[10px] text-gray-500 uppercase tracking-widest font-semibold mb-2">Color Texto</label>
<div className="flex items-center gap-2 bg-white/5 p-1 rounded-lg border border-white/5">
<input
type="color"
value={localConfig.button?.textColor || '#ffffff'}
onChange={(e) => setLocalConfig({
...localConfig,
button: { ...localConfig.button, textColor: e.target.value }
})}
className="w-8 h-8 rounded cursor-pointer bg-transparent border-none p-0"
/>
<span className="text-xs text-gray-400 font-mono">{localConfig.button?.textColor}</span>
</div>
</div>
</div>
</div>
)}
</div>
<div className="border-t border-white/10 p-4 bg-white/5">
<button
onClick={() => {
onUpdateConfig(localConfig);
if (onConfirm) onConfirm(localConfig);
onClose();
}}
className="w-full py-3 px-4 bg-purple-600 hover:bg-purple-700 text-white font-bold rounded-lg transition-colors flex items-center justify-center gap-2 shadow-lg"
>
<Save size={20} />
Guardar Configuraci贸n
</button>
</div>
</div>
);
};