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
Release v0.2.0 with Docker deployment
This commit is contained in:
+198
-16
@@ -413,7 +413,7 @@ button {
|
||||
grid-row: 1 / span 2;
|
||||
}
|
||||
|
||||
.project-delete {
|
||||
.project-menu-trigger {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
@@ -430,15 +430,59 @@ button {
|
||||
box-shadow: 0 2px 6px rgba(24, 43, 60, 0.1);
|
||||
}
|
||||
|
||||
.project-card:hover .project-delete,
|
||||
.project-delete:focus-visible {
|
||||
.project-card:hover .project-menu-trigger,
|
||||
.project-menu-trigger:focus-visible {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.project-delete:hover {
|
||||
.project-menu-trigger:hover,
|
||||
.project-menu-trigger[aria-expanded="true"] {
|
||||
color: #264d6b;
|
||||
border-color: #a9bdcc;
|
||||
background: #f5f9fc;
|
||||
}
|
||||
|
||||
.project-card-menu {
|
||||
position: absolute;
|
||||
top: 52px;
|
||||
right: 12px;
|
||||
z-index: 4;
|
||||
display: grid;
|
||||
width: 148px;
|
||||
gap: 3px;
|
||||
padding: 5px;
|
||||
color: #314b61;
|
||||
background: #ffffff;
|
||||
border: 1px solid #ccd9e3;
|
||||
border-radius: 7px;
|
||||
box-shadow: 0 10px 28px rgba(24, 43, 60, 0.18);
|
||||
}
|
||||
|
||||
.project-card-menu button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
min-height: 36px;
|
||||
padding: 0 10px;
|
||||
color: inherit;
|
||||
background: transparent;
|
||||
border-radius: 5px;
|
||||
font-weight: 700;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.project-card-menu button:hover,
|
||||
.project-card-menu button:focus-visible {
|
||||
background: #eef5fa;
|
||||
}
|
||||
|
||||
.project-card-menu button.delete {
|
||||
color: #b01925;
|
||||
border-color: #efb7be;
|
||||
background: #fff4f5;
|
||||
}
|
||||
|
||||
.project-card-menu button.delete:hover,
|
||||
.project-card-menu button.delete:focus-visible {
|
||||
background: #fff1f2;
|
||||
}
|
||||
|
||||
.dashboard-confirm-overlay {
|
||||
@@ -524,6 +568,44 @@ button {
|
||||
background: #c82031;
|
||||
}
|
||||
|
||||
.dashboard-confirm-save {
|
||||
color: #ffffff;
|
||||
border: 1px solid #147ca8;
|
||||
background: #147ca8;
|
||||
}
|
||||
|
||||
.dashboard-confirm-save:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.45;
|
||||
}
|
||||
|
||||
.dashboard-rename-dialog > label {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
padding: 18px;
|
||||
color: #40586c;
|
||||
font-size: 13px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.dashboard-rename-dialog input {
|
||||
width: 100%;
|
||||
height: 42px;
|
||||
padding: 0 12px;
|
||||
color: #1d3448;
|
||||
background: #ffffff;
|
||||
border: 1px solid #b9cad7;
|
||||
border-radius: 6px;
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.dashboard-rename-dialog input:focus {
|
||||
border-color: #1486b5;
|
||||
box-shadow: 0 0 0 3px rgba(20, 134, 181, 0.14);
|
||||
}
|
||||
|
||||
.project-empty {
|
||||
display: grid;
|
||||
min-height: 190px;
|
||||
@@ -2707,9 +2789,9 @@ button {
|
||||
.workspace-modal-card {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
width: 520px;
|
||||
width: 760px;
|
||||
max-width: calc(100vw - 32px);
|
||||
min-height: min(720px, calc(100vh - 104px));
|
||||
height: min(650px, calc(100vh - 104px));
|
||||
max-height: calc(100vh - 104px);
|
||||
overflow: hidden;
|
||||
color: #264158;
|
||||
@@ -2753,14 +2835,86 @@ button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.workspace-modal-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 190px minmax(0, 1fr);
|
||||
height: calc(100% - 55px);
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.workspace-settings-nav {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: 6px;
|
||||
padding: 16px 10px;
|
||||
background: #f4f7f9;
|
||||
border-right: 1px solid #d8e1e8;
|
||||
}
|
||||
|
||||
.workspace-settings-nav button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
min-height: 42px;
|
||||
padding: 0 12px;
|
||||
color: #526b7e;
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 800;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.workspace-settings-nav button:hover {
|
||||
color: #274861;
|
||||
background: #e9f0f4;
|
||||
}
|
||||
|
||||
.workspace-settings-nav button.active {
|
||||
color: #176f95;
|
||||
background: #ffffff;
|
||||
border-color: #c7d9e4;
|
||||
box-shadow: 0 1px 3px rgba(31, 64, 84, 0.08);
|
||||
}
|
||||
|
||||
.workspace-modal-content {
|
||||
display: grid;
|
||||
grid-template-rows: minmax(0, 1fr) auto;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.workspace-modal-body {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: 20px;
|
||||
max-height: calc(100vh - 159px);
|
||||
padding: 18px 18px 22px;
|
||||
min-height: 0;
|
||||
padding: 22px 24px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.workspace-section-heading {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
padding-bottom: 15px;
|
||||
border-bottom: 1px solid #e2e9ee;
|
||||
}
|
||||
|
||||
.workspace-section-heading strong {
|
||||
color: #213d54;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.workspace-section-heading span {
|
||||
color: #718697;
|
||||
font-size: 12px;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.workspace-row,
|
||||
.workspace-toggle,
|
||||
.workspace-select {
|
||||
@@ -2858,7 +3012,9 @@ button {
|
||||
}
|
||||
|
||||
.make-default-button {
|
||||
height: 30px;
|
||||
min-width: 128px;
|
||||
height: 34px;
|
||||
padding: 0 14px;
|
||||
color: #264158;
|
||||
background: #f7fafc;
|
||||
border: 1px solid #d6e0e8;
|
||||
@@ -2868,9 +3024,18 @@ button {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.make-default-button {
|
||||
width: 240px;
|
||||
margin-left: 153px;
|
||||
.workspace-modal-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
min-height: 64px;
|
||||
padding: 12px 24px;
|
||||
color: #718697;
|
||||
background: #fbfcfd;
|
||||
border-top: 1px solid #dfe7ed;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.workspace-modal-header button:hover,
|
||||
@@ -3333,11 +3498,28 @@ button {
|
||||
}
|
||||
|
||||
.workspace-modal-card {
|
||||
width: min(520px, calc(100vw - 24px));
|
||||
min-height: calc(100vh - 112px);
|
||||
width: min(760px, calc(100vw - 24px));
|
||||
height: calc(100vh - 112px);
|
||||
max-height: calc(100vh - 112px);
|
||||
}
|
||||
|
||||
.workspace-modal-layout {
|
||||
grid-template-columns: 165px minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.workspace-settings-nav {
|
||||
padding-inline: 8px;
|
||||
}
|
||||
|
||||
.workspace-settings-nav button {
|
||||
padding-inline: 9px;
|
||||
}
|
||||
|
||||
.workspace-modal-body,
|
||||
.workspace-modal-footer {
|
||||
padding-inline: 18px;
|
||||
}
|
||||
|
||||
.workplane-plane {
|
||||
inset: 0;
|
||||
}
|
||||
|
||||
+100
-3
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { Clock3, FileUp, Grid3X3, HomeIcon, List, Plus, Search, Settings, SlidersHorizontal, Trash2, X } from "lucide-react";
|
||||
import { Clock3, EllipsisVertical, FileUp, Grid3X3, HomeIcon, List, Pencil, Plus, Search, Settings, SlidersHorizontal, Trash2, X } from "lucide-react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { SketchForgeEditor, importedShapeFromStl } from "@/components/SketchForgeEditor";
|
||||
import { createLocalId } from "@/lib/localIds";
|
||||
@@ -574,6 +574,14 @@ export default function Home() {
|
||||
});
|
||||
};
|
||||
|
||||
const renameProject = (projectId: string, name: string) => {
|
||||
const nextName = name.trim().slice(0, 80);
|
||||
if (!nextName) return;
|
||||
setProjects((current) =>
|
||||
current.map((project) => (project.id === projectId ? { ...project, name: nextName, updatedAt: Date.now() } : project)),
|
||||
);
|
||||
};
|
||||
|
||||
if (!mounted) {
|
||||
return null;
|
||||
}
|
||||
@@ -629,6 +637,7 @@ export default function Home() {
|
||||
onOpenProject={openEditor}
|
||||
onOpenSettings={() => setSettingsOpen(true)}
|
||||
onQueryChange={setQuery}
|
||||
onRenameProject={renameProject}
|
||||
onSortModeChange={setSortMode}
|
||||
onViewModeChange={setViewMode}
|
||||
onWorkspace={openLatestProject}
|
||||
@@ -645,6 +654,7 @@ export default function Home() {
|
||||
onProjectSnapshot={updateProjectSnapshot}
|
||||
onProjectWorkspaceChange={updateProjectWorkspace}
|
||||
projectId={activeProjectId}
|
||||
projectName={activeProject?.name}
|
||||
projectRevision={activeProjectShapeEntry?.revision ?? activeProject?.revision ?? 0}
|
||||
/>
|
||||
</div>
|
||||
@@ -672,6 +682,7 @@ function Dashboard({
|
||||
onOpenProject,
|
||||
onOpenSettings,
|
||||
onQueryChange,
|
||||
onRenameProject,
|
||||
onSortModeChange,
|
||||
onViewModeChange,
|
||||
onWorkspace,
|
||||
@@ -694,12 +705,17 @@ function Dashboard({
|
||||
onOpenProject: (projectId: string) => void;
|
||||
onOpenSettings: () => void;
|
||||
onQueryChange: (value: string) => void;
|
||||
onRenameProject: (projectId: string, name: string) => void;
|
||||
onSortModeChange: (value: string) => void;
|
||||
onViewModeChange: (value: ViewMode) => void;
|
||||
onWorkspace: () => void;
|
||||
}) {
|
||||
const [openProjectMenuId, setOpenProjectMenuId] = useState<string | null>(null);
|
||||
const [projectPendingDeleteId, setProjectPendingDeleteId] = useState<string | null>(null);
|
||||
const [projectPendingRenameId, setProjectPendingRenameId] = useState<string | null>(null);
|
||||
const [projectNameDraft, setProjectNameDraft] = useState("");
|
||||
const projectPendingDelete = projects.find((project) => project.id === projectPendingDeleteId) ?? null;
|
||||
const projectPendingRename = projects.find((project) => project.id === projectPendingRenameId) ?? null;
|
||||
|
||||
useEffect(() => {
|
||||
if (!projectPendingDeleteId) return;
|
||||
@@ -713,6 +729,23 @@ function Dashboard({
|
||||
setProjectPendingDeleteId(null);
|
||||
};
|
||||
|
||||
const startProjectRename = (project: DashboardProject) => {
|
||||
setOpenProjectMenuId(null);
|
||||
setProjectPendingRenameId(project.id);
|
||||
setProjectNameDraft(project.name);
|
||||
};
|
||||
|
||||
const closeProjectRename = () => {
|
||||
setProjectPendingRenameId(null);
|
||||
setProjectNameDraft("");
|
||||
};
|
||||
|
||||
const confirmProjectRename = () => {
|
||||
if (!projectPendingRename || !projectNameDraft.trim()) return;
|
||||
onRenameProject(projectPendingRename.id, projectNameDraft);
|
||||
closeProjectRename();
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="dashboard-shell">
|
||||
<header className="dashboard-topbar">
|
||||
@@ -806,9 +839,36 @@ function Dashboard({
|
||||
{formatUpdated(project.updatedAt)} - {project.shapes} shapes
|
||||
</span>
|
||||
</button>
|
||||
<button className="project-delete" type="button" aria-label={`Delete ${project.name}`} title="Delete project" onClick={() => setProjectPendingDeleteId(project.id)}>
|
||||
<Trash2 size={17} strokeWidth={2.4} />
|
||||
<button
|
||||
className="project-menu-trigger"
|
||||
type="button"
|
||||
aria-label={`Project options for ${project.name}`}
|
||||
aria-expanded={openProjectMenuId === project.id}
|
||||
title="Project options"
|
||||
onClick={() => setOpenProjectMenuId((current) => (current === project.id ? null : project.id))}
|
||||
>
|
||||
<EllipsisVertical size={19} strokeWidth={2.5} />
|
||||
</button>
|
||||
{openProjectMenuId === project.id ? (
|
||||
<div className="project-card-menu" role="menu" aria-label={`Options for ${project.name}`}>
|
||||
<button type="button" role="menuitem" onClick={() => startProjectRename(project)}>
|
||||
<Pencil size={16} />
|
||||
<span>Rename</span>
|
||||
</button>
|
||||
<button
|
||||
className="delete"
|
||||
type="button"
|
||||
role="menuitem"
|
||||
onClick={() => {
|
||||
setOpenProjectMenuId(null);
|
||||
setProjectPendingDeleteId(project.id);
|
||||
}}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
<span>Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
@@ -845,6 +905,43 @@ function Dashboard({
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{projectPendingRename ? (
|
||||
<section className="dashboard-confirm-overlay" role="dialog" aria-modal="true" aria-labelledby="rename-project-title">
|
||||
<form
|
||||
className="dashboard-confirm-dialog dashboard-rename-dialog"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
confirmProjectRename();
|
||||
}}
|
||||
>
|
||||
<header>
|
||||
<strong id="rename-project-title">Rename project</strong>
|
||||
<button type="button" aria-label="Cancel project rename" onClick={closeProjectRename}>
|
||||
<X size={18} />
|
||||
</button>
|
||||
</header>
|
||||
<label>
|
||||
<span>Project name</span>
|
||||
<input
|
||||
autoFocus
|
||||
maxLength={80}
|
||||
value={projectNameDraft}
|
||||
onChange={(event) => setProjectNameDraft(event.currentTarget.value)}
|
||||
aria-label="Project name"
|
||||
/>
|
||||
</label>
|
||||
<div className="dashboard-confirm-actions">
|
||||
<button className="dashboard-confirm-cancel" type="button" onClick={closeProjectRename}>
|
||||
Cancel
|
||||
</button>
|
||||
<button className="dashboard-confirm-save" type="submit" disabled={!projectNameDraft.trim()}>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{settingsOpen ? (
|
||||
<section className="dashboard-settings-panel" role="dialog" aria-modal="true" aria-label="Download settings">
|
||||
<header>
|
||||
|
||||
@@ -56,6 +56,7 @@ import {
|
||||
workplaneShapesEqual,
|
||||
} from "@/lib/workplaneShapes";
|
||||
import { createLocalId } from "@/lib/localIds";
|
||||
import { projectExportFileName } from "@/lib/exportNames";
|
||||
import { makeShapeFromAsset, sceneShape, toolbarShapeAssets, type ToolbarShapeAsset } from "@/lib/shapeCatalog";
|
||||
import { importedShapeFromStl, importExtensionSupported } from "@/lib/stlImport";
|
||||
import type { AlignAxis, AlignHandleStatus, AlignTarget, GridSize, ShapeAsset, WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
|
||||
@@ -4006,6 +4007,7 @@ export function SketchForgeEditor({
|
||||
onProjectSnapshot,
|
||||
onProjectWorkspaceChange,
|
||||
projectId,
|
||||
projectName = "SketchForge design",
|
||||
projectRevision = 0,
|
||||
}: {
|
||||
initialShapes?: WorkplaneShape[];
|
||||
@@ -4016,6 +4018,7 @@ export function SketchForgeEditor({
|
||||
onProjectSnapshot?: (snapshot: { image: string; projectId: string; shapes: number }) => void;
|
||||
onProjectWorkspaceChange?: (snapshot: { projectId: string; workspace: WorkplaneWorkspaceSettings; snap: GridSize }) => void;
|
||||
projectId?: string | null;
|
||||
projectName?: string;
|
||||
projectRevision?: number;
|
||||
} = {}) {
|
||||
const [shapes, setShapes] = useState<WorkplaneShape[]>(() => initialShapes.map(canonicalizeShape));
|
||||
@@ -4983,7 +4986,6 @@ export function SketchForgeEditor({
|
||||
return;
|
||||
}
|
||||
const meshes = exportable.map(meshForShape);
|
||||
const scope = hasSelection ? "selection" : "design";
|
||||
const selectedNotice = `Exported ${exportable.length} selected shape${exportable.length === 1 ? "" : "s"}`;
|
||||
const finishNotice = (label: string, result: DownloadResult) => {
|
||||
if (result.mode === "folder") {
|
||||
@@ -4996,15 +4998,15 @@ export function SketchForgeEditor({
|
||||
setNotice(error instanceof Error ? error.message : `Could not export ${label}`);
|
||||
};
|
||||
if (format === "stl") {
|
||||
void downloadTextFile(`sketchforge-${scope}.stl`, toStl(meshes), "model/stl")
|
||||
void downloadTextFile(projectExportFileName(projectName, "stl"), toStl(meshes), "model/stl")
|
||||
.then((result) => finishNotice("STL", result))
|
||||
.catch((error: unknown) => failNotice("STL", error));
|
||||
return;
|
||||
}
|
||||
void downloadTextFile(`sketchforge-${scope}.obj`, toObj(meshes), "text/plain")
|
||||
void downloadTextFile(projectExportFileName(projectName, "obj"), toObj(meshes), "text/plain")
|
||||
.then((result) => finishNotice("OBJ", result))
|
||||
.catch((error: unknown) => failNotice("OBJ", error));
|
||||
}, [hasSelection, selectedShapes, shapes]);
|
||||
}, [hasSelection, projectName, selectedShapes, shapes]);
|
||||
|
||||
const clearDesign = useCallback(() => {
|
||||
commitShapes([], [], "New empty design");
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import { X } from "lucide-react";
|
||||
import { Grid3X3, Palette, Ruler, X } from "lucide-react";
|
||||
import { useState, type CSSProperties } from "react";
|
||||
import { DEFAULT_WORKPLANE_WORKSPACE } from "@/lib/workplaneSettings";
|
||||
import type { GridSize, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
|
||||
|
||||
type WorkspaceSettings = WorkplaneWorkspaceSettings;
|
||||
type WorkspaceSettingsSection = "appearance" | "measurement" | "workplane";
|
||||
|
||||
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;
|
||||
@@ -49,6 +50,7 @@ export function WorkspaceSettingsModal({
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const [defaultSaved, setDefaultSaved] = useState(false);
|
||||
const [activeSection, setActiveSection] = useState<WorkspaceSettingsSection>("appearance");
|
||||
const patchWorkspace = (patch: Partial<WorkspaceSettings>) => {
|
||||
setDefaultSaved(false);
|
||||
onWorkspaceChange({ ...workspace, ...patch });
|
||||
@@ -83,123 +85,168 @@ export function WorkspaceSettingsModal({
|
||||
</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 })}
|
||||
/>
|
||||
<div className="workspace-modal-layout">
|
||||
<nav className="workspace-settings-nav" aria-label="Workspace settings sections">
|
||||
<button className={activeSection === "appearance" ? "active" : ""} aria-current={activeSection === "appearance" ? "page" : undefined} onClick={() => setActiveSection("appearance")}>
|
||||
<Palette size={18} />
|
||||
<span>Appearance</span>
|
||||
</button>
|
||||
<button className={activeSection === "measurement" ? "active" : ""} aria-current={activeSection === "measurement" ? "page" : undefined} onClick={() => setActiveSection("measurement")}>
|
||||
<Ruler size={18} />
|
||||
<span>Measurement</span>
|
||||
</button>
|
||||
<button className={activeSection === "workplane" ? "active" : ""} aria-current={activeSection === "workplane" ? "page" : undefined} onClick={() => setActiveSection("workplane")}>
|
||||
<Grid3X3 size={18} />
|
||||
<span>Workplane</span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<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>
|
||||
<div className="workspace-modal-content">
|
||||
<div className="workspace-modal-body">
|
||||
{activeSection === "appearance" ? (
|
||||
<>
|
||||
<div className="workspace-section-heading">
|
||||
<strong>Appearance</strong>
|
||||
<span>Adjust the canvas and navigation behavior.</span>
|
||||
</div>
|
||||
<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>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
<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="Accuracy"
|
||||
value={`0.${"0".repeat(workspace.accuracy)}`}
|
||||
options={["0.0", "0.00", "0.000"]}
|
||||
onChange={(accuracy) => patchWorkspace({ accuracy: accuracy.slice(2).length as WorkspaceSettings["accuracy"] })}
|
||||
/>
|
||||
<WorkspaceSelect
|
||||
label="Snap Grid"
|
||||
value={snap}
|
||||
options={GRID_SIZES}
|
||||
onChange={(next) => {
|
||||
setDefaultSaved(false);
|
||||
onSnapChange(next as GridSize);
|
||||
}}
|
||||
/>
|
||||
<WorkspaceSelect
|
||||
label="Workplane size"
|
||||
value={workspace.sizePreset}
|
||||
options={WORKSPACE_SIZE_PRESETS.map((preset) => preset.label)}
|
||||
onChange={setWorkspaceSizePreset}
|
||||
/>
|
||||
{activeSection === "measurement" ? (
|
||||
<>
|
||||
<div className="workspace-section-heading">
|
||||
<strong>Measurement</strong>
|
||||
<span>Choose units, precision, scale, and snapping.</span>
|
||||
</div>
|
||||
<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="Accuracy"
|
||||
value={`0.${"0".repeat(workspace.accuracy)}`}
|
||||
options={["0.0", "0.00", "0.000"]}
|
||||
onChange={(accuracy) => patchWorkspace({ accuracy: accuracy.slice(2).length as WorkspaceSettings["accuracy"] })}
|
||||
/>
|
||||
<WorkspaceSelect
|
||||
label="Snap Grid"
|
||||
value={snap}
|
||||
options={GRID_SIZES}
|
||||
onChange={(next) => {
|
||||
setDefaultSaved(false);
|
||||
onSnapChange(next as GridSize);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
<div className="workspace-dimensions">
|
||||
<label>
|
||||
<span>Width</span>
|
||||
<input
|
||||
type="number"
|
||||
value={workspace.width.toFixed(workspace.accuracy)}
|
||||
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(workspace.accuracy)}
|
||||
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(workspace.accuracy)}
|
||||
min={MIN_GRID_BLOCK_SIZE}
|
||||
max={MAX_GRID_BLOCK_SIZE}
|
||||
step={0.5}
|
||||
onChange={(event) => setGridBlockSize(event.currentTarget.value)}
|
||||
/>
|
||||
</label>
|
||||
{activeSection === "workplane" ? (
|
||||
<>
|
||||
<div className="workspace-section-heading">
|
||||
<strong>Workplane</strong>
|
||||
<span>Set the plate dimensions and visible grid spacing.</span>
|
||||
</div>
|
||||
<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(workspace.accuracy)}
|
||||
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(workspace.accuracy)}
|
||||
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(workspace.accuracy)}
|
||||
min={MIN_GRID_BLOCK_SIZE}
|
||||
max={MAX_GRID_BLOCK_SIZE}
|
||||
step={0.5}
|
||||
onChange={(event) => setGridBlockSize(event.currentTarget.value)}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<button
|
||||
className="make-default-button"
|
||||
onClick={() => {
|
||||
onMakeDefault();
|
||||
setDefaultSaved(true);
|
||||
}}
|
||||
>
|
||||
{defaultSaved ? "Default saved" : "Make default"}
|
||||
</button>
|
||||
<div className="workspace-modal-footer">
|
||||
<span>Save the current settings for this project.</span>
|
||||
<button
|
||||
className="make-default-button"
|
||||
onClick={() => {
|
||||
onMakeDefault();
|
||||
setDefaultSaved(true);
|
||||
}}
|
||||
>
|
||||
{defaultSaved ? "Default saved" : "Make default"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button className="workspace-modal-backdrop" aria-label="Close settings" onClick={onClose} />
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
export type ProjectExportFormat = "stl" | "obj";
|
||||
|
||||
export function projectExportFileName(projectName: string, format: ProjectExportFormat) {
|
||||
const safeProjectName = projectName
|
||||
.trim()
|
||||
.replace(/[<>:"/\\|?*\u0000-\u001f]/g, "-")
|
||||
.replace(/\s+/g, " ")
|
||||
.replace(/[. ]+$/g, "")
|
||||
.slice(0, 120);
|
||||
return `${safeProjectName || "SketchForge design"}.${format}`;
|
||||
}
|
||||
Reference in New Issue
Block a user