Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
216 lines
8.2 KiB
TypeScript
216 lines
8.2 KiB
TypeScript
"use client";
|
|||
|
|
|
||
|
|
import { X } from "lucide-react";
|
||
|
|
import type { CSSProperties } from "react";
|
||
|
|
import { DEFAULT_WORKPLANE_WORKSPACE } from "@/lib/workplaneSettings";
|
||
|
|
import type { GridSize, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
|
||
|
|
|
||
|
|
type WorkspaceSettings = WorkplaneWorkspaceSettings;
|
||
|
|
|
||
|
|
const GRID_SIZES: GridSize[] = ["Off", "0.1 mm", "0.25 mm", "0.5 mm", "1.0 mm", "2.0 mm", "5.0 mm", "Brick"];
|
||
|
|
const MIN_WORKSPACE_SIZE = 60;
|
||
|
|
const MAX_WORKSPACE_SIZE = 2000;
|
||
|
|
const MIN_GRID_BLOCK_SIZE = 1;
|
||
|
|
const MAX_GRID_BLOCK_SIZE = 200;
|
||
|
|
const WORKSPACE_SIZE_PRESETS = [
|
||
|
|
{ label: "200 x 200 mm", width: 200, depth: 200 },
|
||
|
|
{ label: "300 x 300 mm", width: 300, depth: 300 },
|
||
|
|
{ label: "500 x 500 mm", width: 500, depth: 500 },
|
||
|
|
{ label: "1000 x 1000 mm", width: 1000, depth: 1000 },
|
||
|
|
{ label: "2000 x 2000 mm", width: 2000, depth: 2000 },
|
||
|
|
{ label: "Custom", width: 200, depth: 200 },
|
||
|
|
];
|
||
|
|
const GRID_BLOCK_PRESETS = ["1 mm", "2.5 mm", "5 mm", "10 mm", "20 mm", "50 mm", "100 mm", "Custom"] as const;
|
||
|
|
|
||
|
|
function clamp(value: number, min: number, max: number) {
|
||
|
|
return Math.min(max, Math.max(min, value));
|
||
|
|
}
|
||
|
|
|
||
|
|
function gridBlockSizeForPreset(preset: string, fallback: number) {
|
||
|
|
if (preset === "Custom") {
|
||
|
|
return clamp(fallback, MIN_GRID_BLOCK_SIZE, MAX_GRID_BLOCK_SIZE);
|
||
|
|
}
|
||
|
|
return clamp(Number.parseFloat(preset) || DEFAULT_WORKPLANE_WORKSPACE.gridBlockSize, MIN_GRID_BLOCK_SIZE, MAX_GRID_BLOCK_SIZE);
|
||
|
|
}
|
||
|
|
|
||
|
|
export function WorkspaceSettingsModal({
|
||
|
|
workspace,
|
||
|
|
snap,
|
||
|
|
onWorkspaceChange,
|
||
|
|
onSnapChange,
|
||
|
|
onClose,
|
||
|
|
}: {
|
||
|
|
workspace: WorkspaceSettings;
|
||
|
|
snap: GridSize;
|
||
|
|
onWorkspaceChange: (next: WorkspaceSettings) => void;
|
||
|
|
onSnapChange: (next: GridSize) => void;
|
||
|
|
onClose: () => void;
|
||
|
|
}) {
|
||
|
|
const patchWorkspace = (patch: Partial<WorkspaceSettings>) => onWorkspaceChange({ ...workspace, ...patch });
|
||
|
|
const setDimension = (key: "width" | "depth", value: string) => {
|
||
|
|
const next = clamp(Number.parseFloat(value) || DEFAULT_WORKPLANE_WORKSPACE[key], MIN_WORKSPACE_SIZE, MAX_WORKSPACE_SIZE);
|
||
|
|
patchWorkspace({ [key]: next, sizePreset: "Custom" } as Partial<WorkspaceSettings>);
|
||
|
|
};
|
||
|
|
const setWorkspaceSizePreset = (sizePreset: string) => {
|
||
|
|
const preset = WORKSPACE_SIZE_PRESETS.find((entry) => entry.label === sizePreset);
|
||
|
|
if (!preset || sizePreset === "Custom") {
|
||
|
|
patchWorkspace({ sizePreset: "Custom" });
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
patchWorkspace({ sizePreset, width: preset.width, depth: preset.depth });
|
||
|
|
};
|
||
|
|
const setGridBlockPreset = (gridBlockPreset: string) => {
|
||
|
|
patchWorkspace({ gridBlockPreset, gridBlockSize: gridBlockSizeForPreset(gridBlockPreset, workspace.gridBlockSize) });
|
||
|
|
};
|
||
|
|
const setGridBlockSize = (value: string) => {
|
||
|
|
const next = clamp(Number.parseFloat(value) || DEFAULT_WORKPLANE_WORKSPACE.gridBlockSize, MIN_GRID_BLOCK_SIZE, MAX_GRID_BLOCK_SIZE);
|
||
|
|
patchWorkspace({ gridBlockPreset: "Custom", gridBlockSize: next });
|
||
|
|
};
|
||
|
|
|
||
|
|
return (
|
||
|
|
<div className="workspace-modal" role="dialog" aria-modal="true" aria-label="Workspace settings">
|
||
|
|
<div className="workspace-modal-card" onPointerDown={(event) => event.stopPropagation()}>
|
||
|
|
<header className="workspace-modal-header">
|
||
|
|
<strong>Workspace settings</strong>
|
||
|
|
<button aria-label="Close settings" onClick={onClose}>
|
||
|
|
<X size={18} />
|
||
|
|
</button>
|
||
|
|
</header>
|
||
|
|
|
||
|
|
<div className="workspace-modal-body">
|
||
|
|
<div className="workspace-row">
|
||
|
|
<span>Background color</span>
|
||
|
|
<button
|
||
|
|
className="workspace-color-button"
|
||
|
|
style={{ "--workspace-bg": workspace.background } as CSSProperties}
|
||
|
|
aria-label="Background color"
|
||
|
|
onClick={() => patchWorkspace({ background: workspace.background === "#f8fbfc" ? "#eaf7fb" : "#f8fbfc" })}
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
<WorkspaceToggle label="Show shadows" checked={workspace.showShadows} onChange={(showShadows) => patchWorkspace({ showShadows })} />
|
||
|
|
<WorkspaceToggle label="Show grid" checked={workspace.showGrid} onChange={(showGrid) => patchWorkspace({ showGrid })} />
|
||
|
|
<WorkspaceToggle
|
||
|
|
label="Cruise when adding new shapes"
|
||
|
|
checked={workspace.cruiseShapes}
|
||
|
|
onChange={(cruiseShapes) => patchWorkspace({ cruiseShapes })}
|
||
|
|
/>
|
||
|
|
|
||
|
|
<label className="workspace-range">
|
||
|
|
<span>Zoom speed</span>
|
||
|
|
<input
|
||
|
|
type="range"
|
||
|
|
min={1}
|
||
|
|
max={10}
|
||
|
|
value={workspace.zoomSpeed}
|
||
|
|
onChange={(event) => patchWorkspace({ zoomSpeed: Number(event.currentTarget.value) })}
|
||
|
|
/>
|
||
|
|
<small>
|
||
|
|
<span>Slow</span>
|
||
|
|
<span>Fast</span>
|
||
|
|
</small>
|
||
|
|
</label>
|
||
|
|
|
||
|
|
<WorkspaceSelect
|
||
|
|
label="Units"
|
||
|
|
value={workspace.units}
|
||
|
|
options={["Metric (Default)", "Imperial", "Bricks"]}
|
||
|
|
onChange={(units) => patchWorkspace({ units })}
|
||
|
|
/>
|
||
|
|
<WorkspaceSelect
|
||
|
|
label="Scale"
|
||
|
|
value={workspace.scale}
|
||
|
|
options={["1:1 (millimeters)", "1:10 (centimeters)", "1:100 (meters)", "1:1000 (meters)"]}
|
||
|
|
onChange={(scale) => patchWorkspace({ scale })}
|
||
|
|
/>
|
||
|
|
<WorkspaceSelect label="Snap Grid" value={snap} options={GRID_SIZES} onChange={(next) => onSnapChange(next as GridSize)} />
|
||
|
|
<WorkspaceSelect
|
||
|
|
label="Workplane size"
|
||
|
|
value={workspace.sizePreset}
|
||
|
|
options={WORKSPACE_SIZE_PRESETS.map((preset) => preset.label)}
|
||
|
|
onChange={setWorkspaceSizePreset}
|
||
|
|
/>
|
||
|
|
|
||
|
|
<div className="workspace-dimensions">
|
||
|
|
<label>
|
||
|
|
<span>Width</span>
|
||
|
|
<input
|
||
|
|
type="number"
|
||
|
|
value={workspace.width.toFixed(2)}
|
||
|
|
min={MIN_WORKSPACE_SIZE}
|
||
|
|
max={MAX_WORKSPACE_SIZE}
|
||
|
|
step={1}
|
||
|
|
onChange={(event) => setDimension("width", event.currentTarget.value)}
|
||
|
|
/>
|
||
|
|
</label>
|
||
|
|
<label>
|
||
|
|
<span>Length</span>
|
||
|
|
<input
|
||
|
|
type="number"
|
||
|
|
value={workspace.depth.toFixed(2)}
|
||
|
|
min={MIN_WORKSPACE_SIZE}
|
||
|
|
max={MAX_WORKSPACE_SIZE}
|
||
|
|
step={1}
|
||
|
|
onChange={(event) => setDimension("depth", event.currentTarget.value)}
|
||
|
|
/>
|
||
|
|
</label>
|
||
|
|
</div>
|
||
|
|
<WorkspaceSelect label="Grid block size" value={workspace.gridBlockPreset} options={GRID_BLOCK_PRESETS} onChange={setGridBlockPreset} />
|
||
|
|
{workspace.gridBlockPreset === "Custom" ? (
|
||
|
|
<div className="workspace-dimensions workspace-grid-dimensions">
|
||
|
|
<label>
|
||
|
|
<span>Block size</span>
|
||
|
|
<input
|
||
|
|
type="number"
|
||
|
|
value={workspace.gridBlockSize.toFixed(2)}
|
||
|
|
min={MIN_GRID_BLOCK_SIZE}
|
||
|
|
max={MAX_GRID_BLOCK_SIZE}
|
||
|
|
step={0.5}
|
||
|
|
onChange={(event) => setGridBlockSize(event.currentTarget.value)}
|
||
|
|
/>
|
||
|
|
</label>
|
||
|
|
</div>
|
||
|
|
) : null}
|
||
|
|
|
||
|
|
<button className="make-default-button" onClick={() => onWorkspaceChange(DEFAULT_WORKPLANE_WORKSPACE)}>
|
||
|
|
Make default
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<button className="workspace-modal-backdrop" aria-label="Close settings" onClick={onClose} />
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
function WorkspaceToggle({ label, checked, onChange }: { label: string; checked: boolean; onChange: (checked: boolean) => void }) {
|
||
|
|
return (
|
||
|
|
<label className="workspace-toggle">
|
||
|
|
<span>{label}</span>
|
||
|
|
<input type="checkbox" checked={checked} onChange={(event) => onChange(event.currentTarget.checked)} />
|
||
|
|
</label>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
function WorkspaceSelect({
|
||
|
|
label,
|
||
|
|
value,
|
||
|
|
options,
|
||
|
|
onChange,
|
||
|
|
}: {
|
||
|
|
label: string;
|
||
|
|
value: string;
|
||
|
|
options: readonly string[];
|
||
|
|
onChange: (value: string) => void;
|
||
|
|
}) {
|
||
|
|
return (
|
||
|
|
<label className="workspace-select">
|
||
|
|
<span>{label}</span>
|
||
|
|
<select value={value} onChange={(event) => onChange(event.currentTarget.value)}>
|
||
|
|
{options.map((option) => (
|
||
|
|
<option key={option} value={option}>
|
||
|
|
{option}
|
||
|
|
</option>
|
||
|
|
))}
|
||
|
|
</select>
|
||
|
|
</label>
|
||
|
|
);
|
||
|
|
}
|