import React from 'react'; import { AppConfig, PerforationShape } from '../types'; import { Ruler, Box, Layers, Minimize2, CircleDashed, Grid, Circle, Hexagon, Triangle } from 'lucide-react'; interface Props { config: AppConfig; onChange: (newConfig: AppConfig) => void; } const InputGroup: React.FC<{ label: string; children: React.ReactNode }> = ({ label, children }) => (
{children}
); const NumberInput = ({ label, value, onChange, max }: { label: string; value: number; onChange: (val: number) => void; max?: number }) => (
{label} onChange(parseFloat(e.target.value) || 0)} className="w-full bg-slate-800 border border-slate-700 rounded p-2 pl-8 text-white focus:ring-2 focus:ring-primary outline-none" /> мм
); const PerforationPreview = ({ config }: { config: AppConfig['perforation'] }) => { if (!config.enabled) return (
Перфорация отключена
); // Simple canvas-like SVG generation const width = 200; const height = 120; const size = config.size * 2; // Scale up mostly for visibility const gap = config.gap * 2; const step = size + gap; const elements = []; if (config.shape === 'circle') { for (let y = 0; y < height; y += step) { for (let x = 0; x < width; x += step) { elements.push(); } } } else if (config.shape === 'honeycomb') { const hStep = size * 0.866; // height of equilateral triangle for (let y = 0; y < height; y += (size + gap) * 0.85) { const row = Math.floor(y / ((size + gap) * 0.85)); const xOffset = row % 2 === 0 ? 0 : (size + gap) / 2; for (let x = xOffset - step; x < width; x += step) { // Hexagon points const r = size / 2; const cx = x + step / 2; const cy = y + step / 2; // Points for flat-topped hexagon const points = []; for (let i = 0; i < 6; i++) { const angle_deg = 60 * i + 30; const angle_rad = Math.PI / 180 * angle_deg; points.push(`${cx + r * Math.cos(angle_rad)},${cy + r * Math.sin(angle_rad)}`); } elements.push(); } } } else if (config.shape === 'triangle') { for (let y = 0; y < height; y += step * 0.866) { // Staggered rows const row = Math.floor(y / (step * 0.866)); const xOffset = row % 2 === 0 ? 0 : step / 2; for (let x = -step + xOffset; x < width; x += step) { const cx = x + step / 2; const cy = y + step / 2; const r = size / 2; // Upright triangle const points = [ `${cx},${cy - r}`, `${cx + r * 0.866},${cy + r * 0.5}`, `${cx - r * 0.866},${cy + r * 0.5}` ]; elements.push(); } } } return (
{elements}
:: Масштаб условен
); } export const ConfigStep: React.FC = ({ config, onChange }) => { const updateDrawer = (key: keyof AppConfig['drawer'], val: number) => { onChange({ ...config, drawer: { ...config.drawer, [key]: val } }); }; const updatePerforation = (key: keyof AppConfig['perforation'], val: any) => { onChange({ ...config, perforation: { ...config.perforation, [key]: val } }) } return (
{/* SECTION 1: Dimensions & Settings */}

1. Размеры

{/* Drawer Dimensions */}

Внутренние размеры ящика

updateDrawer('width', v)} /> updateDrawer('depth', v)} /> updateDrawer('height', v)} />
{/* Settings */}

Параметры печати

{/* Wall Thickness */}
{config.wallThickness.toFixed(1)} мм
0.4 onChange({ ...config, wallThickness: parseFloat(e.target.value) })} className="w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-primary hover:accent-blue-400 transition-all" /> 3.2
{/* Corner Radius */}
{config.cornerRadius?.toFixed(0) || 0} мм
0 onChange({ ...config, cornerRadius: parseFloat(e.target.value) })} className="w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-purple-500 hover:accent-purple-400 transition-all" /> 20
{/* Printer Tolerance */}
{config.printerTolerance.toFixed(1)} мм
0.0 onChange({ ...config, printerTolerance: parseFloat(e.target.value) })} className="w-full h-2 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-accent hover:accent-amber-400 transition-all" /> 2.0
{/* SECTION 2: Perforation */}

2. Перфорация (узоры)

Включено
{[ { id: 'circle', icon: Circle, label: 'Круг' }, { id: 'honeycomb', icon: Hexagon, label: 'Соты' }, { id: 'triangle', icon: Triangle, label: 'Треуг.' } ].map((item) => ( ))}
{/* Resize Controls */}
{config.perforation.size} мм
2 мм updatePerforation('size', parseFloat(e.target.value))} className="flex-1 h-1.5 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-blue-500" /> 25 мм
{config.perforation.gap} мм
1 мм updatePerforation('gap', parseFloat(e.target.value))} className="flex-1 h-1.5 bg-slate-700 rounded-lg appearance-none cursor-pointer accent-blue-500" /> 10 мм
{/* Preview */}
); };