Try fix build
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React, { useRef, useState, useMemo } from 'react';
|
||||
import { AppConfig, LayoutSplits, Partition } from '../types';
|
||||
import { Grid, MousePointer2, Trash2, RotateCcw, X, Move, Settings2 } from 'lucide-react';
|
||||
// ИСПОЛЬЗУЕМ ТОЛЬКО БАЗОВЫЕ ИКОНКИ (чтобы не ломать билд)
|
||||
import { Grid, MousePointer2, Trash2, RotateCcw, X, Plus } from 'lucide-react';
|
||||
|
||||
interface Props {
|
||||
config: AppConfig;
|
||||
@@ -21,20 +22,17 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
|
||||
const [mode, setMode] = useState<EditMode>('lines');
|
||||
|
||||
// Мышь и состояния
|
||||
const [mousePos, setMousePos] = useState({ x: 0, y: 0 });
|
||||
const [isButtonHovered, setIsButtonHovered] = useState(false);
|
||||
|
||||
// Main Grid States
|
||||
// States
|
||||
const [phantomMainAxis, setPhantomMainAxis] = useState<Axis | null>(null);
|
||||
const [hoveredMainSplit, setHoveredMainSplit] = useState<{ axis: Axis; index: number } | null>(null);
|
||||
|
||||
// Partition States
|
||||
const [hoveredCell, setHoveredCell] = useState<{ i: number; j: number } | null>(null);
|
||||
const [hoveredPartition, setHoveredPartition] = useState<{ id: string; cellKey: string } | null>(null);
|
||||
const [phantomPartition, setPhantomPartition] = useState<{ axis: Axis; offset: number } | null>(null);
|
||||
|
||||
// Selection & Dragging
|
||||
const [selectedPartitionId, setSelectedPartitionId] = useState<string | null>(null);
|
||||
const [dragging, setDragging] = useState<DragTarget | null>(null);
|
||||
|
||||
@@ -43,19 +41,17 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
const safeY = Array.isArray(splits?.y) ? splits.y : [];
|
||||
const safePartitions = splits?.partitions || {};
|
||||
|
||||
// --- Dimensions & Aspect Ratio ---
|
||||
const drawerW = Math.max(1, config.drawer.width || 300);
|
||||
const drawerD = Math.max(1, config.drawer.depth || 400);
|
||||
const aspectRatio = drawerD / drawerW;
|
||||
|
||||
// ViewBox (internal SVG coordinates)
|
||||
const viewBoxW = 1000;
|
||||
const viewBoxH = viewBoxW * aspectRatio;
|
||||
|
||||
const sortedX = useMemo(() => [0, ...safeX, 1].sort((a, b) => a - b), [safeX]);
|
||||
const sortedY = useMemo(() => [0, ...safeY, 1].sort((a, b) => a - b), [safeY]);
|
||||
|
||||
// --- Helper: Get Partition Data ---
|
||||
// --- Helpers ---
|
||||
const getSelectedPartition = () => {
|
||||
if (!selectedPartitionId) return null;
|
||||
for (const key in safePartitions) {
|
||||
@@ -66,7 +62,7 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
};
|
||||
const selectedData = getSelectedPartition();
|
||||
|
||||
// --- ACTIONS: MAIN GRID ---
|
||||
// --- ACTIONS ---
|
||||
const removeMainSplit = (axis: Axis, index: number) => {
|
||||
const newSplits = { ...splits, x: [...safeX], y: [...safeY] };
|
||||
newSplits[axis] = newSplits[axis].filter((_, i) => i !== index);
|
||||
@@ -76,7 +72,6 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
setIsButtonHovered(false);
|
||||
};
|
||||
|
||||
// --- ACTIONS: PARTITIONS ---
|
||||
const createPartition = (i: number, j: number, axis: Axis, offset: number) => {
|
||||
const key = `${i}-${j}`;
|
||||
const current = safePartitions[key] || [];
|
||||
@@ -110,12 +105,10 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
const rect = svgRef.current.getBoundingClientRect();
|
||||
if (rect.width === 0) return;
|
||||
|
||||
// Normalize coordinates (0 to 1)
|
||||
const nx = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
||||
const ny = Math.max(0, Math.min(1, (e.clientY - rect.top) / rect.height));
|
||||
setMousePos({ x: nx, y: ny });
|
||||
|
||||
// --- DRAGGING LOGIC ---
|
||||
if (dragging) {
|
||||
if (dragging.type === 'main') {
|
||||
const newSplits = { ...splits, x: [...safeX], y: [...safeY] };
|
||||
@@ -123,33 +116,32 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
newSplits[dragging.axis][dragging.index] = val;
|
||||
onChange(newSplits);
|
||||
} else {
|
||||
// Dragging Partition
|
||||
const [iStr, jStr] = dragging.cellKey.split('-');
|
||||
// Явное приведение типа для TS, чтобы не ругался при билде
|
||||
const pDrag = dragging as { type: 'partition'; cellKey: string; id: string; axis: Axis };
|
||||
const [iStr, jStr] = pDrag.cellKey.split('-');
|
||||
const i = parseInt(iStr); const j = parseInt(jStr);
|
||||
|
||||
const cellX1 = sortedX[i]; const cellX2 = sortedX[i+1];
|
||||
const cellY1 = sortedY[j]; const cellY2 = sortedY[j+1];
|
||||
|
||||
let newOffset = 0;
|
||||
if (dragging.axis === 'x') {
|
||||
if (pDrag.axis === 'x') {
|
||||
newOffset = (nx - cellX1) / (cellX2 - cellX1);
|
||||
} else {
|
||||
newOffset = (ny - cellY1) / (cellY2 - cellY1);
|
||||
}
|
||||
newOffset = Math.max(0.05, Math.min(0.95, newOffset));
|
||||
updatePartition(dragging.cellKey, dragging.id, { offset: newOffset });
|
||||
updatePartition(pDrag.cellKey, pDrag.id, { offset: newOffset });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (isButtonHovered) return;
|
||||
|
||||
// --- HOVER LOGIC: MAIN LINES ---
|
||||
// --- MODE: LINES ---
|
||||
if (mode === 'lines') {
|
||||
setHoveredMainSplit(null);
|
||||
const SNAP = 0.015;
|
||||
|
||||
// Phantom Line
|
||||
if (nx > SNAP && nx < 1-SNAP && ny > SNAP && ny < 1-SNAP) {
|
||||
const closeToX = safeX.some(val => Math.abs(nx - val) < SNAP);
|
||||
const closeToY = safeY.some(val => Math.abs(ny - val) < SNAP);
|
||||
@@ -159,14 +151,12 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
} else { setPhantomMainAxis(null); }
|
||||
}
|
||||
}
|
||||
|
||||
// --- HOVER LOGIC: PARTITIONS ---
|
||||
// --- MODE: CELLS ---
|
||||
else if (mode === 'cells') {
|
||||
setHoveredPartition(null);
|
||||
setPhantomPartition(null);
|
||||
setHoveredCell(null);
|
||||
|
||||
// 1. Find which cell we are in
|
||||
let cellIndex = null;
|
||||
for(let i=0; i<sortedX.length-1; i++) {
|
||||
if (nx >= sortedX[i] && nx <= sortedX[i+1]) {
|
||||
@@ -188,11 +178,9 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
const cy1 = sortedY[cellIndex.j]; const cy2 = sortedY[cellIndex.j+1];
|
||||
const cw = cx2 - cx1; const ch = cy2 - cy1;
|
||||
|
||||
// Local coords in cell (0..1)
|
||||
const lx = (nx - cx1) / cw;
|
||||
const ly = (ny - cy1) / ch;
|
||||
|
||||
// Check existing partitions
|
||||
let foundPart = null;
|
||||
const PART_SNAP = 0.05;
|
||||
|
||||
@@ -207,12 +195,10 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
if (foundPart) {
|
||||
setHoveredPartition({ id: foundPart.id, cellKey: key });
|
||||
} else {
|
||||
// Show Phantom Partition
|
||||
const distLeft = lx; const distRight = 1 - lx;
|
||||
const distTop = ly; const distBottom = 1 - ly;
|
||||
const minX = Math.min(distLeft, distRight);
|
||||
const minY = Math.min(distTop, distBottom);
|
||||
|
||||
const axis = minX < minY ? 'y' : 'x';
|
||||
|
||||
if (lx > 0.05 && lx < 0.95 && ly > 0.05 && ly < 0.95) {
|
||||
@@ -280,7 +266,7 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
<div className="flex bg-slate-800 p-1 rounded-lg border border-slate-700">
|
||||
<button onClick={() => { setMode('lines'); setSelectedPartitionId(null); }}
|
||||
className={`flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-bold transition-all ${mode === 'lines' ? 'bg-primary text-white shadow' : 'text-gray-400 hover:text-gray-200'}`}>
|
||||
<Move size={14}/> Границы
|
||||
<MousePointer2 size={14}/> Границы
|
||||
</button>
|
||||
<button onClick={() => setMode('cells')}
|
||||
className={`flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-bold transition-all ${mode === 'cells' ? 'bg-primary text-white shadow' : 'text-gray-400 hover:text-gray-200'}`}>
|
||||
@@ -305,39 +291,27 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
<div className="flex gap-3">
|
||||
<span><b className="text-green-400">ЛКМ в ячейке:</b> Создать перегородку</span>
|
||||
<span><b className="text-purple-400">Драг:</b> Двигать</span>
|
||||
<span><b className="text-red-400">ПКМ:</b> Удалить</span>
|
||||
<span><b className="text-red-400">2xЛКМ:</b> Удалить</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* --- CANVAS AREA --- */}
|
||||
{/* --- CANVAS --- */}
|
||||
<div className="flex-1 bg-slate-800/30 rounded-lg flex flex-col items-center justify-center relative overflow-hidden border border-slate-700/50 min-h-0 w-full">
|
||||
|
||||
{/* SVG Container - FILLS SPACE BUT KEEPS ASPECT RATIO */}
|
||||
<div className="relative w-full h-full flex items-center justify-center p-4">
|
||||
<div
|
||||
className="relative shadow-2xl bg-[#1e293b] border border-slate-600 rounded-sm overflow-hidden"
|
||||
<div className="relative shadow-2xl bg-[#1e293b] border border-slate-600 rounded-sm overflow-hidden"
|
||||
style={{
|
||||
// Magic to keep aspect ratio and fit in parent
|
||||
width: aspectRatio > 1 ? 'auto' : '100%',
|
||||
height: aspectRatio > 1 ? '100%' : 'auto',
|
||||
aspectRatio: `${1/aspectRatio}`,
|
||||
maxHeight: '100%',
|
||||
maxWidth: '100%',
|
||||
maxHeight: '100%', maxWidth: '100%',
|
||||
cursor: mode === 'lines' ? (dragging ? 'grabbing' : hoveredMainSplit ? 'col-resize' : 'crosshair')
|
||||
: (dragging ? 'grabbing' : hoveredPartition ? 'grab' : hoveredCell ? 'crosshair' : 'default'),
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
ref={svgRef}
|
||||
viewBox={`0 0 ${viewBoxW} ${viewBoxH}`}
|
||||
className="w-full h-full touch-none block"
|
||||
<svg ref={svgRef} viewBox={`0 0 ${viewBoxW} ${viewBoxH}`} className="w-full h-full touch-none block"
|
||||
preserveAspectRatio="none"
|
||||
onMouseMove={handleMouseMove}
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseUp={() => setDragging(null)}
|
||||
onMouseLeave={() => setDragging(null)}
|
||||
onContextMenu={(e) => e.preventDefault()}
|
||||
onMouseMove={handleGlobalMouseMove} onMouseDown={handleMouseDown} onMouseUp={() => setDragging(null)} onMouseLeave={() => setDragging(null)} onContextMenu={(e) => e.preventDefault()}
|
||||
>
|
||||
<defs>
|
||||
<pattern id="grid" width="50" height="50" patternUnits="userSpaceOnUse">
|
||||
@@ -346,77 +320,41 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="url(#grid)" />
|
||||
|
||||
{/* --- ЯЧЕЙКИ И ВНУТРЕННОСТИ --- */}
|
||||
{/* --- CELLS & PARTITIONS --- */}
|
||||
{sortedX.slice(0, -1).map((x1, i) => {
|
||||
const x2 = sortedX[i + 1];
|
||||
return sortedY.slice(0, -1).map((y1, j) => {
|
||||
const y2 = sortedY[j + 1];
|
||||
const y2 = sortedY[j + 1]; // Гарантированно определена
|
||||
const cellX = x1 * viewBoxW; const cellY = y1 * viewBoxH;
|
||||
const cellW = (x2 - x1) * viewBoxW; const cellH = (y2 - y1) * viewBoxH;
|
||||
|
||||
const key = `${i}-${j}`;
|
||||
const parts = safePartitions[key] || [];
|
||||
|
||||
// Логика выделения ячейки
|
||||
const isHovered = hoveredCell?.i === i && hoveredCell?.j === j && mode === 'cells';
|
||||
const isAnyPartSelected = parts.some(p => p.id === selectedPartitionId);
|
||||
|
||||
return (
|
||||
<g key={`cell-${key}`}>
|
||||
{/* Фон ячейки при наведении */}
|
||||
{isHovered && (
|
||||
<rect x={cellX} y={cellY} width={cellW} height={cellH} fill="rgba(16, 185, 129, 0.05)" stroke="#10b981" strokeWidth="2" strokeDasharray="4,4" className="pointer-events-none"/>
|
||||
)}
|
||||
|
||||
{/* Рамка если выбрана стенка внутри этой ячейки */}
|
||||
{isAnyPartSelected && mode === 'cells' && (
|
||||
<rect x={cellX} y={cellY} width={cellW} height={cellH} fill="transparent" stroke="#a855f7" strokeWidth="2" className="pointer-events-none opacity-50"/>
|
||||
)}
|
||||
|
||||
{/* Перегородки */}
|
||||
{isHovered && <rect x={cellX} y={cellY} width={cellW} height={cellH} fill="rgba(16, 185, 129, 0.05)" stroke="#10b981" strokeWidth="2" strokeDasharray="4,4" className="pointer-events-none"/>}
|
||||
{isAnyPartSelected && mode === 'cells' && <rect x={cellX} y={cellY} width={cellW} height={cellH} fill="transparent" stroke="#a855f7" strokeWidth="2" className="pointer-events-none opacity-50"/>}
|
||||
{parts.map(p => {
|
||||
const isSelected = selectedPartitionId === p.id;
|
||||
const isHoveredPart = hoveredPartition?.id === p.id;
|
||||
|
||||
let lx1, ly1, lx2, ly2;
|
||||
if (p.axis === 'x') {
|
||||
const px = cellX + (cellW * p.offset);
|
||||
lx1 = px; ly1 = cellY; lx2 = px; ly2 = cellY + cellH;
|
||||
} else {
|
||||
const py = cellY + (cellH * p.offset);
|
||||
lx1 = cellX; ly1 = py; lx2 = cellX + cellW; ly2 = py;
|
||||
}
|
||||
|
||||
if (p.axis === 'x') { const px = cellX + (cellW * p.offset); lx1 = px; ly1 = cellY; lx2 = px; ly2 = cellY + cellH; }
|
||||
else { const py = cellY + (cellH * p.offset); lx1 = cellX; ly1 = py; lx2 = cellX + cellW; ly2 = py; }
|
||||
return (
|
||||
<g key={p.id} onDoubleClick={(e) => { e.stopPropagation(); removePartition(key, p.id); }}>
|
||||
{/* Толстая невидимая линия для захвата */}
|
||||
<line x1={lx1} y1={ly1} x2={lx2} y2={ly2} stroke="transparent" strokeWidth="30" />
|
||||
{/* Видимая линия */}
|
||||
<line x1={lx1} y1={ly1} x2={lx2} y2={ly2}
|
||||
stroke={isSelected ? "#a855f7" : (isHoveredPart ? "#d8b4fe" : "#7e22ce")}
|
||||
strokeWidth={isSelected ? 6 : 4}
|
||||
strokeLinecap="round"
|
||||
/>
|
||||
<line x1={lx1} y1={ly1} x2={lx2} y2={ly2} stroke={isSelected ? "#a855f7" : (isHoveredPart ? "#d8b4fe" : "#7e22ce")} strokeWidth={isSelected ? 6 : 4} strokeLinecap="round" />
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Фантомная перегородка */}
|
||||
{isHovered && phantomPartition && !hoveredPartition && !dragging && (
|
||||
<g className="pointer-events-none opacity-60">
|
||||
{phantomPartition.axis === 'x' ? (
|
||||
<line
|
||||
x1={cellX + (cellW * phantomPartition.offset)} y1={cellY}
|
||||
x2={cellX + (cellW * phantomPartition.offset)} y2={cellY + cellH}
|
||||
stroke="#34d399" strokeWidth="3" strokeDasharray="6,6"
|
||||
/>
|
||||
) : (
|
||||
<line
|
||||
x1={cellX} y1={cellY + (cellH * phantomPartition.offset)}
|
||||
x2={cellX + cellW} y2={cellY + (cellH * phantomPartition.offset)}
|
||||
stroke="#34d399" strokeWidth="3" strokeDasharray="6,6"
|
||||
/>
|
||||
)}
|
||||
{phantomPartition.axis === 'x' ?
|
||||
<line x1={cellX + (cellW * phantomPartition.offset)} y1={cellY} x2={cellX + (cellW * phantomPartition.offset)} y2={cellY + cellH} stroke="#34d399" strokeWidth="3" strokeDasharray="6,6"/> :
|
||||
<line x1={cellX} y1={cellY + (cellH * phantomPartition.offset)} x2={cellX + cellW} y2={cellY + (cellH * phantomPartition.offset)} stroke="#34d399" strokeWidth="3" strokeDasharray="6,6"/>
|
||||
}
|
||||
</g>
|
||||
)}
|
||||
</g>
|
||||
@@ -424,84 +362,55 @@ export const LayoutStep: React.FC<Props> = ({ config, splits, onChange }) => {
|
||||
});
|
||||
})}
|
||||
|
||||
{/* --- ГЛАВНЫЕ ЛИНИИ (Поверх всего) --- */}
|
||||
{/* --- MAIN GRID --- */}
|
||||
{safeX.map((x, i) => {
|
||||
const isHovered = hoveredMainSplit?.axis === 'x' && hoveredMainSplit.index === i;
|
||||
return (
|
||||
<g key={`x-${i}`}
|
||||
onMouseMove={(e) => { if(mode === 'lines' && !dragging) { e.stopPropagation(); setHoveredMainSplit({axis: 'x', index: i}); setPhantomMainAxis(null); }}}
|
||||
onDoubleClick={(e) => { e.stopPropagation(); removeMainSplit('x', i); }}
|
||||
>
|
||||
<g key={`x-${i}`} onMouseMove={(e) => { if(mode === 'lines' && !dragging) { e.stopPropagation(); setHoveredMainSplit({axis: 'x', index: i}); setPhantomMainAxis(null); }}} onDoubleClick={(e) => { e.stopPropagation(); removeMainSplit('x', i); }}>
|
||||
<line x1={x * viewBoxW} y1="0" x2={x * viewBoxW} y2="100%" stroke="transparent" strokeWidth="40" className={mode === 'lines' ? "cursor-col-resize" : ""} />
|
||||
<line x1={x * viewBoxW} y1="0" x2={x * viewBoxW} y2="100%" stroke={isHovered ? "#f59e0b" : "#64748b"} strokeWidth={isHovered ? 6 : 4} className="pointer-events-none" />
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
|
||||
{safeY.map((y, i) => {
|
||||
const isHovered = hoveredMainSplit?.axis === 'y' && hoveredMainSplit.index === i;
|
||||
return (
|
||||
<g key={`y-${i}`}
|
||||
onMouseMove={(e) => { if(mode === 'lines' && !dragging) { e.stopPropagation(); setHoveredMainSplit({axis: 'y', index: i}); setPhantomMainAxis(null); }}}
|
||||
onDoubleClick={(e) => { e.stopPropagation(); removeMainSplit('y', i); }}
|
||||
>
|
||||
<g key={`y-${i}`} onMouseMove={(e) => { if(mode === 'lines' && !dragging) { e.stopPropagation(); setHoveredMainSplit({axis: 'y', index: i}); setPhantomMainAxis(null); }}} onDoubleClick={(e) => { e.stopPropagation(); removeMainSplit('y', i); }}>
|
||||
<line x1="0" y1={y * viewBoxH} x2="100%" y2={y * viewBoxH} stroke="transparent" strokeWidth="40" className={mode === 'lines' ? "cursor-row-resize" : ""} />
|
||||
<line x1="0" y1={y * viewBoxH} x2="100%" y2={y * viewBoxH} stroke={isHovered ? "#f59e0b" : "#64748b"} strokeWidth={isHovered ? 6 : 4} className="pointer-events-none" />
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* Фантомная главная линия */}
|
||||
{mode === 'lines' && !hoveredMainSplit && !dragging && phantomMainAxis === 'x' && <line x1={mousePos.x * viewBoxW} y1="0" x2={mousePos.x * viewBoxW} y2="100%" stroke="#3b82f6" strokeWidth="4" strokeDasharray="8,8" className="pointer-events-none opacity-50"/>}
|
||||
{mode === 'lines' && !hoveredMainSplit && !dragging && phantomMainAxis === 'y' && <line x1="0" y1={mousePos.y * viewBoxH} x2="100%" y2={mousePos.y * viewBoxH} stroke="#3b82f6" strokeWidth="4" strokeDasharray="8,8" className="pointer-events-none opacity-50"/>}
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* --- SIDEBAR FOR SELECTED PARTITION SETTINGS --- */}
|
||||
{/* --- SIDEBAR --- */}
|
||||
{mode === 'cells' && selectedData && (
|
||||
<div className="absolute top-0 right-0 bottom-0 w-72 bg-slate-900 border-l border-slate-700 p-4 shadow-2xl flex flex-col z-30 animate-in slide-in-from-right duration-200">
|
||||
<div className="flex justify-between items-center mb-6">
|
||||
<h3 className="text-sm font-bold text-white flex items-center gap-2">
|
||||
<Settings2 size={16} className="text-purple-400"/> Настройки стенки
|
||||
<Grid size={16} className="text-purple-400"/> Настройки стенки
|
||||
</h3>
|
||||
<button onClick={() => setSelectedPartitionId(null)} className="text-gray-400 hover:text-white"><X size={20}/></button>
|
||||
</div>
|
||||
|
||||
<div className="bg-slate-800 p-4 rounded border border-slate-700 space-y-6">
|
||||
{/* Высота */}
|
||||
<div>
|
||||
<div className="flex justify-between text-xs text-gray-300 mb-2">
|
||||
<span>Высота</span>
|
||||
<span className="font-mono bg-slate-900 px-1.5 py-0.5 rounded text-xs">{selectedData.part.height} мм</span>
|
||||
</div>
|
||||
<input type="range" min="5" max={config.drawer.height || 100} step="1" value={selectedData.part.height}
|
||||
onChange={(e) => updatePartition(selectedData.key, selectedData.part.id, { height: parseFloat(e.target.value) })}
|
||||
className="w-full h-1 bg-slate-600 rounded-lg appearance-none cursor-pointer accent-purple-500"
|
||||
/>
|
||||
<div className="flex justify-between text-xs text-gray-300 mb-2"><span>Высота</span> <span className="font-mono bg-slate-900 px-1.5 py-0.5 rounded text-xs">{selectedData.part.height} мм</span></div>
|
||||
<input type="range" min="5" max={config.drawer.height || 100} step="1" value={selectedData.part.height} onChange={(e) => updatePartition(selectedData.key, selectedData.part.id, { height: parseFloat(e.target.value) })} className="w-full h-1 bg-slate-600 rounded-lg appearance-none cursor-pointer accent-purple-500"/>
|
||||
</div>
|
||||
|
||||
{/* Скругление */}
|
||||
<div className="flex items-center justify-between">
|
||||
<label htmlFor="rounded-check" className="text-xs text-gray-300 cursor-pointer select-none">Скруглить края</label>
|
||||
<input type="checkbox" id="rounded-check" checked={selectedData.part.rounded}
|
||||
onChange={(e) => updatePartition(selectedData.key, selectedData.part.id, { rounded: e.target.checked })}
|
||||
className="w-4 h-4 rounded bg-slate-700 border-slate-600 text-purple-500 focus:ring-0 cursor-pointer"
|
||||
/>
|
||||
<input type="checkbox" id="rounded-check" checked={selectedData.part.rounded} onChange={(e) => updatePartition(selectedData.key, selectedData.part.id, { rounded: e.target.checked })} className="w-4 h-4 rounded bg-slate-700 border-slate-600 text-purple-500 focus:ring-0 cursor-pointer"/>
|
||||
</div>
|
||||
|
||||
{/* Удалить */}
|
||||
<button
|
||||
onClick={() => removePartition(selectedData.key, selectedData.part.id)}
|
||||
className="w-full py-2 bg-red-500/10 hover:bg-red-500/20 text-red-400 border border-red-500/30 rounded text-xs flex items-center justify-center gap-2 transition-colors mt-4"
|
||||
>
|
||||
<button onClick={() => removePartition(selectedData.key, selectedData.part.id)} className="w-full py-2 bg-red-500/10 hover:bg-red-500/20 text-red-400 border border-red-500/30 rounded text-xs flex items-center justify-center gap-2 transition-colors mt-4">
|
||||
<Trash2 size={14}/> Удалить
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="mt-auto text-[10px] text-gray-500 text-center leading-relaxed">
|
||||
Выделите стенку для настройки.<br/>Двойной клик удаляет её.
|
||||
</div>
|
||||
<div className="mt-auto text-[10px] text-gray-500 text-center leading-relaxed">Выделите стенку для настройки.<br/>Двойной клик удаляет её.</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -11,11 +11,11 @@ export interface AppConfig {
|
||||
cornerRadius: number;
|
||||
}
|
||||
|
||||
// Описание одной внутренней перегородки
|
||||
// Описание внутренней перегородки
|
||||
export interface Partition {
|
||||
id: string;
|
||||
axis: 'x' | 'y';
|
||||
offset: number; // 0.1 - 0.9
|
||||
offset: number; // 0.1 - 0.9
|
||||
height: number;
|
||||
rounded: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user