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
feat: SnapCAD Studio'yu YakHub deposuna taşı
- DWG/DXF içe aktarma ve .skf yeniden açma düzeltmeleri - YakNet Bulut eşitlemede boş/eski kopya koruması ve yerel-only proje bildirimi - Panelden içe aktarma duyuruları ve erişilebilir Türkçe hata mesajları - AGPL-3.0 lisansı, README ve YakHub bağlantıları
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -182,3 +182,126 @@ export function ToolbarWorkplaneIcon() {
|
||||
export function ToolbarDropToWorkplaneIcon() {
|
||||
return <ToolbarCommandImage file="toolbar-drop-workplane.png" className="toolbar-user-art-icon" />;
|
||||
}
|
||||
|
||||
export function ToolbarPushPullIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z" />
|
||||
<polyline points="3.27 6.96 12 12.01 20.73 6.96" />
|
||||
<line x1="12" y1="22.08" x2="12" y2="12" />
|
||||
<path d="M12 3v6" stroke="#38bdf8" strokeWidth="2.5" />
|
||||
<path d="M9.5 5.5L12 3l2.5 2.5" stroke="#38bdf8" strokeWidth="2.5" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarFollowMeIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<path d="M4 19c4-6 8-8 16-8" stroke="#10b981" strokeWidth="2.5" />
|
||||
<polygon points="12,15 15,11 12,7" fill="#10b981" stroke="none" />
|
||||
<circle cx="4" cy="19" r="2.5" fill="currentColor" />
|
||||
<rect x="16" y="8" width="5" height="5" rx="1" fill="#38bdf8" stroke="currentColor" strokeWidth="1" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarLineToolIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<line x1="4" y1="20" x2="20" y2="4" stroke="#0284c7" strokeWidth="2.5" />
|
||||
<circle cx="4" cy="20" r="2.5" fill="#0284c7" />
|
||||
<circle cx="20" cy="4" r="2.5" fill="#0284c7" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarSolarStudyIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<circle cx="12" cy="12" r="4" stroke="#eab308" fill="#eab308" />
|
||||
<path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41" stroke="#eab308" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarGuidesIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<line x1="3" y1="6" x2="21" y2="6" stroke="#38bdf8" strokeDasharray="3 3" />
|
||||
<line x1="3" y1="18" x2="21" y2="18" stroke="#38bdf8" strokeDasharray="3 3" />
|
||||
<line x1="7" y1="2" x2="7" y2="22" stroke="#38bdf8" strokeDasharray="3 3" />
|
||||
<line x1="17" y1="2" x2="17" y2="22" stroke="#38bdf8" strokeDasharray="3 3" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarOffsetIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<rect x="3" y="3" width="18" height="18" rx="2" stroke="#94a3b8" />
|
||||
<rect x="7" y="7" width="10" height="10" rx="1" stroke="#0ea5e9" strokeWidth="2" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarXRayIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z" stroke="#38bdf8" />
|
||||
<circle cx="12" cy="12" r="3" stroke="#38bdf8" strokeDasharray="2 2" fill="rgba(56, 189, 248, 0.2)" />
|
||||
<line x1="12" y1="5" x2="12" y2="19" stroke="#38bdf8" strokeDasharray="2 2" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarLayersIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<polygon points="12 2 2 7 12 12 22 7 12 2" stroke="#a855f7" />
|
||||
<polyline points="2 17 12 22 22 17" stroke="#a855f7" />
|
||||
<polyline points="2 12 12 17 22 12" stroke="#a855f7" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarTerrainIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<path d="M8 3l4 8 5-5 5 15H2L8 3z" stroke="#10b981" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarProtractorIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<path d="M2 19a10 10 0 0 1 20 0H2z" stroke="#f59e0b" />
|
||||
<line x1="12" y1="19" x2="12" y2="13" stroke="#f59e0b" />
|
||||
<line x1="12" y1="19" x2="19" y2="12" stroke="#f59e0b" strokeDasharray="2 2" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarPaintBucketIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<path d="M19 11L12 4 4 12l7 7 8-8z" stroke="#ec4899" />
|
||||
<path d="M5 2c4 4 6 7 6 7" stroke="#ec4899" />
|
||||
<path d="M22 19a2 2 0 1 1-4 0c0-1.6 2-3 2-3s2 1.4 2 3z" fill="#ec4899" stroke="#ec4899" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolbarWallOpeningIcon(props: IconProps) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" {...props}>
|
||||
<rect x="2" y="4" width="20" height="16" rx="2" stroke="#38bdf8" />
|
||||
<rect x="8" y="8" width="8" height="8" rx="1" stroke="#f59e0b" fill="rgba(245, 158, 11, 0.2)" />
|
||||
<line x1="12" y1="8" x2="12" y2="16" stroke="#f59e0b" />
|
||||
<line x1="8" y1="12" x2="16" y2="12" stroke="#f59e0b" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { AlignCenter, Box, CircleDotDashed, Group, LockKeyhole, MoveUp, Type } from "lucide-react";
|
||||
import { AlignCenter, Box, CircleDotDashed, GraduationCap, Group, LockKeyhole, MoveUp, PaintBucket, Play, Smartphone, Type, Activity } from "lucide-react";
|
||||
import type { ChallengeTutorialId } from "@/lib/challenges";
|
||||
|
||||
function KeyTagPreview() {
|
||||
@@ -37,7 +37,13 @@ function NameplatePreview() {
|
||||
);
|
||||
}
|
||||
|
||||
export default function ChallengesDashboard({ onStartChallenge }: { onStartChallenge: (challenge: ChallengeTutorialId) => void }) {
|
||||
export default function ChallengesDashboard({
|
||||
onStartChallenge,
|
||||
onStartAcademy,
|
||||
}: {
|
||||
onStartChallenge: (challenge: ChallengeTutorialId) => void;
|
||||
onStartAcademy?: () => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="challenge-key-tag-page">
|
||||
<div className="challenge-key-tag-rail" aria-hidden="true">
|
||||
@@ -54,21 +60,21 @@ export default function ChallengesDashboard({ onStartChallenge }: { onStartChall
|
||||
<div className="challenge-key-tag-content">
|
||||
<div className="challenge-key-tag-title-row">
|
||||
<span>01</span>
|
||||
<h2>Key Tag</h2>
|
||||
<h2>Anahtarlık Tasarımı (Key Tag)</h2>
|
||||
</div>
|
||||
|
||||
<p>Build your first Key Tag from simple shapes.</p>
|
||||
<p>Temel şekilleri, delik (Hole) açmayı ve gruplamayı kullanarak ilk 3B anahtarlığınızı oluşturun.</p>
|
||||
|
||||
<div className="challenge-key-tag-skills" aria-label="Skills used in this challenge">
|
||||
<span><Box size={16} aria-hidden="true" /> Basic shapes</span>
|
||||
<span><AlignCenter size={16} aria-hidden="true" /> Align</span>
|
||||
<span><CircleDotDashed size={16} aria-hidden="true" /> Hole</span>
|
||||
<span><LockKeyhole size={16} aria-hidden="true" /> Lock</span>
|
||||
<span><Group size={16} aria-hidden="true" /> Group</span>
|
||||
<div className="challenge-key-tag-skills" aria-label="Bu görevde kullanılan beceriler">
|
||||
<span><Box size={16} aria-hidden="true" /> Temel şekiller</span>
|
||||
<span><AlignCenter size={16} aria-hidden="true" /> Hizalama (Align)</span>
|
||||
<span><CircleDotDashed size={16} aria-hidden="true" /> Delik (Hole)</span>
|
||||
<span><LockKeyhole size={16} aria-hidden="true" /> Kilitleme</span>
|
||||
<span><Group size={16} aria-hidden="true" /> Gruplama (Group)</span>
|
||||
</div>
|
||||
|
||||
<button type="button" className="challenge-key-tag-start" onClick={() => onStartChallenge("key-tag")}>
|
||||
Start Challenge
|
||||
Göreve Başla
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
@@ -81,22 +87,94 @@ export default function ChallengesDashboard({ onStartChallenge }: { onStartChall
|
||||
<div className="challenge-key-tag-content">
|
||||
<div className="challenge-key-tag-title-row">
|
||||
<span>02</span>
|
||||
<h2>Personalized Nameplate</h2>
|
||||
<h2>Kişiselleştirilmiş İsimlik (Nameplate)</h2>
|
||||
</div>
|
||||
|
||||
<p>Create a printable nameplate with rounded edges and raised custom text.</p>
|
||||
<p>Kenarları yuvarlatılmış (Fillet) ve kabartma yazılı 3B baskıya hazır bir masa isimliği tasarlayın.</p>
|
||||
|
||||
<div className="challenge-key-tag-skills" aria-label="Skills used in this challenge">
|
||||
<span><Box size={16} aria-hidden="true" /> Box</span>
|
||||
<span><CircleDotDashed size={16} aria-hidden="true" /> Fillet</span>
|
||||
<span><Type size={16} aria-hidden="true" /> Text</span>
|
||||
<span><MoveUp size={16} aria-hidden="true" /> Elevation</span>
|
||||
<span><AlignCenter size={16} aria-hidden="true" /> Align</span>
|
||||
<span><Group size={16} aria-hidden="true" /> Group</span>
|
||||
<div className="challenge-key-tag-skills" aria-label="Bu görevde kullanılan beceriler">
|
||||
<span><Box size={16} aria-hidden="true" /> Kutu</span>
|
||||
<span><CircleDotDashed size={16} aria-hidden="true" /> Yuvarlama (Fillet)</span>
|
||||
<span><Type size={16} aria-hidden="true" /> 3B Metin</span>
|
||||
<span><MoveUp size={16} aria-hidden="true" /> Yükseklik (Elevation)</span>
|
||||
<span><AlignCenter size={16} aria-hidden="true" /> Hizalama</span>
|
||||
<span><Group size={16} aria-hidden="true" /> Gruplama</span>
|
||||
</div>
|
||||
|
||||
<button type="button" className="challenge-key-tag-start" onClick={() => onStartChallenge("nameplate")}>
|
||||
Start Challenge
|
||||
Göreve Başla
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article className="challenge-key-tag-card" style={{ borderColor: "rgba(99, 102, 241, 0.4)" }}>
|
||||
<div
|
||||
className="challenge-key-tag-preview"
|
||||
style={{
|
||||
background: "linear-gradient(135deg, #0f172a, #1e1b4b)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
flexDirection: "column",
|
||||
gap: "12px",
|
||||
padding: "24px",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: "80px",
|
||||
height: "80px",
|
||||
borderRadius: "24px",
|
||||
background: "linear-gradient(135deg, #6366f1, #8b5cf6)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
color: "#ffffff",
|
||||
boxShadow: "0 10px 25px rgba(99, 102, 241, 0.4)",
|
||||
}}
|
||||
>
|
||||
<GraduationCap size={44} />
|
||||
</div>
|
||||
<span style={{ fontSize: "12px", fontWeight: "bold", color: "#a5b4fc", letterSpacing: "1px", textTransform: "uppercase" }}>
|
||||
10 Adımlı Canlı Atölye
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="challenge-key-tag-content">
|
||||
<div className="challenge-key-tag-title-row">
|
||||
<span style={{ color: "#818cf8" }}>03</span>
|
||||
<h2>SnapCAD Akademi — Uygulamalı Mimari & 3B Modelleme</h2>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Navigasyondan İt/Çek (Push/Pull) ve çatı yerleştirmeye, Boya Kovasından gerçekçi dokulara, Akıllı Bileşenlerden deprem ve fizik testlerine kadar 10 adımlı interaktif canlı eğitim.
|
||||
</p>
|
||||
|
||||
<div className="challenge-key-tag-skills" aria-label="Bu eğitimde öğrenilen beceriler">
|
||||
<span><Play size={16} aria-hidden="true" /> Push/Pull ('P')</span>
|
||||
<span><PaintBucket size={16} aria-hidden="true" /> Boya Kovası ('B')</span>
|
||||
<span><Box size={16} aria-hidden="true" /> Akıllı Çatı Yerleştirme</span>
|
||||
<span><Activity size={16} aria-hidden="true" /> Statik Deprem Testi</span>
|
||||
<span><Smartphone size={16} aria-hidden="true" /> Masamda Gör (Mobil AR)</span>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="challenge-key-tag-start"
|
||||
style={{
|
||||
background: "linear-gradient(135deg, #6366f1, #8b5cf6)",
|
||||
borderColor: "#a5b4fc",
|
||||
boxShadow: "0 4px 14px rgba(99, 102, 241, 0.35)",
|
||||
}}
|
||||
onClick={() => {
|
||||
if (onStartAcademy) {
|
||||
onStartAcademy();
|
||||
} else {
|
||||
window.dispatchEvent(new CustomEvent("snapcad:open-tutorial"));
|
||||
}
|
||||
}}
|
||||
>
|
||||
Eğitime Başla (10 Adım)
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
import React, { useEffect, useState, useId } from "react";
|
||||
import QRCode from "qrcode";
|
||||
import { Smartphone, QrCode, Download, X, HelpCircle, CheckCircle, ExternalLink, Sparkles } from "lucide-react";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
export interface ARPreviewModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
shapes: WorkplaneShape[];
|
||||
projectName?: string;
|
||||
onExportGlb?: () => void;
|
||||
}
|
||||
|
||||
export const ARPreviewModal: React.FC<ARPreviewModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
shapes,
|
||||
projectName = "3D Tasarımım",
|
||||
onExportGlb,
|
||||
}) => {
|
||||
const baseId = useId();
|
||||
const [qrDataUrl, setQrDataUrl] = useState<string>("");
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [mobileTab, setMobileTab] = useState<"qr" | "guide">("qr");
|
||||
|
||||
const solidShapesCount = shapes.filter((s) => !s.hole).length;
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen) return;
|
||||
|
||||
// Mobil AR için hedef URL oluştur (mevcut sayfa + AR parametresi)
|
||||
const currentUrl = typeof window !== "undefined" ? window.location.href : "https://snap.yakhub.com.tr";
|
||||
const arTargetUrl = currentUrl.includes("?")
|
||||
? `${currentUrl}&mode=ar_viewer`
|
||||
: `${currentUrl}?mode=ar_viewer`;
|
||||
|
||||
QRCode.toDataURL(arTargetUrl, {
|
||||
width: 280,
|
||||
margin: 1.5,
|
||||
color: {
|
||||
dark: "#0284c7", // Sky 600
|
||||
light: "#ffffff",
|
||||
},
|
||||
})
|
||||
.then((url) => setQrDataUrl(url))
|
||||
.catch((err) => console.error("QR Code generation error:", err));
|
||||
}, [isOpen]);
|
||||
|
||||
// ESC tuşu ile kapatma
|
||||
useEffect(() => {
|
||||
if (!isOpen) return;
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") onClose();
|
||||
};
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [isOpen, onClose]);
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
const handleCopyLink = () => {
|
||||
if (typeof navigator !== "undefined" && navigator.clipboard) {
|
||||
void navigator.clipboard.writeText(window.location.href);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 3000);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-0 z-50 bg-black/65 backdrop-blur-sm flex items-center justify-center p-4"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby={`${baseId}-ar-title`}
|
||||
aria-describedby={`${baseId}-ar-desc`}
|
||||
>
|
||||
<div className="bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-3xl max-w-lg w-full p-6 space-y-5 shadow-2xl relative text-slate-900 dark:text-white">
|
||||
{/* Kapat Butonu */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="absolute top-5 right-5 p-1.5 rounded-xl text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 hover:bg-slate-100 dark:hover:bg-slate-800 transition"
|
||||
aria-label="Pencereyi kapat"
|
||||
title="Kapat"
|
||||
>
|
||||
<X size={20} aria-hidden="true" />
|
||||
</button>
|
||||
|
||||
{/* Başlık Alanı */}
|
||||
<div className="space-y-1">
|
||||
<div className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wider bg-sky-50 dark:bg-sky-950/60 text-sky-600 dark:text-sky-400 border border-sky-200 dark:border-sky-800">
|
||||
<Smartphone size={13} aria-hidden="true" /> Artırılmış Gerçeklik (AR)
|
||||
</div>
|
||||
<h2 id={`${baseId}-ar-title`} className="text-2xl font-black tracking-tight flex items-center gap-2">
|
||||
Masa Üstünde Gör
|
||||
</h2>
|
||||
<p id={`${baseId}-ar-desc`} className="text-xs text-slate-500 dark:text-slate-400">
|
||||
<strong>"{projectName}"</strong> tasarımınızı telefonunuzun kamerasıyla sınıf sırasının veya çalışma masanızın üzerinde gerçek boyutuyla 3D inceleyin.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Sekmeler */}
|
||||
<div className="flex items-center gap-2 border-b border-slate-200 dark:border-slate-800 pb-2 text-xs font-semibold">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setMobileTab("qr")}
|
||||
className={`px-3 py-1.5 rounded-xl transition flex items-center gap-1.5 ${
|
||||
mobileTab === "qr"
|
||||
? "bg-sky-600 text-white shadow-sm"
|
||||
: "text-slate-600 dark:text-slate-400 hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
}`}
|
||||
>
|
||||
<QrCode size={14} aria-hidden="true" />
|
||||
<span>Kamera ile Tara</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setMobileTab("guide")}
|
||||
className={`px-3 py-1.5 rounded-xl transition flex items-center gap-1.5 ${
|
||||
mobileTab === "guide"
|
||||
? "bg-sky-600 text-white shadow-sm"
|
||||
: "text-slate-600 dark:text-slate-400 hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
}`}
|
||||
>
|
||||
<HelpCircle size={14} aria-hidden="true" />
|
||||
<span>Nasıl Çalışır?</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Tab 1: QR Kod Görünümü */}
|
||||
{mobileTab === "qr" && (
|
||||
<div className="space-y-4 text-center">
|
||||
<div className="p-4 bg-white rounded-2xl shadow-inner border border-slate-200 inline-block mx-auto">
|
||||
{qrDataUrl ? (
|
||||
<img
|
||||
src={qrDataUrl}
|
||||
alt="Mobil AR için QR Kodu"
|
||||
className="w-56 h-56 mx-auto rounded-lg"
|
||||
/>
|
||||
) : (
|
||||
<div className="w-56 h-56 flex items-center justify-center text-xs text-slate-400">
|
||||
QR Kod Üretiliyor...
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="text-xs text-slate-600 dark:text-slate-300 space-y-1">
|
||||
<p className="font-semibold text-slate-900 dark:text-white">
|
||||
Telefonunuzun kamerasını açarak QR kodu tarayın
|
||||
</p>
|
||||
<p className="text-slate-400">
|
||||
Harici hiçbir uygulama yüklemenize gerek yoktur. Safari (iOS) veya Chrome (Android) doğrudan AR modunda açacaktır.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Tab 2: Nasıl Çalışır Kılavuzu */}
|
||||
{mobileTab === "guide" && (
|
||||
<div className="space-y-3 text-xs text-slate-700 dark:text-slate-300">
|
||||
<div className="p-3.5 rounded-2xl bg-slate-50 dark:bg-slate-800/60 border border-slate-200 dark:border-slate-700 space-y-1">
|
||||
<div className="font-bold text-sky-600 dark:text-sky-400 flex items-center gap-1.5">
|
||||
<Sparkles size={14} aria-hidden="true" /> 1. iPhone & iPad (Apple AR Quick Look)
|
||||
</div>
|
||||
<p>
|
||||
Kameranızı QR koda tuttuğunuzda çıkan bağlantıya dokunun. Model doğrudan Safari içinde açılır ve "AR" sekmesine bastığınızda masanızın üzerine yerleşir. Parmaklarınızla döndürebilir ve büyütebilirsiniz.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="p-3.5 rounded-2xl bg-slate-50 dark:bg-slate-800/60 border border-slate-200 dark:border-slate-700 space-y-1">
|
||||
<div className="font-bold text-emerald-600 dark:text-emerald-400 flex items-center gap-1.5">
|
||||
<Sparkles size={14} aria-hidden="true" /> 2. Android (Google Play Hizmetleri AR)
|
||||
</div>
|
||||
<p>
|
||||
Google Lens veya kamera ile tarayın. Google Scene Viewer otomatik olarak açılarak "Alanımdaki Görünüm" butonunu sunar. Masanızı tarayarak katı modelinizi 1:1 ölçekte görebilirsiniz.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="p-3 rounded-xl bg-blue-50 dark:bg-blue-950/40 border border-blue-200 dark:border-blue-900 text-blue-800 dark:text-blue-300">
|
||||
Mevcut tasarımınız <strong>{solidShapesCount}</strong> parçadan oluşmaktadır.
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Alt Aksiyon Butonları */}
|
||||
<div className="pt-2 flex items-center justify-between border-t border-slate-100 dark:border-slate-800 gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleCopyLink}
|
||||
className="px-3.5 py-2 rounded-xl text-xs font-semibold text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800 transition flex items-center gap-1.5"
|
||||
aria-label="Tasarım bağlantısını kopyala"
|
||||
>
|
||||
{copied ? <CheckCircle size={14} className="text-emerald-500" /> : <ExternalLink size={14} />}
|
||||
<span>{copied ? "Bağlantı Kopyalandı!" : "Linki Kopyala"}</span>
|
||||
</button>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{onExportGlb && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onExportGlb}
|
||||
className="px-4 py-2 rounded-xl text-xs font-semibold bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 transition flex items-center gap-1.5"
|
||||
aria-label="GLB dosyasını doğrudan indir"
|
||||
>
|
||||
<Download size={14} aria-hidden="true" />
|
||||
<span>GLB İndir</span>
|
||||
</button>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="px-5 py-2 rounded-xl text-xs font-bold bg-sky-600 hover:bg-sky-700 text-white transition shadow-sm"
|
||||
aria-label="Pencereyi kapat"
|
||||
>
|
||||
Tamam
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,251 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Compass,
|
||||
Eye,
|
||||
EyeOff,
|
||||
HeartHandshake,
|
||||
Layers,
|
||||
Lightbulb,
|
||||
Maximize2,
|
||||
MoveRight,
|
||||
Ruler,
|
||||
ShieldCheck,
|
||||
Sparkles,
|
||||
Trophy,
|
||||
Users,
|
||||
Volume2,
|
||||
Workflow,
|
||||
Zap,
|
||||
} from "lucide-react";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
interface AboutPageContentProps {
|
||||
onStartDesign?: () => void;
|
||||
onGoToContact?: () => void;
|
||||
}
|
||||
|
||||
export function AboutPageContent({ onStartDesign, onGoToContact }: AboutPageContentProps) {
|
||||
const headingRef = useRef<HTMLHeadingElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Sayfa açıldığında ekran okuyucunun doğrudan ana başlığa atlamasını sağla
|
||||
headingRef.current?.focus();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<article className="snapcad-content-page about-page" aria-labelledby="about-main-heading">
|
||||
{/* 1. Kahraman Başlık Bölümü (Hero Section) */}
|
||||
<header className="content-hero about-hero">
|
||||
<div className="hero-badge">
|
||||
<Sparkles size={15} aria-hidden="true" />
|
||||
<span>Evrensel Tasarım & Yeni Nesil 3B CAD Devrimi</span>
|
||||
</div>
|
||||
<h1
|
||||
id="about-main-heading"
|
||||
ref={headingRef}
|
||||
tabIndex={-1}
|
||||
className="hero-title outline-none focus:ring-2 focus:ring-sky-500 rounded-md"
|
||||
>
|
||||
Siz hiç görme engelli bir mimar gördünüz mü?
|
||||
</h1>
|
||||
<p className="hero-lead">
|
||||
Çoğu insan mimarlık ve üç boyutlu tasarımı sadece gözlerle yapılan görsel bir meslek sanır.
|
||||
Oysa mimarlık; boşluğu hissetmek, sesin yankısını dinlemek, dokuları kavramak,
|
||||
zihinde matematiksel oranlar kurmak ve insan ölçeğinde yaşanabilir mekânlar inşa etmektir.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
{/* 2. Gerçek Mimarların Hikayeleri (Story Section) */}
|
||||
<section className="about-section architects-spotlight" aria-labelledby="architects-heading">
|
||||
<div className="section-header-pill">
|
||||
<Users size={16} aria-hidden="true" />
|
||||
<h2 id="architects-heading">Işığın Ötesindeki Mimarlar: Gerçek Yaşam Öyküleri</h2>
|
||||
</div>
|
||||
<p className="section-description">
|
||||
Tarih ve günümüz, gözlerini kaybettikten sonra mimarlığı daha derin, duyusal ve kapsayıcı
|
||||
boyutlarda icra eden öncü mimarlarla doludur.
|
||||
</p>
|
||||
|
||||
<div className="architect-cards-grid">
|
||||
{/* Chris Downey Kartı */}
|
||||
<div className="architect-card">
|
||||
<div className="architect-card-header">
|
||||
<div className="architect-avatar-badge">CD</div>
|
||||
<div>
|
||||
<h3 className="architect-name">Chris Downey</h3>
|
||||
<span className="architect-title">San Francisco, ABD — Mimar & Erişilebilirlik Danışmanı</span>
|
||||
</div>
|
||||
</div>
|
||||
<p className="architect-bio">
|
||||
2008 yılında başarılı bir mimarken optik tümör ameliyatı sonucu 45 yaşında görme yetisini
|
||||
tamamen kaybetti. Ancak mesleğinden vazgeçmedi; tersine, görme engelliler için dünyanın en
|
||||
kapsayıcı yapılarından olan <strong>San Francisco Lighthouse for the Blind</strong> merkezini ve
|
||||
Amerikan Gaziler İdaresi Polytrauma Rehabilitasyon Merkezini tasarladı.
|
||||
</p>
|
||||
<blockquote className="architect-quote">
|
||||
“Gözlerimi kaybettiğimde mimarlıktan kopmadım; mimarlığı gözün aldatmacalarından arındırıp
|
||||
akustik, doku, hava akımı ve zihinsel geometriyle daha saf bir şekilde hissetmeye başladım.”
|
||||
</blockquote>
|
||||
<div className="architect-tools">
|
||||
<span className="tool-tag">Dokunsal Planlar</span>
|
||||
<span className="tool-tag">Kabartma Çizim</span>
|
||||
<span className="tool-tag">Akustik Mekân Algısı</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Carlos Mourão Pereira Kartı */}
|
||||
<div className="architect-card">
|
||||
<div className="architect-card-header">
|
||||
<div className="architect-avatar-badge">CP</div>
|
||||
<div>
|
||||
<h3 className="architect-name">Carlos Mourão Pereira</h3>
|
||||
<span className="architect-title">Lizbon, Portekiz — Mimar & Araştırmacı</span>
|
||||
</div>
|
||||
</div>
|
||||
<p className="architect-bio">
|
||||
Lizbon'da deniz ve su yapıları üzerine uzman bir mimarken 2006 yılında görme yetisini kaybetti.
|
||||
Görme kaybının ardından duyusal mimari ve dokunsal modelleme tekniklerini geliştirerek Lizbon
|
||||
Oşinografi Müzesi ve sensoryal termal banyo yapılarını tasarladı. Uluslararası mimarlık
|
||||
bienallerinde konuşmacı oldu.
|
||||
</p>
|
||||
<blockquote className="architect-quote">
|
||||
“Mekân sadece bir fotoğraf karesi değildir. Isıdır, sestir, adımların yankısıdır ve
|
||||
milimetrik dokunuşların uyumudur.”
|
||||
</blockquote>
|
||||
<div className="architect-tools">
|
||||
<span className="tool-tag">Duyusal Mimari</span>
|
||||
<span className="tool-tag">Dokunsal Maketler</span>
|
||||
<span className="tool-tag">Haptik Geometri</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 3. SnapCAD'in Misyonu ve Vizyonu */}
|
||||
<section className="about-section mission-vision-grid" aria-labelledby="mission-heading">
|
||||
<div className="mission-card">
|
||||
<div className="card-icon-container mission-icon">
|
||||
<Compass size={28} aria-hidden="true" />
|
||||
</div>
|
||||
<h2 id="mission-heading" className="card-title">Misyonumuz</h2>
|
||||
<p className="card-text">
|
||||
SnapCAD; profesyonel mimarlardan mühendislik öğrencilerine, hobi üreticilerinden görme engelli
|
||||
tasarımcılara kadar herkes için modern, hafif ve tam erişilebilir bir 3B modelleme ekosistemi sunar.
|
||||
</p>
|
||||
<p className="card-text highlight-text">
|
||||
<strong>SnapCAD'in misyonu;</strong> ağır donanım gereksinimleri, karmaşık arayüzler ve
|
||||
erişim bariyerleri olmadan herkesin zihnindeki 3 boyutlu fikirleri gerçeğe dönüştürmesini sağlamaktır.
|
||||
WebAssembly tabanlı yüksek performans, milimetrik VCB hassasiyeti ve küresel erişilebilirlik
|
||||
standartları (WCAG 2.1 AAA) ile tüm tasarımcılara ortak bir çalışma alanı sağlar.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="vision-card">
|
||||
<div className="card-icon-container vision-icon">
|
||||
<Lightbulb size={28} aria-hidden="true" />
|
||||
</div>
|
||||
<h2 className="card-title">Vizyonumuz</h2>
|
||||
<p className="card-text">
|
||||
Tasarım ve mühendisliğin yalnızca belirli donanımlara veya görsel yetilere sahip kişilere
|
||||
özgü olmadığı, herkesi kapsayan evrensel bir geleceği inşa etmek.
|
||||
</p>
|
||||
<p className="card-text highlight-text">
|
||||
<strong>SnapCAD'in vizyonu;</strong> doğrudan modelleme mantığı, parametrik kod blokları ve
|
||||
evrensel erişim altyapısıyla küresel CAD dünyasında standartları yeniden tanımlamak; dünyanın
|
||||
neresinde olursa olsun herkesin özgürce üretebildiği bir ekosistem oluşturmaktır.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 4. SnapCAD'i Eşsiz Kılan Teknolojik Temeller */}
|
||||
<section className="about-section tech-pillars-section" aria-labelledby="pillars-heading">
|
||||
<div className="section-header-pill">
|
||||
<Zap size={16} aria-hidden="true" />
|
||||
<h2 id="pillars-heading">SnapCAD Nasıl Başarıyor? 4 Temel Direk</h2>
|
||||
</div>
|
||||
|
||||
<div className="pillars-grid">
|
||||
<div className="pillar-item">
|
||||
<div className="pillar-icon">
|
||||
<Volume2 size={24} aria-hidden="true" />
|
||||
</div>
|
||||
<h3>1. Ekran Okuyucu & İşitsel HUD</h3>
|
||||
<p>
|
||||
NVDA, JAWS ve VoiceOver ile tam uyumlu ARIA altyapısı. Fare olmadan yön tuşlarıyla nesne hareketi,
|
||||
seçili nesnenin anlık X/Y/Z ölçülerini ve yüzey normallerini sesli dinleyebilme.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="pillar-item">
|
||||
<div className="pillar-icon">
|
||||
<Ruler size={24} aria-hidden="true" />
|
||||
</div>
|
||||
<h3>2. VCB Hassas Ölçü Kutusu</h3>
|
||||
<p>
|
||||
Göz kararı fare sürüklemelerine mecbur kalmadan, doğrudan klavyeden milimetrik değer
|
||||
yazıp (örn: 25 mm) Enter'a basarak kesin mühendislik toleranslarıyla modelleme.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="pillar-item">
|
||||
<div className="pillar-icon">
|
||||
<MoveRight size={24} aria-hidden="true" />
|
||||
</div>
|
||||
<h3>3. Doğrudan Modelleme: İt / Çek</h3>
|
||||
<p>
|
||||
Yüzey normallerini anında tespit eden ve karşı yüzü çalışma düzlemine sabitleyen doğrudan modelleme.
|
||||
Zihindeki hacim genişletme mantığıyla birebir örtüşen sezgisel geometri motoru.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="pillar-item">
|
||||
<div className="pillar-icon">
|
||||
<Layers size={24} aria-hidden="true" />
|
||||
</div>
|
||||
<h3>4. Yüksek Hızlı CAD & YakNet Bulut</h3>
|
||||
<p>
|
||||
Yüksek performanslı WebAssembly CAD çekirdeği ile tarayıcıda 60+ FPS akıcı modelleme. Ağır resimler yerine saf 3B koordinat
|
||||
veritabanı ile YakNet ekosisteminde anında bulut senkronizasyonu.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 5. Eyleme Çağrı (Call to Action) */}
|
||||
<section className="about-cta-card">
|
||||
<div className="cta-content">
|
||||
<h2>Hayalinizdeki Tasarımı Birlikte İnşa Edelim</h2>
|
||||
<p>
|
||||
SnapCAD ile herkes için tasarlanmış modern 3B modelleme stüdyosuna hemen başlayabilir veya
|
||||
ekibimizle iletişime geçerek fikirlerinizi ve önerilerinizi paylaşabilirsiniz.
|
||||
</p>
|
||||
</div>
|
||||
<div className="cta-actions">
|
||||
{onStartDesign ? (
|
||||
<button type="button" className="cta-btn primary-btn" onClick={onStartDesign}>
|
||||
<Zap size={18} aria-hidden="true" />
|
||||
<span>3D Modellemeye Başla</span>
|
||||
</button>
|
||||
) : (
|
||||
<a href="./" className="cta-btn primary-btn">
|
||||
<Zap size={18} aria-hidden="true" />
|
||||
<span>3D Modellemeye Başla</span>
|
||||
</a>
|
||||
)}
|
||||
{onGoToContact ? (
|
||||
<button type="button" className="cta-btn secondary-btn" onClick={onGoToContact}>
|
||||
<HeartHandshake size={18} aria-hidden="true" />
|
||||
<span>Bize Ulaşın</span>
|
||||
</button>
|
||||
) : (
|
||||
<a href="/iletisim" className="cta-btn secondary-btn">
|
||||
<HeartHandshake size={18} aria-hidden="true" />
|
||||
<span>Bize Ulaşın</span>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,661 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Accessibility,
|
||||
Command,
|
||||
Contrast,
|
||||
Eye,
|
||||
Keyboard,
|
||||
MousePointerClick,
|
||||
RotateCcw,
|
||||
Search,
|
||||
Sparkles,
|
||||
Type,
|
||||
Volume2,
|
||||
VolumeX,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import {
|
||||
applyA11ySettingsToDom,
|
||||
DEFAULT_A11Y_SETTINGS,
|
||||
installGlobalModalAccessibilityGuard,
|
||||
readA11ySettings,
|
||||
saveA11ySettings,
|
||||
speakTurkish,
|
||||
type A11yColorblindMode,
|
||||
type A11yScale,
|
||||
type SnapCadA11ySettings,
|
||||
} from "@/lib/accessibility";
|
||||
import { SNAPCAD_PREFABS } from "@/lib/snapcadPrefabs";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
export const SNAPCAD_SHORTCUTS = [
|
||||
{ keys: "Ctrl + K", label: "Hızlı Komut Paleti & Arama", category: "Genel & Erişilebilirlik" },
|
||||
{ keys: "Alt + A", label: "Erişilebilirlik & Görünüm Menüsünü Aç/Kapat", category: "Genel & Erişilebilirlik" },
|
||||
{ keys: "W", label: "Çalışma Düzlemi (Workplane) Aracı", category: "3D Tasarım" },
|
||||
{ keys: "R", label: "Cetvel (Ruler) Aracı", category: "3D Tasarım" },
|
||||
{ keys: "Ctrl + G", label: "Seçili Nesneleri Grupla (Boolean CSG)", category: "3D Tasarım" },
|
||||
{ keys: "Ctrl + Shift + G", label: "Grubu Çöz (Ungroup)", category: "3D Tasarım" },
|
||||
{ keys: "L", label: "Hizala (Align) Aracı", category: "3D Tasarım" },
|
||||
{ keys: "M", label: "Aynala / Çevir (Mirror / Flip)", category: "3D Tasarım" },
|
||||
{ keys: "D", label: "Çalışma Düzlemine Oturt (Drop to Workplane)", category: "3D Tasarım" },
|
||||
{ keys: "F", label: "Seçili Nesneye Odaklan (Fit View)", category: "3D Tasarım" },
|
||||
{ keys: "Ctrl + D", label: "Çoğalt ve Tekrarla (Duplicate & Repeat)", category: "3D Tasarım" },
|
||||
{ keys: "Ok Tuşları", label: "Seçili Şekli X/Z Düzleminde 1 Adım Taşı", category: "Klavye ile Modelleme" },
|
||||
{ keys: "Shift + Ok Tuşları", label: "Seçili Şekli 10 kat Hızlı Taşı", category: "Klavye ile Modelleme" },
|
||||
{ keys: "Delete / Backspace", label: "Seçili Nesneyi Sil", category: "Klavye ile Modelleme" },
|
||||
{ keys: "Ctrl + Z / Ctrl + Y", label: "Geri Al / İleri Al", category: "Genel & Erişilebilirlik" },
|
||||
];
|
||||
|
||||
export function CustomizationAndA11yStudio({
|
||||
onLaunchPrefab,
|
||||
}: {
|
||||
onLaunchPrefab?: (name: string, shapes: WorkplaneShape[]) => void;
|
||||
}) {
|
||||
const [settings, setSettings] = useState<SnapCadA11ySettings>(DEFAULT_A11Y_SETTINGS);
|
||||
|
||||
useEffect(() => {
|
||||
const loaded = readA11ySettings();
|
||||
setSettings(loaded);
|
||||
applyA11ySettingsToDom(loaded);
|
||||
}, []);
|
||||
|
||||
const update = (patch: Partial<SnapCadA11ySettings>, announceText?: string) => {
|
||||
const next = { ...settings, ...patch };
|
||||
setSettings(next);
|
||||
saveA11ySettings(next);
|
||||
if (announceText) {
|
||||
speakTurkish(announceText, Boolean(next.voiceFeedback));
|
||||
}
|
||||
};
|
||||
|
||||
const resetAll = () => {
|
||||
setSettings(DEFAULT_A11Y_SETTINGS);
|
||||
saveA11ySettings(DEFAULT_A11Y_SETTINGS);
|
||||
speakTurkish("Erişilebilirlik ayarları varsayılana sıfırlandı.", true);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="snapcad-studio-wrap" role="region" aria-label="Erişilebilirlik ve Özelleştirme Merkezi">
|
||||
{/* SVG Colorblind Filters */}
|
||||
<div className="snapcad-studio-header">
|
||||
<div>
|
||||
<span className="snapcad-pill-badge">WCAG 2.2 AAA · Evrensel Tasarım</span>
|
||||
<h2>SnapCAD Erişilebilirlik, Kısayol & Hazır Parça Merkezi</h2>
|
||||
<p>
|
||||
Görme, işitme ve motor erişilebilirlik seçeneklerini kişiselleştirin; Türkçe sesli ekran rehberini
|
||||
etkinleştirin veya hazır SnapCAD mekanik/mimari bileşenleriyle tasarıma hemen başlayın.
|
||||
</p>
|
||||
</div>
|
||||
<div className="snapcad-studio-actions">
|
||||
<button
|
||||
type="button"
|
||||
className="snapcad-btn-secondary"
|
||||
onClick={() => speakTurkish("SnapCAD Türkçe sesli ekran rehberi aktif ve hazır.", true)}
|
||||
>
|
||||
<Volume2 size={17} />
|
||||
<span>Sesli Rehberi Test Et</span>
|
||||
</button>
|
||||
<button type="button" className="snapcad-btn-secondary" onClick={resetAll}>
|
||||
<RotateCcw size={17} />
|
||||
<span>Varsayılana Sıfırla</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Erişilebilirlik Ayar Kartları */}
|
||||
<div className="snapcad-a11y-grid">
|
||||
<article className="snapcad-a11y-card">
|
||||
<div className="snapcad-a11y-card-head">
|
||||
<Contrast size={20} />
|
||||
<div>
|
||||
<h3>Görsel Kontrast & Renk Körlüğü Desteği</h3>
|
||||
<span>Az gören veya renk körlüğü olan kullanıcılar için net sınırlar</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label className="snapcad-a11y-toggle">
|
||||
<div>
|
||||
<strong>Yüksek Kontrast Modu (WCAG AAA)</strong>
|
||||
<small>Tüm butonlara, panellere ve 3D araçlarına belirgin kontrast kenarlıklar ekler.</small>
|
||||
</div>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={settings.highContrast}
|
||||
onChange={(e) =>
|
||||
update(
|
||||
{ highContrast: e.target.checked },
|
||||
e.target.checked ? "Yüksek kontrast modu açıldı" : "Yüksek kontrast modu kapatıldı",
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label className="snapcad-a11y-select-row">
|
||||
<span>Renk Körlüğü Telafi Filtresi</span>
|
||||
<select
|
||||
value={settings.colorblindMode}
|
||||
onChange={(e) =>
|
||||
update(
|
||||
{ colorblindMode: e.target.value as A11yColorblindMode },
|
||||
`Renk körlüğü modu ${e.target.value} olarak ayarlandı`,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="none">Standart Renkler (Kapalı)</option>
|
||||
<option value="deuteranopia">Deuteranopia (Yeşil-Kırmızı Hassasiyeti)</option>
|
||||
<option value="protanopia">Protanopia (Kırmızı Hassasiyeti)</option>
|
||||
<option value="tritanopia">Tritanopia (Mavi-Sarı Hassasiyeti)</option>
|
||||
</select>
|
||||
</label>
|
||||
</article>
|
||||
|
||||
<article className="snapcad-a11y-card">
|
||||
<div className="snapcad-a11y-card-head">
|
||||
<Type size={20} />
|
||||
<div>
|
||||
<h3>Okunabilirlik, Ölçekleme & Motor Kolaylık</h3>
|
||||
<span>Yazı boyutunu, tıklama hedeflerini ve font okunabilirliğini büyütün</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-a11y-scale-group" role="group" aria-label="Arayüz Ölçeği">
|
||||
<span>Arayüz & Metin Ölçeği:</span>
|
||||
<div className="snapcad-a11y-scale-buttons">
|
||||
{(["100", "115", "130"] as A11yScale[]).map((sc) => (
|
||||
<button
|
||||
key={sc}
|
||||
type="button"
|
||||
className={settings.uiScale === sc ? "active" : ""}
|
||||
onClick={() => update({ uiScale: sc }, `Arayüz ölçeği yüzde ${sc} yapıldı`)}
|
||||
>
|
||||
%{sc} {sc === "100" ? "(Normal)" : sc === "115" ? "(Büyük)" : "(Çok Büyük)"}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label className="snapcad-a11y-toggle">
|
||||
<div>
|
||||
<strong>Disleksi Dostu Okunabilir Yazı Tipi</strong>
|
||||
<small>Harf ve kelime aralıklarını genişleterek okuma güçlüğünü azaltır.</small>
|
||||
</div>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={settings.dyslexicFont}
|
||||
onChange={(e) =>
|
||||
update(
|
||||
{ dyslexicFont: e.target.checked },
|
||||
e.target.checked ? "Okunabilir yazı tipi açıldı" : "Varsayılan yazı tipine dönüldü",
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label className="snapcad-a11y-toggle">
|
||||
<div>
|
||||
<strong>Geniş Tıklama Hedefleri (Motor Erişilebilirlik)</strong>
|
||||
<small>3D araç çubuğu butonlarını, pin noktalarını ve kontrolleri büyütür.</small>
|
||||
</div>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={settings.largeTargets}
|
||||
onChange={(e) =>
|
||||
update(
|
||||
{ largeTargets: e.target.checked },
|
||||
e.target.checked ? "Geniş tıklama hedefleri açıldı" : "Geniş tıklama hedefleri kapatıldı",
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</article>
|
||||
|
||||
<article className="snapcad-a11y-card">
|
||||
<div className="snapcad-a11y-card-head">
|
||||
<Volume2 size={20} />
|
||||
<div>
|
||||
<h3>Türkçe Sesli Rehber & Odak Desteği</h3>
|
||||
<span>Ekran okuyucu ipuçları ve Web Speech API sesli bildirimler</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label className="snapcad-a11y-toggle">
|
||||
<div>
|
||||
<strong>Türkçe Sesli Geri Bildirim (TTS)</strong>
|
||||
<small>Seçilen araçları, eklenen 3D şekilleri ve simülasyon durumunu sesli okur.</small>
|
||||
</div>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={settings.voiceFeedback}
|
||||
onChange={(e) =>
|
||||
update(
|
||||
{ voiceFeedback: e.target.checked },
|
||||
e.target.checked ? "Türkçe sesli geri bildirim etkinleştirildi" : "Sesli geri bildirim kapatıldı",
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label className="snapcad-a11y-toggle">
|
||||
<div>
|
||||
<strong>Animasyonları ve Hareketi Azalt (Reduced Motion)</strong>
|
||||
<small>Baş dönmesi veya odak dağınıklığını önlemek için geçiş efektlerini sadeleştirir.</small>
|
||||
</div>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={settings.reducedMotion}
|
||||
onChange={(e) =>
|
||||
update(
|
||||
{ reducedMotion: e.target.checked },
|
||||
e.target.checked ? "Hareket azaltma modu açıldı" : "Hareket azaltma modu kapatıldı",
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
{/* SnapCAD Hazır 3D Modeller & Başlatıcılar (Prefab Kütüphanesi) */}
|
||||
{onLaunchPrefab ? (
|
||||
<section className="snapcad-prefab-section" aria-label="Hazır 3D Modeller ve Tasarım Başlatıcılar">
|
||||
<div className="snapcad-section-title-row">
|
||||
<div>
|
||||
<h3>
|
||||
<Sparkles size={18} /> SnapCAD Hazır 3D Bileşen & Şablon Kütüphanesi
|
||||
</h3>
|
||||
<span>
|
||||
Tek tıkla çok parçalı (Katı + Delik) mekanik, elektronik veya mimari modelleri 3D çalışma düzleminde açın.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="snapcad-prefab-grid">
|
||||
{SNAPCAD_PREFABS.map((item) => (
|
||||
<article key={item.id} className="snapcad-prefab-card">
|
||||
<div className="snapcad-prefab-top">
|
||||
<span className="snapcad-prefab-cat" style={{ color: item.accentColor }}>
|
||||
{item.categoryLabel}
|
||||
</span>
|
||||
<span className="snapcad-prefab-badge">{item.badge}</span>
|
||||
</div>
|
||||
<h4>{item.title}</h4>
|
||||
<p>{item.description}</p>
|
||||
<button
|
||||
type="button"
|
||||
className="snapcad-btn-primary full"
|
||||
onClick={() => {
|
||||
speakTurkish(`${item.title} 3D sahnede açılıyor`);
|
||||
onLaunchPrefab(item.title, item.buildShapes());
|
||||
}}
|
||||
>
|
||||
<span>3D Editörde Aç ve Düzenle</span>
|
||||
</button>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{/* Klavye Kısayolları Tablosu */}
|
||||
<section className="snapcad-shortcuts-section" aria-label="Klavye Kısayolları">
|
||||
<h3>
|
||||
<Keyboard size={18} /> Klavye ile Tam Kontrol & Kısayol Rehberi
|
||||
</h3>
|
||||
<div className="snapcad-shortcuts-grid">
|
||||
{SNAPCAD_SHORTCUTS.map((sc) => (
|
||||
<div key={sc.keys} className="snapcad-shortcut-item">
|
||||
<kbd>{sc.keys}</kbd>
|
||||
<div>
|
||||
<strong>{sc.label}</strong>
|
||||
<small>{sc.category}</small>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function GlobalAccessibilityToolbar({
|
||||
onQuickNavigate,
|
||||
onLaunchPrefab,
|
||||
}: {
|
||||
onQuickNavigate?: (section: "home" | "drawing" | "circuits" | "codeblocks" | "challenges" | "customization" | "create3d") => void;
|
||||
onLaunchPrefab?: (name: string, shapes: WorkplaneShape[]) => void;
|
||||
}) {
|
||||
const [settings, setSettings] = useState<SnapCadA11ySettings>(DEFAULT_A11Y_SETTINGS);
|
||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||
const [paletteOpen, setPaletteOpen] = useState(false);
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
const loaded = readA11ySettings();
|
||||
setSettings(loaded);
|
||||
applyA11ySettingsToDom(loaded);
|
||||
installGlobalModalAccessibilityGuard();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "k") {
|
||||
event.preventDefault();
|
||||
setPaletteOpen((v) => !v);
|
||||
setDrawerOpen(false);
|
||||
} else if (event.altKey && event.key.toLowerCase() === "a") {
|
||||
event.preventDefault();
|
||||
setDrawerOpen((v) => !v);
|
||||
setPaletteOpen(false);
|
||||
} else if (event.key === "Escape") {
|
||||
setPaletteOpen(false);
|
||||
setDrawerOpen(false);
|
||||
}
|
||||
};
|
||||
window.addEventListener("keydown", onKeyDown);
|
||||
return () => window.removeEventListener("keydown", onKeyDown);
|
||||
}, []);
|
||||
|
||||
const update = (patch: Partial<SnapCadA11ySettings>, msg?: string) => {
|
||||
const next = { ...settings, ...patch };
|
||||
setSettings(next);
|
||||
saveA11ySettings(next);
|
||||
if (msg) speakTurkish(msg, Boolean(next.voiceFeedback));
|
||||
};
|
||||
|
||||
const quickActions = useMemo(
|
||||
() => [
|
||||
{
|
||||
id: "new-3d",
|
||||
title: "Yeni 3D Tasarım Oluştur (3D CAD Editörü)",
|
||||
category: "Stüdyolar",
|
||||
run: () => onQuickNavigate?.("create3d"),
|
||||
},
|
||||
{
|
||||
id: "open-drawing",
|
||||
title: "Teknik Resim & Mühendislik Paftası (ISO-E 3 Görünüş, Kesit, .DXF & .PDF)",
|
||||
category: "Stüdyolar",
|
||||
run: () => onQuickNavigate?.("drawing"),
|
||||
},
|
||||
{
|
||||
id: "open-circuits",
|
||||
title: "Elektronik Devreler (Arduino & Breadboard Simülatörü)",
|
||||
category: "Stüdyolar",
|
||||
run: () => onQuickNavigate?.("circuits"),
|
||||
},
|
||||
{
|
||||
id: "open-codeblocks",
|
||||
title: "Kod Blokları (Parametrik Bloklarla 3D Modelleme)",
|
||||
category: "Stüdyolar",
|
||||
run: () => onQuickNavigate?.("codeblocks"),
|
||||
},
|
||||
{
|
||||
id: "open-challenges",
|
||||
title: "Eğitim Görevleri ve Rehberler",
|
||||
category: "Eğitim",
|
||||
run: () => onQuickNavigate?.("challenges"),
|
||||
},
|
||||
{
|
||||
id: "toggle-contrast",
|
||||
title: `Yüksek Kontrast Modunu ${settings.highContrast ? "Kapat" : "Aç"}`,
|
||||
category: "Erişilebilirlik",
|
||||
run: () => update({ highContrast: !settings.highContrast }, "Yüksek kontrast değiştirildi"),
|
||||
},
|
||||
{
|
||||
id: "toggle-voice",
|
||||
title: `Türkçe Sesli Ekran Rehberini ${settings.voiceFeedback ? "Kapat" : "Aç"}`,
|
||||
category: "Erişilebilirlik",
|
||||
run: () => update({ voiceFeedback: !settings.voiceFeedback }, "Türkçe sesli rehber değiştirildi"),
|
||||
},
|
||||
{
|
||||
id: "scale-115",
|
||||
title: "Arayüz Boyutunu Büyüt (%115)",
|
||||
category: "Erişilebilirlik",
|
||||
run: () => update({ uiScale: "115" }, "Arayüz yüzde 115 büyütüldü"),
|
||||
},
|
||||
{
|
||||
id: "scale-100",
|
||||
title: "Arayüz Boyutunu Normale Döndür (%100)",
|
||||
category: "Erişilebilirlik",
|
||||
run: () => update({ uiScale: "100" }, "Arayüz normal boyuta döndü"),
|
||||
},
|
||||
...SNAPCAD_PREFABS.map((prefab) => ({
|
||||
id: `prefab-${prefab.id}`,
|
||||
title: `Hazır 3D Model Aç: ${prefab.title} (${prefab.categoryLabel})`,
|
||||
category: "Hazır 3D Modeller",
|
||||
run: () => onLaunchPrefab?.(prefab.title, prefab.buildShapes()),
|
||||
})),
|
||||
],
|
||||
[onLaunchPrefab, onQuickNavigate, settings],
|
||||
);
|
||||
|
||||
const filteredActions = useMemo(() => {
|
||||
const q = searchQuery.trim().toLowerCase();
|
||||
if (!q) return quickActions;
|
||||
return quickActions.filter(
|
||||
(a) => a.title.toLowerCase().includes(q) || a.category.toLowerCase().includes(q),
|
||||
);
|
||||
}, [quickActions, searchQuery]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Global SVG Filters for Colorblindness */}
|
||||
<svg className="snapcad-sr-svg-filters" aria-hidden="true">
|
||||
<defs>
|
||||
<filter id="snapcad-deuteranopia">
|
||||
<feColorMatrix
|
||||
type="matrix"
|
||||
values="0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0"
|
||||
/>
|
||||
</filter>
|
||||
<filter id="snapcad-protanopia">
|
||||
<feColorMatrix
|
||||
type="matrix"
|
||||
values="0.567 0.433 0 0 0 0.558 0.442 0 0 0 0 0.242 0.758 0 0 0 0 0 1 0"
|
||||
/>
|
||||
</filter>
|
||||
<filter id="snapcad-tritanopia">
|
||||
<feColorMatrix
|
||||
type="matrix"
|
||||
values="0.95 0.05 0 0 0 0 0.433 0.567 0 0 0 0.475 0.525 0 0 0 0 0 1 0"
|
||||
/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
{/* Sağ Alt Yüzen Erişilebilirlik & Komut Paleti Çubuğu */}
|
||||
<div className="snapcad-floating-a11y-dock" role="region" aria-label="Hızlı Erişilebilirlik ve Komut Çubuğu">
|
||||
<button
|
||||
type="button"
|
||||
className="snapcad-dock-btn command"
|
||||
onClick={() => {
|
||||
setPaletteOpen((v) => !v);
|
||||
setDrawerOpen(false);
|
||||
}}
|
||||
title="Hızlı Komut Paleti (Ctrl+K)"
|
||||
aria-label="Hızlı Komut Paleti (Ctrl+K)"
|
||||
>
|
||||
<Command size={16} />
|
||||
<span>Komutlar (Ctrl+K)</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={`snapcad-dock-btn a11y ${
|
||||
settings.highContrast || settings.voiceFeedback || settings.uiScale !== "100" ? "active" : ""
|
||||
}`}
|
||||
onClick={() => {
|
||||
setDrawerOpen((v) => !v);
|
||||
setPaletteOpen(false);
|
||||
}}
|
||||
title="Erişilebilirlik Ayarları (Alt+A)"
|
||||
aria-label="Erişilebilirlik Ayarları (Alt+A)"
|
||||
aria-expanded={drawerOpen}
|
||||
>
|
||||
<Accessibility size={17} />
|
||||
<span>Erişilebilirlik</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Hızlı Erişilebilirlik Çekmecesi */}
|
||||
{drawerOpen ? (
|
||||
<aside
|
||||
className="snapcad-a11y-popover"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="snapcad-a11y-popover-title"
|
||||
tabIndex={-1}
|
||||
>
|
||||
<header className="snapcad-a11y-popover-head">
|
||||
<strong id="snapcad-a11y-popover-title">
|
||||
<Accessibility size={17} /> Erişilebilirlik Kontrolleri
|
||||
</strong>
|
||||
<button
|
||||
type="button"
|
||||
data-modal-close="true"
|
||||
data-modal-focus-key="a11y-close"
|
||||
onClick={() => setDrawerOpen(false)}
|
||||
aria-label="Erişilebilirlik penceresini kapat"
|
||||
>
|
||||
<X size={16} />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div className="snapcad-a11y-popover-body">
|
||||
<button
|
||||
type="button"
|
||||
data-modal-initial-focus="true"
|
||||
data-modal-focus-key="a11y-contrast"
|
||||
aria-pressed={settings.highContrast}
|
||||
className={`snapcad-a11y-quick-btn ${settings.highContrast ? "on" : ""}`}
|
||||
onClick={() => update({ highContrast: !settings.highContrast }, "Yüksek kontrast değiştirildi")}
|
||||
>
|
||||
<Contrast size={16} />
|
||||
<span>Yüksek Kontrast: {settings.highContrast ? "AÇIK" : "KAPALI"}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
data-modal-focus-key="a11y-voice"
|
||||
aria-pressed={settings.voiceFeedback}
|
||||
className={`snapcad-a11y-quick-btn ${settings.voiceFeedback ? "on" : ""}`}
|
||||
onClick={() => update({ voiceFeedback: !settings.voiceFeedback }, "Türkçe sesli rehber aktif")}
|
||||
>
|
||||
{settings.voiceFeedback ? <Volume2 size={16} /> : <VolumeX size={16} />}
|
||||
<span>Sesli Rehber (TTS): {settings.voiceFeedback ? "AÇIK" : "KAPALI"}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
data-modal-focus-key="a11y-font"
|
||||
aria-pressed={settings.dyslexicFont}
|
||||
className={`snapcad-a11y-quick-btn ${settings.dyslexicFont ? "on" : ""}`}
|
||||
onClick={() => update({ dyslexicFont: !settings.dyslexicFont }, "Okunabilir font değiştirildi")}
|
||||
>
|
||||
<Type size={16} />
|
||||
<span>Okunabilir Font: {settings.dyslexicFont ? "AÇIK" : "KAPALI"}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
data-modal-focus-key="a11y-targets"
|
||||
aria-pressed={settings.largeTargets}
|
||||
className={`snapcad-a11y-quick-btn ${settings.largeTargets ? "on" : ""}`}
|
||||
onClick={() => update({ largeTargets: !settings.largeTargets }, "Geniş buton hedefleri değiştirildi")}
|
||||
>
|
||||
<MousePointerClick size={16} />
|
||||
<span>Büyük Butonlar: {settings.largeTargets ? "AÇIK" : "KAPALI"}</span>
|
||||
</button>
|
||||
|
||||
<div className="snapcad-a11y-popover-scale" role="group" aria-label="Arayüz Boyutu">
|
||||
<span>Boyut:</span>
|
||||
{(["100", "115", "130"] as A11yScale[]).map((sc) => (
|
||||
<button
|
||||
key={sc}
|
||||
type="button"
|
||||
data-modal-focus-key={`a11y-scale-${sc}`}
|
||||
aria-pressed={settings.uiScale === sc}
|
||||
className={settings.uiScale === sc ? "active" : ""}
|
||||
onClick={() => update({ uiScale: sc }, `Ölçek yüzde ${sc}`)}
|
||||
>
|
||||
%{sc}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<label className="snapcad-a11y-popover-select">
|
||||
<span>
|
||||
<Eye size={14} /> Renk Körlüğü:
|
||||
</span>
|
||||
<select
|
||||
data-modal-focus-key="a11y-colorblind"
|
||||
value={settings.colorblindMode}
|
||||
onChange={(e) => update({ colorblindMode: e.target.value as A11yColorblindMode })}
|
||||
>
|
||||
<option value="none">Normal</option>
|
||||
<option value="deuteranopia">Deuteranopia</option>
|
||||
<option value="protanopia">Protanopia</option>
|
||||
<option value="tritanopia">Tritanopia</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</aside>
|
||||
) : null}
|
||||
|
||||
{/* Ctrl+K Hızlı Komut Paleti */}
|
||||
{paletteOpen ? (
|
||||
<div
|
||||
className="snapcad-command-overlay"
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget) setPaletteOpen(false);
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="snapcad-command-modal"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="SnapCAD Hızlı Komut Paleti"
|
||||
tabIndex={-1}
|
||||
>
|
||||
<div className="snapcad-command-search">
|
||||
<Search size={18} />
|
||||
<input
|
||||
autoFocus
|
||||
data-modal-initial-focus="true"
|
||||
data-modal-focus-key="command-search-input"
|
||||
type="text"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
placeholder="Komut, 3D hazır model veya erişilebilirlik özelliği ara..."
|
||||
aria-label="Komut ara"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
data-modal-close="true"
|
||||
onClick={() => setPaletteOpen(false)}
|
||||
aria-label="Komut paletini kapat"
|
||||
>
|
||||
<X size={17} />
|
||||
</button>
|
||||
</div>
|
||||
<div className="snapcad-command-list" role="listbox" aria-label="Komut Sonuçları">
|
||||
{filteredActions.map((act) => (
|
||||
<button
|
||||
key={act.id}
|
||||
type="button"
|
||||
className="snapcad-command-item"
|
||||
onClick={() => {
|
||||
act.run();
|
||||
setPaletteOpen(false);
|
||||
setSearchQuery("");
|
||||
}}
|
||||
>
|
||||
<span>{act.title}</span>
|
||||
<small>{act.category}</small>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
"use client";
|
||||
|
||||
import React, { Component, type ErrorInfo, type ReactNode } from "react";
|
||||
import { AlertTriangle, RefreshCw, RotateCcw } from "lucide-react";
|
||||
|
||||
interface Props {
|
||||
children: ReactNode;
|
||||
fallback?: ReactNode;
|
||||
}
|
||||
|
||||
interface State {
|
||||
hasError: boolean;
|
||||
error: Error | null;
|
||||
}
|
||||
|
||||
export class AppErrorBoundary extends Component<Props, State> {
|
||||
public override state: State = {
|
||||
hasError: false,
|
||||
error: null,
|
||||
};
|
||||
|
||||
public static getDerivedStateFromError(error: Error): State {
|
||||
return { hasError: true, error };
|
||||
}
|
||||
|
||||
public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||
console.error("[SnapCAD ErrorBoundary]", error, errorInfo);
|
||||
}
|
||||
|
||||
private handleReload = () => {
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
private handleSafeReset = () => {
|
||||
try {
|
||||
window.sessionStorage.clear();
|
||||
window.localStorage.removeItem("sketchforge.active_challenge");
|
||||
window.localStorage.removeItem("sketchforge.last_active_project");
|
||||
} catch {}
|
||||
window.location.href = "/";
|
||||
};
|
||||
|
||||
public override render() {
|
||||
if (this.state.hasError) {
|
||||
if (this.props.fallback) {
|
||||
return this.props.fallback;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="snapcad-error-boundary-screen" role="alert" aria-live="assertive">
|
||||
<div className="error-card">
|
||||
<div className="error-icon-box" aria-hidden="true">
|
||||
<AlertTriangle size={32} className="text-amber-400" />
|
||||
</div>
|
||||
<h1 className="error-card-title">SnapCAD Studio Yükleme Kurtarma</h1>
|
||||
<p className="error-card-desc">
|
||||
Sayfa görüntülenirken beklenmeyen bir tarayıcı veya grafik belleği durumu algılandı.
|
||||
Verileriniz güvendedir, aşağıdaki adımla stüdyoyu hemen kurtarabilirsiniz:
|
||||
</p>
|
||||
{this.state.error ? (
|
||||
<pre className="error-diagnostic-preview">
|
||||
{this.state.error.message || "Bilinmeyen çalışma zamanı hatası"}
|
||||
</pre>
|
||||
) : null}
|
||||
<div className="error-actions-row">
|
||||
<button
|
||||
type="button"
|
||||
className="error-action-btn primary"
|
||||
onClick={this.handleReload}
|
||||
>
|
||||
<RefreshCw size={15} aria-hidden="true" />
|
||||
<span>Sayfayı Yeniden Yükle</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="error-action-btn secondary"
|
||||
onClick={this.handleSafeReset}
|
||||
>
|
||||
<RotateCcw size={15} aria-hidden="true" />
|
||||
<span>Güvenli Modda Başlat</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Layers,
|
||||
X,
|
||||
Eye,
|
||||
EyeOff,
|
||||
Check,
|
||||
Plus,
|
||||
Tag,
|
||||
CheckSquare,
|
||||
Sparkles,
|
||||
} from "lucide-react";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
export interface ArchitecturalLayersModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
shapes: WorkplaneShape[];
|
||||
onUpdateShapes: (shapes: WorkplaneShape[], notice?: string) => void;
|
||||
onSelectShapes: (ids: string[]) => void;
|
||||
}
|
||||
|
||||
const PRESET_TAG_COLORS: Record<string, string> = {
|
||||
Duvarlar: "#3b82f6",
|
||||
Çatı: "#ef4444",
|
||||
Zemin: "#10b981",
|
||||
"Kapı & Boşluklar": "#f59e0b",
|
||||
Pencereler: "#06b6d4",
|
||||
Mobilyalar: "#8b5cf6",
|
||||
Merdiven: "#14b8a6",
|
||||
"Çatı Makası": "#64748b",
|
||||
"Katman 0 (Genel)": "#94a3b8",
|
||||
};
|
||||
|
||||
export const ArchitecturalLayersModal: React.FC<ArchitecturalLayersModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
shapes,
|
||||
onUpdateShapes,
|
||||
onSelectShapes,
|
||||
}) => {
|
||||
const [newTagInput, setNewTagInput] = useState("");
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
// Group shapes by tag
|
||||
const tagMap = new Map<string, WorkplaneShape[]>();
|
||||
shapes.forEach((shape) => {
|
||||
const tagName = (shape.tag && shape.tag.trim()) || "Katman 0 (Genel)";
|
||||
const existing = tagMap.get(tagName) || [];
|
||||
existing.push(shape);
|
||||
tagMap.set(tagName, existing);
|
||||
});
|
||||
|
||||
const tags = Array.from(tagMap.entries()).map(([name, tagShapes]) => {
|
||||
const allHidden = tagShapes.length > 0 && tagShapes.every((s) => s.hidden);
|
||||
const anyHidden = tagShapes.some((s) => s.hidden);
|
||||
const color = PRESET_TAG_COLORS[name] || "#6366f1";
|
||||
return {
|
||||
name,
|
||||
shapes: tagShapes,
|
||||
count: tagShapes.length,
|
||||
allHidden,
|
||||
anyHidden,
|
||||
color,
|
||||
};
|
||||
});
|
||||
|
||||
const toggleLayerVisibility = (tagName: string) => {
|
||||
const targetShapes = tagMap.get(tagName) || [];
|
||||
const shouldHide = !targetShapes.every((s) => s.hidden);
|
||||
|
||||
const updated = shapes.map((shape) => {
|
||||
const shapeTag = (shape.tag && shape.tag.trim()) || "Katman 0 (Genel)";
|
||||
if (shapeTag === tagName) {
|
||||
return { ...shape, hidden: shouldHide };
|
||||
}
|
||||
return shape;
|
||||
});
|
||||
|
||||
onUpdateShapes(
|
||||
updated,
|
||||
`'${tagName}' katmanı ${shouldHide ? "gizlendi" : "görünür yapıldı"}`
|
||||
);
|
||||
};
|
||||
|
||||
const handleSelectLayer = (tagName: string) => {
|
||||
const targetShapes = tagMap.get(tagName) || [];
|
||||
const visibleIds = targetShapes.filter((s) => !s.hidden).map((s) => s.id);
|
||||
if (visibleIds.length) {
|
||||
onSelectShapes(visibleIds);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreateTag = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const trimmed = newTagInput.trim();
|
||||
if (!trimmed) return;
|
||||
setNewTagInput("");
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="layers-title"
|
||||
>
|
||||
<div className="relative flex max-h-[85vh] w-full max-w-lg flex-col rounded-2xl border border-slate-200 bg-white shadow-2xl dark:border-slate-800 dark:bg-slate-900">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between border-b border-slate-200 px-6 py-4 dark:border-slate-800">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-blue-500/10 text-blue-600 dark:bg-blue-500/20 dark:text-blue-400">
|
||||
<Layers className="h-5 w-5" />
|
||||
</div>
|
||||
<div>
|
||||
<h2
|
||||
id="layers-title"
|
||||
className="text-lg font-bold text-slate-900 dark:text-white"
|
||||
>
|
||||
Mimari Katmanlar (Tags & Layers)
|
||||
</h2>
|
||||
<p className="text-xs text-slate-500 dark:text-slate-400">
|
||||
Çatı, duvar, mobilya gibi elemanları tek tıkla gizleyip açın
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-lg p-2 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-slate-800 dark:hover:text-slate-200"
|
||||
aria-label="Kapat"
|
||||
>
|
||||
<X className="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Quick hint */}
|
||||
<div className="bg-amber-50 px-6 py-2.5 text-xs text-amber-800 dark:bg-amber-950/30 dark:text-amber-300">
|
||||
💡 <strong>İpucu:</strong> Minyatür ev gibi projelerde evin içini görmek için <strong>"Çatı"</strong> katmanının göz ikonuna tıklayarak çatıyı anında gizleyebilirsiniz.
|
||||
</div>
|
||||
|
||||
{/* Layers List */}
|
||||
<div className="flex-1 overflow-y-auto px-6 py-4">
|
||||
<div className="space-y-2">
|
||||
{tags.map((layer) => (
|
||||
<div
|
||||
key={layer.name}
|
||||
className={`flex items-center justify-between rounded-xl border p-3 transition-all ${
|
||||
layer.allHidden
|
||||
? "border-slate-200 bg-slate-50/70 opacity-60 dark:border-slate-800 dark:bg-slate-900/40"
|
||||
: "border-slate-200 bg-white hover:border-blue-300 dark:border-slate-700 dark:bg-slate-800 dark:hover:border-blue-500"
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<span
|
||||
className="h-3.5 w-3.5 rounded-full ring-2 ring-white dark:ring-slate-900"
|
||||
style={{ backgroundColor: layer.color }}
|
||||
/>
|
||||
<div>
|
||||
<span className="font-semibold text-slate-800 dark:text-slate-200">
|
||||
{layer.name}
|
||||
</span>
|
||||
<span className="ml-2.5 text-xs text-slate-400 dark:text-slate-500">
|
||||
{layer.count} nesne
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleSelectLayer(layer.name)}
|
||||
title="Katmandaki tüm nesneleri seç"
|
||||
className="flex items-center gap-1 rounded-lg px-2.5 py-1 text-xs font-medium text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-700"
|
||||
>
|
||||
<CheckSquare className="h-3.5 w-3.5" />
|
||||
Seç
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => toggleLayerVisibility(layer.name)}
|
||||
title={
|
||||
layer.allHidden
|
||||
? "Katmanı görünür yap"
|
||||
: "Katmanı gizle"
|
||||
}
|
||||
className={`flex h-8 w-8 items-center justify-center rounded-lg transition-colors ${
|
||||
layer.allHidden
|
||||
? "bg-rose-100 text-rose-600 hover:bg-rose-200 dark:bg-rose-950/60 dark:text-rose-400"
|
||||
: "bg-slate-100 text-slate-700 hover:bg-slate-200 dark:bg-slate-700 dark:text-slate-200"
|
||||
}`}
|
||||
>
|
||||
{layer.allHidden ? (
|
||||
<EyeOff className="h-4 w-4" />
|
||||
) : (
|
||||
<Eye className="h-4 w-4" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="flex items-center justify-between border-t border-slate-200 bg-slate-50 px-6 py-3.5 dark:border-slate-800 dark:bg-slate-950/50">
|
||||
<span className="text-xs text-slate-500">
|
||||
Toplam {tags.length} katman, {shapes.length} nesne
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-xl bg-blue-600 px-5 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-700 active:scale-95"
|
||||
>
|
||||
Tamam
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,195 @@
|
||||
"use client";
|
||||
|
||||
import { Activity, Cpu, Download, Plus, Search, Sparkles, Zap } from "lucide-react";
|
||||
import { useState, useMemo } from "react";
|
||||
import { CIRCUIT_TEMPLATES } from "./circuits/templates";
|
||||
import type { CircuitTemplate } from "./circuits/types";
|
||||
|
||||
export type CircuitsProjectsDashboardProps = {
|
||||
onOpenProject: (templateId: string) => void;
|
||||
};
|
||||
|
||||
export function CircuitsProjectsDashboard({ onOpenProject }: CircuitsProjectsDashboardProps) {
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>("all");
|
||||
|
||||
const categories = useMemo(() => {
|
||||
const list = Array.from(new Set(CIRCUIT_TEMPLATES.map((t) => t.category)));
|
||||
return ["all", ...list];
|
||||
}, []);
|
||||
|
||||
const filteredTemplates = useMemo(() => {
|
||||
return CIRCUIT_TEMPLATES.filter((tpl) => {
|
||||
const matchCat = selectedCategory === "all" || tpl.category === selectedCategory;
|
||||
const matchQuery =
|
||||
!searchQuery ||
|
||||
tpl.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
tpl.description.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
tpl.badge.toLowerCase().includes(searchQuery.toLowerCase());
|
||||
return matchCat && matchQuery;
|
||||
});
|
||||
}, [selectedCategory, searchQuery]);
|
||||
|
||||
return (
|
||||
<div className="snapcad-projects-dashboard">
|
||||
<div className="snapcad-dashboard-hero">
|
||||
<div>
|
||||
<span className="snapcad-pill-badge circuits">
|
||||
<Zap size={14} /> Elektronik Devre Projeleri
|
||||
</span>
|
||||
<h2>Elektronik Devre & Arduino Projeleri Galerisi</h2>
|
||||
<p>
|
||||
İnteraktif devre stüdyosu mantığıyla devre projelerinizi listeleyin, yönetin ve test edin. Arduino Uno, sensörler,
|
||||
aktüatörler ve C++ / Blok kodlama ile çalışan projeleri tek tıkla açıp simüle edin.
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="dashboard-primary"
|
||||
onClick={() => onOpenProject(CIRCUIT_TEMPLATES[0].id)}
|
||||
>
|
||||
<Plus size={18} strokeWidth={2.6} />
|
||||
<span>Yeni Elektronik Devre Oluştur</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Hızlı Başlatıcı Aksiyon Butonları (Action Tiles) */}
|
||||
<div className="dashboard-actions-band snapcad-actions-band">
|
||||
<button
|
||||
className="dashboard-action-tile create"
|
||||
type="button"
|
||||
onClick={() => onOpenProject(CIRCUIT_TEMPLATES[0].id)}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Plus size={24} strokeWidth={2.6} />
|
||||
</span>
|
||||
<span>Yeni Devre Tasarla</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile snapcad-tile-circuits"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("traffic-light")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Zap size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Trafik Lambası (3x LED)</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("servo-pot")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Cpu size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Servo Motor & PWM Kontrol</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("ultrasonic-radar")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Activity size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>HC-SR04 Mesafe Radarı</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("lcd-thermometer")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Sparkles size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>16x2 I2C LCD Termometre</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Arama & Kategori Filtreleme */}
|
||||
<div className="snapcad-dashboard-filter-bar">
|
||||
<div className="snapcad-search-box">
|
||||
<Search size={16} />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Devre projelerinde ara (örn: LED, servo, radar, motor)..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-filter-chips">
|
||||
{categories.map((cat) => (
|
||||
<button
|
||||
key={cat}
|
||||
type="button"
|
||||
className={`snapcad-filter-chip ${selectedCategory === cat ? "active" : ""}`}
|
||||
onClick={() => setSelectedCategory(cat)}
|
||||
>
|
||||
{cat === "all" ? "Tüm Devreler" : cat}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Proje Kartları Izgarası */}
|
||||
<div className="project-grid">
|
||||
{filteredTemplates.map((tpl) => (
|
||||
<article className="project-card snapcad-project-card" key={tpl.id}>
|
||||
<div className="snapcad-card-banner circuit">
|
||||
<div className="snapcad-circuit-schematic-bg" />
|
||||
<div className="snapcad-card-icon-badge">
|
||||
<Cpu size={14} />
|
||||
<span>{tpl.components.length} Parça</span>
|
||||
</div>
|
||||
<span className="snapcad-card-source-tag">{tpl.badge}</span>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-card-content">
|
||||
<div className="snapcad-card-head">
|
||||
<span className="snapcad-card-dept">{tpl.category}</span>
|
||||
<span className="snapcad-card-std">{tpl.wires.length} Kablo</span>
|
||||
</div>
|
||||
<h3 className="snapcad-card-title">{tpl.title}</h3>
|
||||
<p className="snapcad-card-desc">{tpl.description}</p>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-card-footer">
|
||||
<button
|
||||
type="button"
|
||||
className="snapcad-btn-tinker"
|
||||
onClick={() => onOpenProject(tpl.id)}
|
||||
title="Devre Simülatöründe Aç"
|
||||
>
|
||||
<Zap size={16} />
|
||||
<span>Devreyi Aç & Simüle Et</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="snapcad-btn-ghost-icon"
|
||||
onClick={() => {
|
||||
const blob = new Blob([tpl.code], { type: "text/plain;charset=utf-8" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `${tpl.id}_code.ino`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}}
|
||||
title="Arduino C++ Kodunu (.ino) İndir"
|
||||
>
|
||||
<Download size={16} />
|
||||
<span>.INO İndir</span>
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,174 @@
|
||||
"use client";
|
||||
|
||||
import { Blocks, Box, Code2, Plus, Search, Sparkles } from "lucide-react";
|
||||
import { useState, useMemo } from "react";
|
||||
import { CODEBLOCK_TEMPLATES, executeCodeblocksToShapes, type CodeblockTemplate } from "./CodeblocksStudio";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
export type CodeblocksProjectsDashboardProps = {
|
||||
onOpenProject: (templateId: string) => void;
|
||||
onOpenIn3DEditor: (projectName: string, shapes: WorkplaneShape[]) => void;
|
||||
};
|
||||
|
||||
export function CodeblocksProjectsDashboard({
|
||||
onOpenProject,
|
||||
onOpenIn3DEditor,
|
||||
}: CodeblocksProjectsDashboardProps) {
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
|
||||
const filteredTemplates = useMemo(() => {
|
||||
return CODEBLOCK_TEMPLATES.filter((tpl) => {
|
||||
const matchQuery =
|
||||
!searchQuery ||
|
||||
tpl.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
tpl.description.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
tpl.badge.toLowerCase().includes(searchQuery.toLowerCase());
|
||||
return matchQuery;
|
||||
});
|
||||
}, [searchQuery]);
|
||||
|
||||
return (
|
||||
<div className="snapcad-projects-dashboard">
|
||||
<div className="snapcad-dashboard-hero">
|
||||
<div>
|
||||
<span className="snapcad-pill-badge">
|
||||
<Blocks size={14} /> Kod Blokları & Algoritmik 3D Projeleri
|
||||
</span>
|
||||
<h2>Kod Blokları ile 3D Modelleme Projeleri Galerisi</h2>
|
||||
<p>
|
||||
Görsel bloklar, döngüler, dairesel dizilimler ve parametrik kurallarla
|
||||
üretilen 3B modellerinizi yönetin; dilediğiniz projeyi açın, blokları değiştirin veya tek tıkla 3D sahneye aktarın.
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="dashboard-primary"
|
||||
onClick={() => onOpenProject(CODEBLOCK_TEMPLATES[0].id)}
|
||||
>
|
||||
<Plus size={18} strokeWidth={2.6} />
|
||||
<span>Yeni Kod Bloğu Oluştur</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Hızlı Başlatma Kartları (Action Tiles) */}
|
||||
<div className="dashboard-actions-band snapcad-actions-band">
|
||||
<button
|
||||
className="dashboard-action-tile create"
|
||||
type="button"
|
||||
onClick={() => onOpenProject(CODEBLOCK_TEMPLATES[0].id)}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Plus size={24} strokeWidth={2.6} />
|
||||
</span>
|
||||
<span>Yeni Boş Blok Projesi</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile snapcad-tile-codeblocks"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("temple")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Blocks size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Antik Tapınak (Dairesel)</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("spiral-tower")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Sparkles size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Spiral Burgu Kule (Döngü)</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("pen-holder")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Box size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Delikli Kalemlik (CSG Boşaltma)</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("gear-set")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Code2 size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Dişli Çark Takımı (Mekanik)</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Arama Kutusu */}
|
||||
<div className="snapcad-dashboard-filter-bar">
|
||||
<div className="snapcad-search-box">
|
||||
<Search size={16} />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Kod blokları projelerinde ara (örn: kule, tapınak, kalemlik, dişli)..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Proje Kartları Izgarası */}
|
||||
<div className="project-grid">
|
||||
{filteredTemplates.map((tpl) => {
|
||||
const shapes = executeCodeblocksToShapes(tpl.blocks);
|
||||
return (
|
||||
<article className="project-card snapcad-project-card" key={tpl.id}>
|
||||
<div className="snapcad-card-banner codeblock">
|
||||
<div className="snapcad-codeblock-grid" />
|
||||
<div className="snapcad-card-icon-badge">
|
||||
<Blocks size={14} />
|
||||
<span>{tpl.blocks.length} Blok</span>
|
||||
</div>
|
||||
<span className="snapcad-card-source-tag">{tpl.badge}</span>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-card-content">
|
||||
<div className="snapcad-card-head">
|
||||
<span className="snapcad-card-dept">Parametrik Model</span>
|
||||
<span className="snapcad-card-std">{shapes.length} 3D Katı</span>
|
||||
</div>
|
||||
<h3 className="snapcad-card-title">{tpl.title}</h3>
|
||||
<p className="snapcad-card-desc">{tpl.description}</p>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-card-footer">
|
||||
<button
|
||||
type="button"
|
||||
className="snapcad-btn-tinker"
|
||||
onClick={() => onOpenProject(tpl.id)}
|
||||
title="Kod Blokları Editöründe Aç"
|
||||
>
|
||||
<Blocks size={16} />
|
||||
<span>Blokları Aç & Düzenle</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="snapcad-btn-ghost-icon"
|
||||
onClick={() => onOpenIn3DEditor(tpl.title, shapes)}
|
||||
title="Bu Modeli Doğrudan 3D Tasarım Editörüne Aktar"
|
||||
>
|
||||
<Box size={16} />
|
||||
<span>3D'ye Aktar</span>
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,216 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Check,
|
||||
CheckCircle2,
|
||||
Clock,
|
||||
Copy,
|
||||
Globe,
|
||||
HelpCircle,
|
||||
Mail,
|
||||
MessageSquare,
|
||||
Users,
|
||||
} from "lucide-react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
interface ContactPageContentProps {
|
||||
onBackToDashboard?: () => void;
|
||||
}
|
||||
|
||||
export function ContactPageContent({ onBackToDashboard }: ContactPageContentProps) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [copyNotice, setCopyNotice] = useState("");
|
||||
const headingRef = useRef<HTMLHeadingElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Sayfa açıldığında ekran okuyucunun doğrudan ana başlığa atlamasını sağla
|
||||
headingRef.current?.focus();
|
||||
}, []);
|
||||
|
||||
const handleCopyEmail = async (email: string) => {
|
||||
try {
|
||||
if (navigator.clipboard) {
|
||||
await navigator.clipboard.writeText(email);
|
||||
} else {
|
||||
const input = document.createElement("input");
|
||||
input.value = email;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(input);
|
||||
}
|
||||
setCopied(true);
|
||||
setCopyNotice(`${email} adresi panoya kopyalandı.`);
|
||||
setTimeout(() => {
|
||||
setCopied(false);
|
||||
setCopyNotice("");
|
||||
}, 3000);
|
||||
} catch {
|
||||
setCopyNotice(`E-posta: ${email}`);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<article className="snapcad-content-page contact-page" aria-labelledby="contact-main-heading">
|
||||
{/* Ekran Okuyucu Canlı Bildirimi */}
|
||||
<div className="sr-only" role="status" aria-live="polite" aria-atomic="true">
|
||||
{copyNotice}
|
||||
</div>
|
||||
|
||||
{/* 1. Başlık Bölümü */}
|
||||
<header className="content-hero contact-hero">
|
||||
<div className="hero-badge">
|
||||
<MessageSquare size={15} aria-hidden="true" />
|
||||
<span>Doğrudan İletişim & Destek</span>
|
||||
</div>
|
||||
<h1
|
||||
id="contact-main-heading"
|
||||
ref={headingRef}
|
||||
tabIndex={-1}
|
||||
className="hero-title outline-none focus:ring-2 focus:ring-sky-500 rounded-md"
|
||||
>
|
||||
Bizimle İletişime Geçin
|
||||
</h1>
|
||||
<p className="hero-lead">
|
||||
SnapCAD Studio ve YakHub ekosistemi hakkında sorularınız, ürün ve özellik önerileriniz,
|
||||
iş birliği veya teknik destek talepleriniz için doğrudan e-posta ile bize ulaşabilirsiniz.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
{/* 2. Doğrudan E-posta Gönderme Alanı */}
|
||||
<div className="contact-main-grid">
|
||||
{/* Sol Sütun: E-posta Gönderim Kartı */}
|
||||
<section className="contact-form-card email-direct-card" aria-labelledby="direct-email-heading">
|
||||
<div className="card-icon-container mission-icon">
|
||||
<Mail size={26} aria-hidden="true" />
|
||||
</div>
|
||||
<h2 id="direct-email-heading" className="form-card-title">
|
||||
Doğrudan E-posta Gönderin
|
||||
</h2>
|
||||
<p className="form-card-subtitle">
|
||||
Mesajlarınızı doğrudan e-posta uygulaması üzerinden hızlıca ve güvenle iletebilirsiniz.
|
||||
Tüm iletiler teknik ve ürün ekibimizce titizlikle değerlendirilir.
|
||||
</p>
|
||||
|
||||
<div className="direct-email-actions">
|
||||
<a
|
||||
href="mailto:[email protected]?subject=SnapCAD%20Studio%20%C4%B0leti%C5%9Fim%20ve%20Destek"
|
||||
className="form-submit-btn direct-email-launch-btn"
|
||||
aria-label="Varsayılan e-posta uygulamanızla [email protected] adresine e-posta gönderin"
|
||||
>
|
||||
<Mail size={18} aria-hidden="true" />
|
||||
<span>E-posta Gönder: iletisim@yakhub.com.tr</span>
|
||||
</a>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="copy-email-action-btn"
|
||||
onClick={() => handleCopyEmail("[email protected]")}
|
||||
aria-label="[email protected] e-posta adresini panoya kopyala"
|
||||
>
|
||||
{copied ? <Check size={16} aria-hidden="true" /> : <Copy size={16} aria-hidden="true" />}
|
||||
<span>{copied ? "Adres Kopyalandı!" : "E-posta Adresini Kopyala"}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="email-meta-box">
|
||||
<span className="email-meta-label">Alternatif Destek Kanalı:</span>
|
||||
<a href="mailto:[email protected]" className="info-link">
|
||||
destek@yakhub.com.tr
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Sağ Sütun: Kurumsal Bilgiler */}
|
||||
<section className="contact-info-column" aria-label="İletişim Bilgileri">
|
||||
<div className="contact-info-card">
|
||||
<div className="info-icon-badge">
|
||||
<Globe size={22} aria-hidden="true" />
|
||||
</div>
|
||||
<div className="info-text">
|
||||
<h3>YakNet Ekosistemi</h3>
|
||||
<p>Geliştirici Konsolu & Merkezi Hesap:</p>
|
||||
<a
|
||||
href="https://developer-console.yakhub.com.tr"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="info-link"
|
||||
>
|
||||
developer-console.yakhub.com.tr
|
||||
</a>
|
||||
<span className="info-meta">Bulut Veritabanı & Tekil Giriş (SSO)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="contact-info-card">
|
||||
<div className="info-icon-badge">
|
||||
<Users size={22} aria-hidden="true" />
|
||||
</div>
|
||||
<div className="info-text">
|
||||
<h3>Kullanıcı Deneyimi & Test Birimi</h3>
|
||||
<p>
|
||||
Mühendisler, mimarlar, öğrenciler ve tasarımcılarla birlikte yürütülen kapsamlı
|
||||
kullanıcı testleri ve evrensel CAD standartları.
|
||||
</p>
|
||||
<span className="info-meta">Standart: Endüstriyel Ergonomi & WCAG 2.1 AAA</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="contact-info-card">
|
||||
<div className="info-icon-badge">
|
||||
<Clock size={22} aria-hidden="true" />
|
||||
</div>
|
||||
<div className="info-text">
|
||||
<h3>Yanıt Süresi</h3>
|
||||
<p>E-posta iletileriniz en geç 24 iş saati içerisinde değerlendirilir.</p>
|
||||
<span className="info-meta">Pazartesi – Cuma: 09:00 - 18:00</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{/* 3. Sıkça Sorulan Sorular (FAQ) */}
|
||||
<section className="contact-faq-section" aria-labelledby="faq-heading">
|
||||
<div className="section-header-pill">
|
||||
<HelpCircle size={16} aria-hidden="true" />
|
||||
<h2 id="faq-heading">Sıkça Sorulan Sorular</h2>
|
||||
</div>
|
||||
|
||||
<div className="faq-grid">
|
||||
<div className="faq-item">
|
||||
<h3>SnapCAD ekran okuyucuyla (NVDA/JAWS) nasıl çalışır?</h3>
|
||||
<p>
|
||||
Geleneksel 3D uygulamaların aksine sahnemiz sadece bir piksel tuvali değildir; her nesne, yüzey
|
||||
ve koordinat ARIA semantiğiyle ekran okuyucuya aktarılır. Yön tuşlarıyla hareket ettirebilir,
|
||||
canlı HUD ile konumunu dinleyebilirsiniz.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="faq-item">
|
||||
<h3>Çizimlerimi 3D yazıcıdan veya CNC tezgahından üretebilir miyim?</h3>
|
||||
<p>
|
||||
Evet. SnapCAD ile tasarlanan tüm modeller doğrudan endüstri standardı .STL, .OBJ, .STEP ve 2B
|
||||
lazer kesim/teknik resim için .DXF ve .PDF formatlarında dışa aktarılabilir.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="faq-item">
|
||||
<h3>Projelerim bulutta nasıl saklanıyor?</h3>
|
||||
<p>
|
||||
Tasarımınız pikseller değil saf matematiksel koordinat paketidir. YakNet Bulut veritabanında
|
||||
yüksek güvenlikli ve optimize edilmiş parametrik vektör yapısında saklanır; hiçbir veri kaybı olmadan cihazlarınızla senkronize olur.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="faq-item">
|
||||
<h3>SnapCAD ticari veya eğitim amaçlı ücretsiz mi?</h3>
|
||||
<p>
|
||||
Evet, SnapCAD açık kaynak (AGPLv3) vizyonuyla ve YakNet ekosistemi altyapısıyla tüm öğrencilere,
|
||||
eğitmenlere, mühendislere ve tüm tasarımcılara açıktır.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,535 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Award,
|
||||
CheckCircle2,
|
||||
ChevronRight,
|
||||
Flame,
|
||||
Footprints,
|
||||
Play,
|
||||
RotateCcw,
|
||||
Sparkles,
|
||||
Trophy,
|
||||
Volume2,
|
||||
X,
|
||||
Zap,
|
||||
} from "lucide-react";
|
||||
import { soundEngine } from "@/lib/audioFx";
|
||||
import { triggerCelebrationConfetti } from "@/lib/fxSystem";
|
||||
|
||||
export interface QuestItem {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
category: "architecture" | "informatics" | "exploration" | "style";
|
||||
categoryLabel: string;
|
||||
xp: number;
|
||||
completed: boolean;
|
||||
actionText?: string;
|
||||
actionType?: "load_domino" | "load_villa" | "start_walk" | "blueprint";
|
||||
}
|
||||
|
||||
export interface BadgeItem {
|
||||
id: string;
|
||||
name: string;
|
||||
desc: string;
|
||||
icon: string;
|
||||
unlocked: boolean;
|
||||
}
|
||||
|
||||
const INITIAL_QUESTS: QuestItem[] = [
|
||||
{
|
||||
id: "quest-architectural-room",
|
||||
title: "Pencereli Modern Bir Mekân Kur",
|
||||
description: "Çalışma alanına bir duvar bloğu koy ve Duvar Açıklığı aracıyla gün ışığı alan bir pencere aç.",
|
||||
category: "architecture",
|
||||
categoryLabel: "Mimarlık Görevi",
|
||||
xp: 150,
|
||||
completed: false,
|
||||
actionText: "Hazır Villa Şablonu",
|
||||
actionType: "load_villa",
|
||||
},
|
||||
{
|
||||
id: "quest-domino-physics",
|
||||
title: "Domino Fizik Parkurunu Devir",
|
||||
description: "İnteraktif domino parkurunu ekle ve fizik simülasyonunu başlatarak zincirleme reaksiyonu izle.",
|
||||
category: "informatics",
|
||||
categoryLabel: "Bilişim & Fizik",
|
||||
xp: 200,
|
||||
completed: false,
|
||||
actionText: "Domino Parkuru Ekle",
|
||||
actionType: "load_domino",
|
||||
},
|
||||
{
|
||||
id: "quest-walkthrough-explore",
|
||||
title: "1. Şahıs (WASD) Mimari Gezinti Yap",
|
||||
description: "Yürüme moduna geç (Ayak İzi ikonu) ve tasarladığın yapının içinde insan gözü hizasında 10 adım at.",
|
||||
category: "exploration",
|
||||
categoryLabel: "Keşif & Walkthrough",
|
||||
xp: 120,
|
||||
completed: false,
|
||||
actionText: "Gezintiyi Başlat",
|
||||
actionType: "start_walk",
|
||||
},
|
||||
{
|
||||
id: "quest-blueprint-style",
|
||||
title: "Mimari Ozalit (Blueprint) Moduna Geç",
|
||||
description: "Görsel render stillerinden klasik mimari mavi ozalit modunu seçerek teknik çizim estetiğini dene.",
|
||||
category: "style",
|
||||
categoryLabel: "Görsel & Render",
|
||||
xp: 100,
|
||||
completed: false,
|
||||
actionText: "Ozalit Modu",
|
||||
actionType: "blueprint",
|
||||
},
|
||||
];
|
||||
|
||||
const INITIAL_BADGES: BadgeItem[] = [
|
||||
{ id: "b1", name: "Çırak Mimar", desc: "İlk 3D şeklini başarıyla yerleştirdin.", icon: "🏛️", unlocked: true },
|
||||
{ id: "b2", name: "Zincir Reaksiyon", desc: "Fizik simülasyonuyla dominoları devirdin.", icon: "⚡", unlocked: false },
|
||||
{ id: "b3", name: "Mekân Kaşifi", desc: "1. Şahıs modunda binanın içinde yürüdün.", icon: "🚶", unlocked: false },
|
||||
{ id: "b4", name: "Teknik Ressam", desc: "Blueprint ozalit render stilini kullandın.", icon: "📐", unlocked: false },
|
||||
{ id: "b5", name: "Kod & Devre Ustası", desc: "Arduino veya blok kodlama stüdyosunu açtın.", icon: "💻", unlocked: true },
|
||||
{ id: "b6", name: "CAD Virtüözü", desc: "Tüm günlük görevleri başarıyla bitirdin.", icon: "👑", unlocked: false },
|
||||
];
|
||||
|
||||
const LEVEL_TITLES = [
|
||||
"Çaylak Tasarımcı",
|
||||
"3D Model Çırağı",
|
||||
"Bilişim & Maker Mimarı",
|
||||
"Kıdemli Mekân Tasarımcısı",
|
||||
"Baş Mimar & CAD Efsanesi",
|
||||
];
|
||||
|
||||
interface DailyChallengesModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onActionTrigger?: (action: "load_domino" | "load_villa" | "start_walk" | "blueprint") => void;
|
||||
}
|
||||
|
||||
export function DailyChallengesModal({
|
||||
isOpen,
|
||||
onClose,
|
||||
onActionTrigger,
|
||||
}: DailyChallengesModalProps) {
|
||||
const [xp, setXp] = useState<number>(320);
|
||||
const [streakDays, setStreakDays] = useState<number>(3);
|
||||
const [quests, setQuests] = useState<QuestItem[]>(INITIAL_QUESTS);
|
||||
const [badges, setBadges] = useState<BadgeItem[]>(INITIAL_BADGES);
|
||||
|
||||
// LocalStorage yükle
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
try {
|
||||
const saved = localStorage.getItem("snapcad_gamification_v1");
|
||||
if (saved) {
|
||||
const parsed = JSON.parse(saved);
|
||||
if (typeof parsed.xp === "number") setXp(parsed.xp);
|
||||
if (typeof parsed.streakDays === "number") setStreakDays(parsed.streakDays);
|
||||
if (Array.isArray(parsed.quests)) setQuests(parsed.quests);
|
||||
if (Array.isArray(parsed.badges)) setBadges(parsed.badges);
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}, []);
|
||||
|
||||
const saveGamification = (newXp: number, newQuests: QuestItem[], newBadges: BadgeItem[]) => {
|
||||
if (typeof window === "undefined") return;
|
||||
try {
|
||||
localStorage.setItem(
|
||||
"snapcad_gamification_v1",
|
||||
JSON.stringify({ xp: newXp, streakDays, quests: newQuests, badges: newBadges }),
|
||||
);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
};
|
||||
|
||||
const level = Math.min(LEVEL_TITLES.length, Math.floor(xp / 250) + 1);
|
||||
const currentLevelTitle = LEVEL_TITLES[level - 1] || "CAD Ustası";
|
||||
const xpInCurrentLevel = xp % 250;
|
||||
const xpNeeded = 250;
|
||||
const progressPercent = Math.min(100, Math.round((xpInCurrentLevel / xpNeeded) * 100));
|
||||
|
||||
const handleClaimQuest = (questId: string) => {
|
||||
const target = quests.find((q) => q.id === questId);
|
||||
if (!target || target.completed) return;
|
||||
|
||||
soundEngine.playCelebration();
|
||||
triggerCelebrationConfetti("cannons");
|
||||
|
||||
const updatedQuests = quests.map((q) =>
|
||||
q.id === questId ? { ...q, completed: true } : q,
|
||||
);
|
||||
const newXp = xp + target.xp;
|
||||
setXp(newXp);
|
||||
setQuests(updatedQuests);
|
||||
|
||||
// Bütün görevler bitti mi?
|
||||
const allDone = updatedQuests.every((q) => q.completed);
|
||||
const updatedBadges = badges.map((b) => {
|
||||
if (allDone && b.id === "b6") return { ...b, unlocked: true };
|
||||
if (questId === "quest-domino-physics" && b.id === "b2") return { ...b, unlocked: true };
|
||||
if (questId === "quest-walkthrough-explore" && b.id === "b3") return { ...b, unlocked: true };
|
||||
if (questId === "quest-blueprint-style" && b.id === "b4") return { ...b, unlocked: true };
|
||||
return b;
|
||||
});
|
||||
setBadges(updatedBadges);
|
||||
saveGamification(newXp, updatedQuests, updatedBadges);
|
||||
};
|
||||
|
||||
const handleQuickAction = (actionType?: "load_domino" | "load_villa" | "start_walk" | "blueprint") => {
|
||||
if (!actionType) return;
|
||||
onClose();
|
||||
onActionTrigger?.(actionType);
|
||||
};
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: "fixed",
|
||||
inset: 0,
|
||||
zIndex: 9999,
|
||||
background: "rgba(15, 23, 42, 0.72)",
|
||||
backdropFilter: "blur(6px)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
padding: "16px",
|
||||
}}
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget) onClose();
|
||||
}}
|
||||
>
|
||||
<div
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="gamification-modal-title"
|
||||
style={{
|
||||
width: "100%",
|
||||
maxWidth: "720px",
|
||||
maxHeight: "90vh",
|
||||
overflowY: "auto",
|
||||
background: "#0f172a",
|
||||
color: "#f8fafc",
|
||||
borderRadius: "20px",
|
||||
border: "1px solid #1e293b",
|
||||
boxShadow: "0 25px 60px rgba(0,0,0,0.6)",
|
||||
padding: "24px",
|
||||
}}
|
||||
>
|
||||
{/* Başlık ve Kapat Butonu */}
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
borderBottom: "1px solid #1e293b",
|
||||
paddingBottom: "16px",
|
||||
marginBottom: "20px",
|
||||
}}
|
||||
>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "12px" }}>
|
||||
<div
|
||||
style={{
|
||||
width: "44px",
|
||||
height: "44px",
|
||||
borderRadius: "12px",
|
||||
background: "linear-gradient(135deg, #f59e0b, #ef4444)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
boxShadow: "0 4px 12px rgba(245, 158, 11, 0.35)",
|
||||
}}
|
||||
>
|
||||
<Trophy size={24} color="#fff" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 id="gamification-modal-title" style={{ margin: 0, fontSize: "18px", fontWeight: 800 }}>
|
||||
Günün 3D Görevleri & Başarımlar
|
||||
</h2>
|
||||
<p style={{ margin: "2px 0 0", fontSize: "13px", color: "#94a3b8" }}>
|
||||
Mimarlık ve Bilişim görevlerini tamamla, XP kazan ve özel rozetlerin kilidini aç!
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label="Pencereyi kapat"
|
||||
style={{
|
||||
background: "#1e293b",
|
||||
border: "none",
|
||||
color: "#94a3b8",
|
||||
borderRadius: "8px",
|
||||
padding: "8px",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
<X size={18} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Kullanıcı Seviye & XP Kartı */}
|
||||
<div
|
||||
style={{
|
||||
background: "linear-gradient(135deg, #1e293b, #0f172a)",
|
||||
border: "1px solid rgba(59, 130, 246, 0.3)",
|
||||
borderRadius: "16px",
|
||||
padding: "16px 20px",
|
||||
marginBottom: "20px",
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
gap: "16px",
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "8px", marginBottom: "4px" }}>
|
||||
<span
|
||||
style={{
|
||||
background: "#2563eb",
|
||||
color: "#fff",
|
||||
fontSize: "11px",
|
||||
fontWeight: 800,
|
||||
padding: "2px 8px",
|
||||
borderRadius: "999px",
|
||||
}}
|
||||
>
|
||||
SEVİYE {level}
|
||||
</span>
|
||||
<strong style={{ fontSize: "16px", color: "#60a5fa" }}>{currentLevelTitle}</strong>
|
||||
<span
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: "4px",
|
||||
background: "rgba(245, 158, 11, 0.15)",
|
||||
color: "#f59e0b",
|
||||
padding: "2px 8px",
|
||||
borderRadius: "999px",
|
||||
fontSize: "11px",
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
<Flame size={13} /> {streakDays} Günlük Seri!
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: "12.5px", color: "#cbd5e1" }}>
|
||||
Toplam: <strong style={{ color: "#38bdf8" }}>{xp} XP</strong> • Sonraki Seviye: {xpNeeded - xpInCurrentLevel} XP kaldı
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ width: "220px" }}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
fontSize: "11.5px",
|
||||
color: "#94a3b8",
|
||||
marginBottom: "4px",
|
||||
}}
|
||||
>
|
||||
<span>İlerleme</span>
|
||||
<span>%{progressPercent}</span>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "8px",
|
||||
background: "#334155",
|
||||
borderRadius: "999px",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: `${progressPercent}%`,
|
||||
height: "100%",
|
||||
background: "linear-gradient(90deg, #3b82f6, #10b981)",
|
||||
borderRadius: "999px",
|
||||
transition: "width 0.4s ease",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Görevler Listesi */}
|
||||
<div style={{ marginBottom: "22px" }}>
|
||||
<h3 style={{ fontSize: "14.5px", fontWeight: 700, color: "#e2e8f0", margin: "0 0 12px 2px" }}>
|
||||
🎯 Günün Görevleri
|
||||
</h3>
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: "10px" }}>
|
||||
{quests.map((quest) => (
|
||||
<div
|
||||
key={quest.id}
|
||||
style={{
|
||||
background: quest.completed ? "rgba(16, 185, 129, 0.08)" : "#1e293b",
|
||||
border: quest.completed
|
||||
? "1px solid rgba(16, 185, 129, 0.35)"
|
||||
: "1px solid rgba(148, 163, 184, 0.15)",
|
||||
borderRadius: "14px",
|
||||
padding: "14px 16px",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
gap: "14px",
|
||||
transition: "all 0.2s ease",
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: 1 }}>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "8px", marginBottom: "4px" }}>
|
||||
<span
|
||||
style={{
|
||||
fontSize: "10.5px",
|
||||
fontWeight: 700,
|
||||
padding: "2px 7px",
|
||||
borderRadius: "6px",
|
||||
background:
|
||||
quest.category === "architecture"
|
||||
? "rgba(16, 185, 129, 0.2)"
|
||||
: quest.category === "informatics"
|
||||
? "rgba(245, 158, 11, 0.2)"
|
||||
: quest.category === "exploration"
|
||||
? "rgba(59, 130, 246, 0.2)"
|
||||
: "rgba(139, 92, 246, 0.2)",
|
||||
color:
|
||||
quest.category === "architecture"
|
||||
? "#34d399"
|
||||
: quest.category === "informatics"
|
||||
? "#fbbf24"
|
||||
: quest.category === "exploration"
|
||||
? "#60a5fa"
|
||||
: "#c084fc",
|
||||
}}
|
||||
>
|
||||
{quest.categoryLabel}
|
||||
</span>
|
||||
<strong style={{ fontSize: "14px", color: quest.completed ? "#94a3b8" : "#f8fafc" }}>
|
||||
{quest.title}
|
||||
</strong>
|
||||
<span
|
||||
style={{
|
||||
fontSize: "11.5px",
|
||||
fontWeight: 700,
|
||||
color: "#fbbf24",
|
||||
marginLeft: "auto",
|
||||
}}
|
||||
>
|
||||
+{quest.xp} XP
|
||||
</span>
|
||||
</div>
|
||||
<p style={{ margin: 0, fontSize: "12.5px", color: "#94a3b8" }}>{quest.description}</p>
|
||||
</div>
|
||||
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
|
||||
{quest.actionText ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleQuickAction(quest.actionType)}
|
||||
style={{
|
||||
background: "#334155",
|
||||
color: "#e2e8f0",
|
||||
border: "none",
|
||||
borderRadius: "8px",
|
||||
padding: "7px 11px",
|
||||
fontSize: "12px",
|
||||
fontWeight: 600,
|
||||
cursor: "pointer",
|
||||
whiteSpace: "nowrap",
|
||||
}}
|
||||
>
|
||||
{quest.actionText}
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
{quest.completed ? (
|
||||
<span
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: "5px",
|
||||
color: "#34d399",
|
||||
fontWeight: 700,
|
||||
fontSize: "12px",
|
||||
padding: "6px 12px",
|
||||
}}
|
||||
>
|
||||
<CheckCircle2 size={16} /> Tamamlandı
|
||||
</span>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleClaimQuest(quest.id)}
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: "5px",
|
||||
background: "linear-gradient(135deg, #10b981, #059669)",
|
||||
color: "#fff",
|
||||
border: "none",
|
||||
borderRadius: "8px",
|
||||
padding: "7px 13px",
|
||||
fontSize: "12px",
|
||||
fontWeight: 700,
|
||||
cursor: "pointer",
|
||||
whiteSpace: "nowrap",
|
||||
boxShadow: "0 2px 8px rgba(16, 185, 129, 0.3)",
|
||||
}}
|
||||
>
|
||||
<Sparkles size={14} /> Ödülü Al
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Rozetler Grid'i */}
|
||||
<div>
|
||||
<h3 style={{ fontSize: "14.5px", fontWeight: 700, color: "#e2e8f0", margin: "0 0 12px 2px" }}>
|
||||
🎖️ Başarım Rozetleri
|
||||
</h3>
|
||||
<div
|
||||
style={{
|
||||
display: "grid",
|
||||
gridTemplateColumns: "repeat(auto-fit, minmax(100px, 1fr))",
|
||||
gap: "10px",
|
||||
}}
|
||||
>
|
||||
{badges.map((b) => (
|
||||
<div
|
||||
key={b.id}
|
||||
style={{
|
||||
background: b.unlocked ? "rgba(30, 41, 59, 0.85)" : "rgba(15, 23, 42, 0.5)",
|
||||
border: b.unlocked
|
||||
? "1px solid rgba(245, 158, 11, 0.4)"
|
||||
: "1px dashed rgba(148, 163, 184, 0.2)",
|
||||
borderRadius: "12px",
|
||||
padding: "12px 8px",
|
||||
textAlign: "center",
|
||||
opacity: b.unlocked ? 1 : 0.45,
|
||||
}}
|
||||
>
|
||||
<div style={{ fontSize: "24px", marginBottom: "4px" }}>{b.icon}</div>
|
||||
<div style={{ fontSize: "11.5px", fontWeight: 700, color: b.unlocked ? "#f8fafc" : "#64748b" }}>
|
||||
{b.name}
|
||||
</div>
|
||||
<div style={{ fontSize: "10px", color: "#94a3b8", marginTop: "2px", lineHeight: "1.2" }}>
|
||||
{b.desc}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
"use client";
|
||||
|
||||
import { Box, Compass, Crosshair, Eye, Grid3X3, Layers, Maximize2, MoveRight, Ruler } from "lucide-react";
|
||||
import { useCallback, useEffect, useRef, useState, type ChangeEvent, type KeyboardEvent } from "react";
|
||||
import type { GridSize } from "@/types/sketchforge";
|
||||
|
||||
export type DirectModelingToolMode = "select" | "push-pull" | "face-sketch" | "measure";
|
||||
|
||||
export interface PrecisionBarData {
|
||||
cursorX: number;
|
||||
cursorY: number;
|
||||
cursorZ: number;
|
||||
activeFaceInfo?: {
|
||||
shapeName: string;
|
||||
normal: { x: number; y: number; z: number };
|
||||
areaMm2?: number;
|
||||
} | null;
|
||||
currentValue?: number | null;
|
||||
valueUnit?: string;
|
||||
valueLabel?: string;
|
||||
isDragging?: boolean;
|
||||
}
|
||||
|
||||
interface EnterprisePrecisionBarProps {
|
||||
data: PrecisionBarData;
|
||||
activeTool: DirectModelingToolMode;
|
||||
onToolChange?: (tool: DirectModelingToolMode) => void;
|
||||
snapGrid: GridSize;
|
||||
onSnapGridChange?: (size: GridSize) => void;
|
||||
isOrthographic?: boolean;
|
||||
onToggleProjection?: () => void;
|
||||
onResetView?: () => void;
|
||||
onSetCameraView?: (face: "top" | "front" | "right" | "isometric") => void;
|
||||
onCommitValue?: (value: number) => void;
|
||||
unitLabel?: string;
|
||||
className?: string;
|
||||
axisLock?: "x" | "z" | null;
|
||||
}
|
||||
|
||||
const SNAP_OPTIONS: GridSize[] = ["0.1 mm", "0.25 mm", "0.5 mm", "1.0 mm", "2.0 mm", "5.0 mm", "Off"];
|
||||
|
||||
export function EnterprisePrecisionBar({
|
||||
data,
|
||||
activeTool,
|
||||
onToolChange,
|
||||
snapGrid,
|
||||
onSnapGridChange,
|
||||
isOrthographic = false,
|
||||
onToggleProjection,
|
||||
onResetView,
|
||||
onSetCameraView,
|
||||
onCommitValue,
|
||||
unitLabel = "mm",
|
||||
className = "",
|
||||
axisLock = null,
|
||||
}: EnterprisePrecisionBarProps) {
|
||||
const [inputValue, setInputValue] = useState<string>("");
|
||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||
|
||||
// Sync input value with live distance during dragging if user hasn't focused it
|
||||
useEffect(() => {
|
||||
if (data.currentValue !== undefined && data.currentValue !== null) {
|
||||
if (document.activeElement !== inputRef.current) {
|
||||
setInputValue(data.currentValue.toFixed(2));
|
||||
}
|
||||
} else if (!data.isDragging && document.activeElement !== inputRef.current) {
|
||||
setInputValue("");
|
||||
}
|
||||
}, [data.currentValue, data.isDragging]);
|
||||
|
||||
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
setInputValue(e.target.value);
|
||||
};
|
||||
|
||||
const handleInputKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
const num = parseFloat(inputValue.replace(",", "."));
|
||||
if (!Number.isNaN(num)) {
|
||||
onCommitValue?.(num);
|
||||
inputRef.current?.blur();
|
||||
}
|
||||
} else if (e.key === "Escape") {
|
||||
inputRef.current?.blur();
|
||||
setInputValue(data.currentValue !== undefined && data.currentValue !== null ? data.currentValue.toFixed(2) : "");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<footer
|
||||
className={`enterprise-precision-bar ${className}`}
|
||||
role="region"
|
||||
aria-label="Hassas Çizim ve Durum Çubuğu (Precision HUD)"
|
||||
>
|
||||
{/* 1. Sol Kısım: Araç Modu ve Yüzey Rozeti */}
|
||||
<div className="precision-group tools-group">
|
||||
<button
|
||||
type="button"
|
||||
className={`precision-pill-btn ${activeTool === "select" ? "active" : ""}`}
|
||||
onClick={() => onToolChange?.("select")}
|
||||
title="Standart Seçim Modu (Space)"
|
||||
aria-pressed={activeTool === "select"}
|
||||
>
|
||||
<Box size={14} className="icon" aria-hidden="true" />
|
||||
<span>3B Katı CAD</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className={`precision-pill-btn highlight-push-pull ${activeTool === "push-pull" ? "active" : ""}`}
|
||||
onClick={() => onToolChange?.("push-pull")}
|
||||
title="SketchUp Tarzı İt / Çek (Push/Pull - P)"
|
||||
aria-pressed={activeTool === "push-pull"}
|
||||
>
|
||||
<MoveRight size={14} className="icon" aria-hidden="true" />
|
||||
<span>İt / Çek (Push/Pull)</span>
|
||||
</button>
|
||||
|
||||
{data.activeFaceInfo ? (
|
||||
<span className="face-indicator-badge" title="Algılanan Yüzey Normali">
|
||||
<span className="dot" />
|
||||
<span className="name">{data.activeFaceInfo.shapeName}</span>
|
||||
<span className="normal font-mono">
|
||||
N({data.activeFaceInfo.normal.x.toFixed(1)}, {data.activeFaceInfo.normal.y.toFixed(1)}, {data.activeFaceInfo.normal.z.toFixed(1)})
|
||||
</span>
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{/* 2. Orta Kısım: VCB (Value Control Box - Hassas Ölçü Girişi) & Koordinatlar */}
|
||||
<div className="precision-group vcb-coords-group">
|
||||
{/* Canlı Koordinatlar */}
|
||||
<div className="live-coords-hud" title="İmleç Dünyası Koordinatları">
|
||||
<Crosshair size={13} className="text-sky-400" aria-hidden="true" />
|
||||
<span className="coord-item">
|
||||
<strong className="text-rose-400">X:</strong> {data.cursorX.toFixed(2)}
|
||||
</span>
|
||||
<span className="coord-item">
|
||||
<strong className="text-emerald-400">Y:</strong> {data.cursorY.toFixed(2)}
|
||||
</span>
|
||||
<span className="coord-item">
|
||||
<strong className="text-sky-400">Z:</strong> {data.cursorZ.toFixed(2)} {unitLabel}
|
||||
</span>
|
||||
{axisLock ? (
|
||||
<span
|
||||
style={{
|
||||
marginLeft: "8px",
|
||||
padding: "1px 6px",
|
||||
borderRadius: "4px",
|
||||
fontSize: "11px",
|
||||
fontWeight: 700,
|
||||
background: axisLock === "x" ? "rgba(239, 68, 68, 0.25)" : "rgba(34, 197, 94, 0.25)",
|
||||
color: axisLock === "x" ? "#f87171" : "#4ade80",
|
||||
border: `1px solid ${axisLock === "x" ? "#ef4444" : "#22c55e"}`,
|
||||
}}
|
||||
title="Eksen Kilidi (Açmak için Aşağı Ok'a basın)"
|
||||
>
|
||||
{axisLock === "x" ? "🔴 X Kilitli" : "🟢 Z Kilitli"}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{/* Değer Kontrol Kutusu (VCB) */}
|
||||
<div className="vcb-input-box" title="Değer Kontrol Kutusu: Bir sayı yazıp Enter'a basarak doğrudan ölçülendirin">
|
||||
<label htmlFor="precision-vcb-input" className="vcb-label">
|
||||
<Ruler size={13} aria-hidden="true" />
|
||||
<span>{data.valueLabel || "Ölçü"}:</span>
|
||||
</label>
|
||||
<div className="vcb-input-wrap">
|
||||
<input
|
||||
id="precision-vcb-input"
|
||||
ref={inputRef}
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
className="vcb-field font-mono"
|
||||
placeholder={data.isDragging ? "Ölçü yazın..." : "0.00"}
|
||||
value={inputValue}
|
||||
onChange={handleInputChange}
|
||||
onKeyDown={handleInputKeyDown}
|
||||
aria-label={`${data.valueLabel || "Ölçü"} değeri milimetre cinsinden`}
|
||||
/>
|
||||
<span className="unit-suffix font-mono">{unitLabel}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 3. Sağ Kısım: Manyetik Izgara ve Kamera Kontrolleri */}
|
||||
<div className="precision-group camera-grid-group">
|
||||
{/* Izgara Adımı Seçici */}
|
||||
<div className="grid-selector-wrap" title="Manyetik Izgara Adımı">
|
||||
<Grid3X3 size={13} className="text-slate-400" aria-hidden="true" />
|
||||
<select
|
||||
className="grid-select font-mono"
|
||||
value={snapGrid}
|
||||
onChange={(e) => onSnapGridChange?.(e.target.value as GridSize)}
|
||||
aria-label="Manyetik Izgara Adımı"
|
||||
>
|
||||
{SNAP_OPTIONS.map((opt) => (
|
||||
<option key={opt} value={opt}>
|
||||
{opt === "Off" ? "Izgara Kapalı" : `${opt} mm`}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="divider-vert" />
|
||||
|
||||
{/* Kamera Projeksiyonu (Perspektif / Ortografik) */}
|
||||
<button
|
||||
type="button"
|
||||
className={`camera-mode-btn ${isOrthographic ? "ortho" : "persp"}`}
|
||||
onClick={onToggleProjection}
|
||||
title={isOrthographic ? "Perspektif Görünüme Geç" : "Ortografik (Teknik CAD) Görünüme Geç"}
|
||||
aria-label={isOrthographic ? "Ortografik Görünüm Aktif" : "Perspektif Görünüm Aktif"}
|
||||
>
|
||||
<Eye size={13} aria-hidden="true" />
|
||||
<span>{isOrthographic ? "Ortografik" : "Perspektif"}</span>
|
||||
</button>
|
||||
|
||||
{/* Hızlı Bakış Açısı Butonları */}
|
||||
<div className="quick-views-group">
|
||||
<button
|
||||
type="button"
|
||||
className="view-btn"
|
||||
onClick={() => onSetCameraView?.("top")}
|
||||
title="Üst Görünüm (5)"
|
||||
aria-label="Üstten Bak"
|
||||
>
|
||||
Üst
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="view-btn"
|
||||
onClick={() => onSetCameraView?.("front")}
|
||||
title="Ön Görünüm (1)"
|
||||
aria-label="Önden Bak"
|
||||
>
|
||||
Ön
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="view-btn"
|
||||
onClick={() => onSetCameraView?.("isometric")}
|
||||
title="İzometrik Görünüm (Home)"
|
||||
aria-label="İzometrik Bak"
|
||||
>
|
||||
<Compass size={12} aria-hidden="true" />
|
||||
<span className="hidden sm:inline">İzometrik</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Activity,
|
||||
ArrowLeft,
|
||||
Blocks,
|
||||
Box,
|
||||
CheckCircle2,
|
||||
ChevronDown,
|
||||
Cpu,
|
||||
Download,
|
||||
FileCode,
|
||||
FileDown,
|
||||
FileUp,
|
||||
FolderOpen,
|
||||
GraduationCap,
|
||||
Layers,
|
||||
MoveRight,
|
||||
Pencil,
|
||||
Redo2,
|
||||
RotateCcw,
|
||||
Ruler,
|
||||
Settings,
|
||||
Smartphone,
|
||||
Sparkles,
|
||||
Trophy,
|
||||
Undo2,
|
||||
SlidersHorizontal,
|
||||
} from "lucide-react";
|
||||
import { useEffect, useRef, useState, type ChangeEvent, type KeyboardEvent, type ReactNode } from "react";
|
||||
import type { AppThemePreference } from "@/lib/appTheme";
|
||||
|
||||
export type EnterpriseStudioMode = "3d-solid" | "push-pull" | "drawing" | "circuits" | "codeblocks" | "challenges";
|
||||
|
||||
interface EnterpriseTopBarProps {
|
||||
projectName: string;
|
||||
onProjectNameChange?: (name: string) => void;
|
||||
activeStudio: EnterpriseStudioMode;
|
||||
onStudioChange: (studio: EnterpriseStudioMode) => void;
|
||||
onBackToDashboard?: () => void;
|
||||
canUndo?: boolean;
|
||||
canRedo?: boolean;
|
||||
onUndo?: () => void;
|
||||
onRedo?: () => void;
|
||||
onImport?: () => void;
|
||||
onExport?: () => void;
|
||||
onOpenAR?: () => void;
|
||||
onStructuralTest?: () => void;
|
||||
onCelebration?: () => void;
|
||||
onOpenTutorial?: () => void;
|
||||
onOpenDailyChallenges?: () => void;
|
||||
onOpenSettings?: () => void;
|
||||
onOpenA11y?: () => void;
|
||||
cloudBarSlot?: ReactNode;
|
||||
cloudSyncStatus?: "synced" | "syncing" | "offline" | "error";
|
||||
lastSyncedText?: string;
|
||||
isDashboard?: boolean;
|
||||
}
|
||||
|
||||
export function EnterpriseTopBar({
|
||||
projectName,
|
||||
onProjectNameChange,
|
||||
activeStudio,
|
||||
onStudioChange,
|
||||
onBackToDashboard,
|
||||
canUndo = false,
|
||||
canRedo = false,
|
||||
onUndo,
|
||||
onRedo,
|
||||
onImport,
|
||||
onExport,
|
||||
onOpenAR,
|
||||
onStructuralTest,
|
||||
onCelebration,
|
||||
onOpenTutorial,
|
||||
onOpenDailyChallenges,
|
||||
onOpenSettings,
|
||||
onOpenA11y,
|
||||
cloudBarSlot,
|
||||
cloudSyncStatus = "synced",
|
||||
lastSyncedText = "Az önce eşitlendi",
|
||||
isDashboard = false,
|
||||
}: EnterpriseTopBarProps) {
|
||||
const [editingTitle, setEditingTitle] = useState(false);
|
||||
const [titleDraft, setTitleDraft] = useState(projectName);
|
||||
const titleInputRef = useRef<HTMLInputElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setTitleDraft(projectName);
|
||||
}, [projectName]);
|
||||
|
||||
const handleStartTitleEdit = () => {
|
||||
setEditingTitle(true);
|
||||
setTimeout(() => titleInputRef.current?.focus(), 50);
|
||||
};
|
||||
|
||||
const handleCommitTitle = () => {
|
||||
setEditingTitle(false);
|
||||
const trimmed = titleDraft.trim();
|
||||
if (trimmed && trimmed !== projectName) {
|
||||
onProjectNameChange?.(trimmed);
|
||||
} else {
|
||||
setTitleDraft(projectName);
|
||||
}
|
||||
};
|
||||
|
||||
const handleTitleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.key === "Enter") {
|
||||
handleCommitTitle();
|
||||
} else if (e.key === "Escape") {
|
||||
setEditingTitle(false);
|
||||
setTitleDraft(projectName);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<header className="enterprise-topbar" role="banner" aria-label="SnapCAD Studio Başlık Çubuğu">
|
||||
{/* 1. Sol: Marka ve Proje Başlığı */}
|
||||
<div className="topbar-section left-section">
|
||||
{onBackToDashboard ? (
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-icon-btn back-btn"
|
||||
onClick={onBackToDashboard}
|
||||
title="Ana Sayfaya Dön"
|
||||
aria-label="SnapCAD Studio Paneline Dön"
|
||||
>
|
||||
<ArrowLeft size={18} aria-hidden="true" />
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
<a href="./" className="enterprise-brand" aria-label="SnapCAD Studio">
|
||||
<div className="brand-logo-gem" aria-hidden="true">
|
||||
<Box size={18} className="text-white" />
|
||||
</div>
|
||||
<div className="brand-text-col">
|
||||
<span className="brand-title">
|
||||
SnapCAD <span className="text-sky-400 font-bold">Studio</span>
|
||||
</span>
|
||||
<span className="brand-subtitle uppercase">YakHub Kurumsal Tasarım Platformu</span>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
{!isDashboard ? (
|
||||
<div className="project-title-cluster">
|
||||
<div className="divider-vert" />
|
||||
{editingTitle ? (
|
||||
<input
|
||||
ref={titleInputRef}
|
||||
type="text"
|
||||
className="project-title-input font-semibold"
|
||||
value={titleDraft}
|
||||
onChange={(e) => setTitleDraft(e.target.value)}
|
||||
onBlur={handleCommitTitle}
|
||||
onKeyDown={handleTitleKeyDown}
|
||||
maxLength={80}
|
||||
aria-label="Proje Adını Düzenle"
|
||||
/>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
className="project-title-display-btn"
|
||||
onClick={handleStartTitleEdit}
|
||||
title="Proje Adını Değiştirmek İçin Tıklayın"
|
||||
aria-label={`Proje Adı: ${projectName}. Düzenlemek için tıklayın`}
|
||||
>
|
||||
<span className="title-text truncate max-w-[180px] sm:max-w-[260px]">{projectName}</span>
|
||||
<Pencil size={12} className="edit-icon text-slate-400 opacity-60" aria-hidden="true" />
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* Bulut Durumu İndikatörü */}
|
||||
<div
|
||||
className={`cloud-sync-badge ${cloudSyncStatus}`}
|
||||
title="Bulut Senkronizasyonu: Güncel"
|
||||
role="status"
|
||||
aria-label="Bulut Senkronizasyonu Güncel"
|
||||
>
|
||||
<span className="sync-pulse" aria-hidden="true" />
|
||||
<span className="sync-label hidden lg:inline">Eşitlendi</span>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{/* 2. Orta: Stüdyo Değiştirici Sekmeler (Studio Switcher Pills) */}
|
||||
<nav className="topbar-section center-section" aria-label="SnapCAD Studio Stüdyoları">
|
||||
<div className="studio-switcher-pills" role="tablist">
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={activeStudio === "3d-solid"}
|
||||
className={`studio-pill ${activeStudio === "3d-solid" ? "active" : ""}`}
|
||||
onClick={() => onStudioChange("3d-solid")}
|
||||
title="3D Katı CAD"
|
||||
>
|
||||
<Box size={14} aria-hidden="true" />
|
||||
<span>3D Katı CAD</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={activeStudio === "push-pull"}
|
||||
className={`studio-pill highlight-sketchup ${activeStudio === "push-pull" ? "active" : ""}`}
|
||||
onClick={() => onStudioChange("push-pull")}
|
||||
title="İt / Çek (Push/Pull)"
|
||||
>
|
||||
<MoveRight size={14} aria-hidden="true" />
|
||||
<span>İt / Çek</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={activeStudio === "drawing"}
|
||||
className={`studio-pill ${activeStudio === "drawing" ? "active" : ""}`}
|
||||
onClick={() => onStudioChange("drawing")}
|
||||
title="Teknik Resim"
|
||||
>
|
||||
<Ruler size={14} aria-hidden="true" />
|
||||
<span>Teknik Resim</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={activeStudio === "circuits"}
|
||||
className={`studio-pill ${activeStudio === "circuits" ? "active" : ""}`}
|
||||
onClick={() => onStudioChange("circuits")}
|
||||
title="Elektronik Devreler"
|
||||
>
|
||||
<Cpu size={14} aria-hidden="true" />
|
||||
<span>Devreler</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={activeStudio === "codeblocks"}
|
||||
className={`studio-pill ${activeStudio === "codeblocks" ? "active" : ""}`}
|
||||
onClick={() => onStudioChange("codeblocks")}
|
||||
title="Kod Blokları"
|
||||
>
|
||||
<Blocks size={14} aria-hidden="true" />
|
||||
<span>Kod Blokları</span>
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{/* 3. Sağ: Hızlı Eylemler, YakNet SSO Menüsü ve Erişilebilirlik */}
|
||||
<div className="topbar-section right-section">
|
||||
{!isDashboard ? (
|
||||
<div className="quick-actions-cluster">
|
||||
{/* Geri Al / İleri Al */}
|
||||
<div className="history-btn-group">
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-icon-btn"
|
||||
disabled={!canUndo}
|
||||
onClick={onUndo}
|
||||
title="Geri Al (Ctrl+Z)"
|
||||
aria-label="Geri Al"
|
||||
>
|
||||
<Undo2 size={16} aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-icon-btn"
|
||||
disabled={!canRedo}
|
||||
onClick={onRedo}
|
||||
title="İleri Al (Ctrl+Y)"
|
||||
aria-label="İleri Al"
|
||||
>
|
||||
<Redo2 size={16} aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="divider-vert" />
|
||||
|
||||
{/* İçe Aktar & Dışa Aktar */}
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-action-btn import-btn"
|
||||
onClick={onImport}
|
||||
title="3B veya 2B Model İçe Aktar (STL, OBJ, STEP, SVG, DXF, GLB, SKF)"
|
||||
aria-label="Dosya İçe Aktar"
|
||||
>
|
||||
<FileUp size={14} aria-hidden="true" />
|
||||
<span className="hidden xl:inline">İçe Aktar</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-action-btn export-btn"
|
||||
onClick={onExport}
|
||||
title="Modeli Dışa Aktar (STL, OBJ, STEP, DXF, SVG, GLB, SKF)"
|
||||
aria-label="Dosyayı Dışa Aktar"
|
||||
>
|
||||
<FileDown size={14} aria-hidden="true" />
|
||||
<span>Dışa Aktar</span>
|
||||
</button>
|
||||
|
||||
{onOpenAR ? (
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-action-btn ar-btn"
|
||||
onClick={onOpenAR}
|
||||
title="Masa Üstünde Gör (Mobil AR & WebXR Kamera Önizleme)"
|
||||
aria-label="Artırılmış Gerçeklik Masada Gör"
|
||||
style={{
|
||||
background: "linear-gradient(135deg, #0ea5e9, #0284c7)",
|
||||
color: "#ffffff",
|
||||
borderColor: "rgba(14, 165, 233, 0.4)",
|
||||
fontWeight: 600,
|
||||
boxShadow: "0 2px 6px rgba(14, 165, 233, 0.25)",
|
||||
}}
|
||||
>
|
||||
<Smartphone size={14} aria-hidden="true" />
|
||||
<span className="hidden lg:inline">Masamda Gör (AR)</span>
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
{onStructuralTest ? (
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-action-btn structural-test-btn"
|
||||
onClick={onStructuralTest}
|
||||
title="Bina Statik Dayanım & Deprem Simülasyonu (Yıkım & Güvenlik Analizi)"
|
||||
aria-label="Statik Dayanım ve Deprem Testi"
|
||||
style={{
|
||||
background: "linear-gradient(135deg, #0284c7, #4f46e5)",
|
||||
color: "#ffffff",
|
||||
borderColor: "rgba(56, 189, 248, 0.4)",
|
||||
fontWeight: 600,
|
||||
boxShadow: "0 2px 6px rgba(2, 132, 199, 0.25)",
|
||||
}}
|
||||
>
|
||||
<Activity size={14} aria-hidden="true" />
|
||||
<span className="hidden lg:inline">Statik & Deprem Testi</span>
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
{onCelebration ? (
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-action-btn celebration-btn"
|
||||
onClick={onCelebration}
|
||||
title="Tebrik & Başarı Konfetisi Patlat (🎉)"
|
||||
aria-label="Tebrik Konfetisi"
|
||||
style={{
|
||||
background: "linear-gradient(135deg, #10b981, #059669)",
|
||||
color: "#ffffff",
|
||||
borderColor: "rgba(52, 211, 153, 0.4)",
|
||||
fontWeight: 600,
|
||||
}}
|
||||
>
|
||||
<Sparkles size={14} aria-hidden="true" />
|
||||
<span className="hidden xl:inline">Tebrik</span>
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
{onOpenDailyChallenges ? (
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-action-btn daily-challenges-btn"
|
||||
onClick={onOpenDailyChallenges}
|
||||
title="Günün 3D Görevleri & XP Başarımları (Mimarlık & Bilişim)"
|
||||
aria-label="Günün Görevleri"
|
||||
style={{
|
||||
background: "linear-gradient(135deg, #f59e0b, #ef4444)",
|
||||
color: "#ffffff",
|
||||
borderColor: "rgba(245, 158, 11, 0.4)",
|
||||
fontWeight: 700,
|
||||
boxShadow: "0 2px 6px rgba(245, 158, 11, 0.25)",
|
||||
}}
|
||||
>
|
||||
<Trophy size={14} aria-hidden="true" />
|
||||
<span className="hidden sm:inline">Günün Görevleri</span>
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
{onOpenTutorial ? (
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-action-btn tutorial-btn"
|
||||
onClick={onOpenTutorial}
|
||||
title="SnapCAD Akademi — Detaylı ve Uygulamalı Mimari Eğitim Modülü"
|
||||
aria-label="Uygulamalı Eğitim Modülü"
|
||||
style={{
|
||||
background: "linear-gradient(135deg, #6366f1, #8b5cf6)",
|
||||
color: "#ffffff",
|
||||
borderColor: "rgba(168, 85, 247, 0.4)",
|
||||
fontWeight: 600,
|
||||
boxShadow: "0 2px 6px rgba(99, 102, 241, 0.25)",
|
||||
}}
|
||||
>
|
||||
<GraduationCap size={15} aria-hidden="true" />
|
||||
<span className="hidden sm:inline">Uygulamalı Eğitim</span>
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{/* YakNet Account Widget & Cloud Bar */}
|
||||
<div className="yaknet-cloud-slot">{cloudBarSlot}</div>
|
||||
|
||||
{/* Erişilebilirlik ve Ayarlar Butonu */}
|
||||
{onOpenA11y ? (
|
||||
<button
|
||||
type="button"
|
||||
className="topbar-icon-btn a11y-trigger-btn"
|
||||
onClick={onOpenA11y}
|
||||
title="Erişilebilirlik, Tema ve Kılavuz Merkezi (Alt+A)"
|
||||
aria-label="Erişilebilirlik ve Kılavuz Merkezi"
|
||||
>
|
||||
<SlidersHorizontal size={16} aria-hidden="true" />
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useId, useEffect } from "react";
|
||||
import {
|
||||
Wand2,
|
||||
X,
|
||||
Layers,
|
||||
Sparkles,
|
||||
Check,
|
||||
Maximize2,
|
||||
Sliders,
|
||||
CornerDownRight,
|
||||
Square,
|
||||
Circle,
|
||||
HelpCircle,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
FOLLOW_ME_PROFILE_PRESETS,
|
||||
generateFollowMeShape,
|
||||
type FollowMeConfig,
|
||||
type FollowMeProfileType,
|
||||
type FollowMePathPreset,
|
||||
} from "@/lib/followMeKernel";
|
||||
import { ARCHITECTURAL_TEXTURES } from "@/lib/architecturalTextures";
|
||||
import type { WorkplaneShape, ArchitecturalTextureId } from "@/types/sketchforge";
|
||||
|
||||
export interface FollowMeModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onAddShape: (shape: WorkplaneShape) => void;
|
||||
}
|
||||
|
||||
export const FollowMeModal: React.FC<FollowMeModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
onAddShape,
|
||||
}) => {
|
||||
const baseId = useId();
|
||||
|
||||
const [profileType, setProfileType] = useState<FollowMeProfileType>("molding");
|
||||
const [pathPreset, setPathPreset] = useState<FollowMePathPreset>("perimeter");
|
||||
|
||||
// Ölçüler
|
||||
const [width, setWidth] = useState(25);
|
||||
const [height, setHeight] = useState(30);
|
||||
const [roomWidth, setRoomWidth] = useState(200);
|
||||
const [roomDepth, setRoomDepth] = useState(150);
|
||||
const [pathLength, setPathLength] = useState(200);
|
||||
const [arcRadius, setArcRadius] = useState(100);
|
||||
|
||||
// Doku & Renk
|
||||
const [texture, setTexture] = useState<ArchitecturalTextureId>("none");
|
||||
const [color, setColor] = useState("#ffffff");
|
||||
|
||||
// Profil değiştiğinde varsayılan değerleri güncelle
|
||||
const handleSelectProfile = (presetId: FollowMeProfileType) => {
|
||||
setProfileType(presetId);
|
||||
const meta = FOLLOW_ME_PROFILE_PRESETS.find((p) => p.id === presetId);
|
||||
if (meta) {
|
||||
setWidth(meta.defaultWidth);
|
||||
setHeight(meta.defaultHeight);
|
||||
setTexture(meta.defaultTexture);
|
||||
setColor(meta.defaultColor);
|
||||
}
|
||||
};
|
||||
|
||||
// Escape tuşu ile kapatma
|
||||
useEffect(() => {
|
||||
if (!isOpen) return;
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") onClose();
|
||||
};
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [isOpen, onClose]);
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
const handleCreate = () => {
|
||||
const config: FollowMeConfig = {
|
||||
profileType,
|
||||
pathPreset,
|
||||
width,
|
||||
height,
|
||||
roomWidth,
|
||||
roomDepth,
|
||||
pathLength,
|
||||
arcRadius,
|
||||
color,
|
||||
texture,
|
||||
};
|
||||
|
||||
const shape = generateFollowMeShape(config);
|
||||
onAddShape(shape);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const currentMeta = FOLLOW_ME_PROFILE_PRESETS.find((p) => p.id === profileType);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4 animate-in fade-in duration-150"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby={`${baseId}-title`}
|
||||
aria-describedby={`${baseId}-desc`}
|
||||
>
|
||||
<div className="bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 rounded-3xl max-w-xl w-full p-6 space-y-5 shadow-2xl relative text-slate-900 dark:text-white max-h-[90vh] overflow-y-auto">
|
||||
{/* Kapat Butonu */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="absolute top-5 right-5 p-1.5 rounded-xl text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 hover:bg-slate-100 dark:hover:bg-slate-800 transition"
|
||||
aria-label="Pencereyi kapat"
|
||||
title="Kapat"
|
||||
>
|
||||
<X size={20} aria-hidden="true" />
|
||||
</button>
|
||||
|
||||
{/* Başlık Alanı */}
|
||||
<div className="space-y-1">
|
||||
<div className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wider bg-emerald-50 dark:bg-emerald-950/60 text-emerald-600 dark:text-emerald-400 border border-emerald-200 dark:border-emerald-800">
|
||||
<Wand2 size={13} aria-hidden="true" /> Mimari Süpürme (Follow Me)
|
||||
</div>
|
||||
<h2 id={`${baseId}-title`} className="text-2xl font-black tracking-tight flex items-center gap-2">
|
||||
Beni Takip Et & Süpürme
|
||||
</h2>
|
||||
<p id={`${baseId}-desc`} className="text-xs text-slate-500 dark:text-slate-400">
|
||||
2B profili bir rota boyunca 3B süpürerek kartonpiyer, süpürgelik, tesisat borusu, korkuluk ve mimari kirişler oluşturun.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 1. Profil Seçimi */}
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs font-bold uppercase tracking-wider text-slate-500 flex items-center gap-1.5">
|
||||
<Sliders size={13} /> 1. Mimari Profil Seçimi
|
||||
</label>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 gap-2">
|
||||
{FOLLOW_ME_PROFILE_PRESETS.map((preset) => (
|
||||
<button
|
||||
key={preset.id}
|
||||
type="button"
|
||||
onClick={() => handleSelectProfile(preset.id)}
|
||||
className={`p-2.5 rounded-xl border text-left transition flex flex-col gap-1 ${
|
||||
profileType === preset.id
|
||||
? "border-emerald-500 bg-emerald-50 dark:bg-emerald-950/40 text-emerald-900 dark:text-emerald-200 ring-2 ring-emerald-500 font-bold"
|
||||
: "border-slate-200 dark:border-slate-800 hover:border-slate-300 dark:hover:border-slate-700 bg-slate-50/50 dark:bg-slate-800/40"
|
||||
}`}
|
||||
>
|
||||
<span className="text-xs font-semibold">{preset.name}</span>
|
||||
<span className="text-[10px] text-slate-500 dark:text-slate-400 line-clamp-1">
|
||||
{preset.category.toUpperCase()}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="p-2.5 rounded-xl bg-slate-50 dark:bg-slate-800/60 border border-slate-100 dark:border-slate-800 text-xs text-slate-600 dark:text-slate-300">
|
||||
💡 <strong>{currentMeta?.name}:</strong> {currentMeta?.description}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 2. Güzergah / Rota Seçimi */}
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs font-bold uppercase tracking-wider text-slate-500 flex items-center gap-1.5">
|
||||
<CornerDownRight size={13} /> 2. Süpürme Güzergahı (Rota)
|
||||
</label>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 gap-2">
|
||||
{[
|
||||
{ id: "perimeter", label: "4 Duvar Çevresi", desc: "Tam oda tavanı/tabanı" },
|
||||
{ id: "l-corner", label: "L-Köşe (90°)", desc: "İki duvar birleşimi" },
|
||||
{ id: "u-shape", label: "U-Kanal (3 Duvar)", desc: "Koridor ve nişler" },
|
||||
{ id: "straight", label: "Düz Hat", desc: "Tek duvar / kiriş" },
|
||||
{ id: "arc", label: "Kıvrımlı Yay", desc: "Balkon ve dairesel kule" },
|
||||
].map((p) => (
|
||||
<button
|
||||
key={p.id}
|
||||
type="button"
|
||||
onClick={() => setPathPreset(p.id as FollowMePathPreset)}
|
||||
className={`p-2.5 rounded-xl border text-left transition ${
|
||||
pathPreset === p.id
|
||||
? "border-emerald-500 bg-emerald-50 dark:bg-emerald-950/40 text-emerald-900 dark:text-emerald-200 ring-2 ring-emerald-500 font-bold"
|
||||
: "border-slate-200 dark:border-slate-800 hover:border-slate-300 dark:hover:border-slate-700 bg-slate-50/50 dark:bg-slate-800/40"
|
||||
}`}
|
||||
>
|
||||
<div className="text-xs font-semibold">{p.label}</div>
|
||||
<div className="text-[10px] text-slate-500 dark:text-slate-400">{p.desc}</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 3. Ölçü Parametreleri */}
|
||||
<div className="space-y-3 p-3.5 rounded-2xl bg-slate-50 dark:bg-slate-800/50 border border-slate-200 dark:border-slate-800">
|
||||
<div className="text-xs font-bold text-slate-700 dark:text-slate-200">
|
||||
Ölçü Parametreleri (Milimetre)
|
||||
</div>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 gap-3 text-xs">
|
||||
<div>
|
||||
<label className="text-slate-500 block mb-1">Profil Genişliği:</label>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<input
|
||||
type="number"
|
||||
min={2}
|
||||
max={200}
|
||||
value={width}
|
||||
onChange={(e) => setWidth(Math.max(2, Number(e.target.value)))}
|
||||
className="w-full px-2 py-1 rounded-lg border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 font-mono font-bold"
|
||||
/>
|
||||
<span className="text-[11px] text-slate-400">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="text-slate-500 block mb-1">Profil Yüksekliği:</label>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<input
|
||||
type="number"
|
||||
min={2}
|
||||
max={200}
|
||||
value={height}
|
||||
onChange={(e) => setHeight(Math.max(2, Number(e.target.value)))}
|
||||
className="w-full px-2 py-1 rounded-lg border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 font-mono font-bold"
|
||||
/>
|
||||
<span className="text-[11px] text-slate-400">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{pathPreset === "straight" ? (
|
||||
<div>
|
||||
<label className="text-slate-500 block mb-1">Hat Uzunluğu:</label>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<input
|
||||
type="number"
|
||||
min={10}
|
||||
max={2000}
|
||||
step={10}
|
||||
value={pathLength}
|
||||
onChange={(e) => setPathLength(Math.max(10, Number(e.target.value)))}
|
||||
className="w-full px-2 py-1 rounded-lg border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 font-mono font-bold"
|
||||
/>
|
||||
<span className="text-[11px] text-slate-400">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
) : pathPreset === "arc" ? (
|
||||
<div>
|
||||
<label className="text-slate-500 block mb-1">Yay Yarıçapı:</label>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<input
|
||||
type="number"
|
||||
min={20}
|
||||
max={1000}
|
||||
step={10}
|
||||
value={arcRadius}
|
||||
onChange={(e) => setArcRadius(Math.max(20, Number(e.target.value)))}
|
||||
className="w-full px-2 py-1 rounded-lg border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 font-mono font-bold"
|
||||
/>
|
||||
<span className="text-[11px] text-slate-400">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<div>
|
||||
<label className="text-slate-500 block mb-1">Oda Genişliği:</label>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<input
|
||||
type="number"
|
||||
min={20}
|
||||
max={2000}
|
||||
step={10}
|
||||
value={roomWidth}
|
||||
onChange={(e) => setRoomWidth(Math.max(20, Number(e.target.value)))}
|
||||
className="w-full px-2 py-1 rounded-lg border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 font-mono font-bold"
|
||||
/>
|
||||
<span className="text-[11px] text-slate-400">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-slate-500 block mb-1">Oda Derinliği:</label>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<input
|
||||
type="number"
|
||||
min={20}
|
||||
max={2000}
|
||||
step={10}
|
||||
value={roomDepth}
|
||||
onChange={(e) => setRoomDepth(Math.max(20, Number(e.target.value)))}
|
||||
className="w-full px-2 py-1 rounded-lg border border-slate-300 dark:border-slate-700 bg-white dark:bg-slate-900 font-mono font-bold"
|
||||
/>
|
||||
<span className="text-[11px] text-slate-400">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 4. Malzeme / Doku Seçimi */}
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs font-bold uppercase tracking-wider text-slate-500 flex items-center gap-1.5">
|
||||
<Layers size={13} /> 3. Mimari Kaplama & Doku
|
||||
</label>
|
||||
<div className="grid grid-cols-3 sm:grid-cols-5 gap-1.5">
|
||||
{ARCHITECTURAL_TEXTURES.slice(0, 5).map((tex) => (
|
||||
<button
|
||||
key={tex.id}
|
||||
type="button"
|
||||
onClick={() => setTexture(tex.id)}
|
||||
className={`p-2 rounded-xl border text-xs font-medium text-center transition ${
|
||||
texture === tex.id
|
||||
? "border-emerald-500 bg-emerald-50 dark:bg-emerald-950/50 text-emerald-700 dark:text-emerald-300 ring-1 ring-emerald-500 font-bold"
|
||||
: "border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-800"
|
||||
}`}
|
||||
>
|
||||
{tex.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Eylemler */}
|
||||
<div className="flex items-center justify-end gap-3 pt-3 border-t border-slate-200 dark:border-slate-800">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="px-4 py-2 rounded-xl text-xs font-semibold text-slate-600 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-800 transition"
|
||||
>
|
||||
Vazgeç
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleCreate}
|
||||
className="px-5 py-2.5 rounded-xl text-xs font-bold bg-emerald-600 hover:bg-emerald-700 text-white shadow-lg shadow-emerald-600/25 transition flex items-center gap-2"
|
||||
>
|
||||
<Sparkles size={14} /> Süpürmeyi Sahnede Oluştur
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,355 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect, useCallback } from "react";
|
||||
import {
|
||||
GraduationCap,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
X,
|
||||
CheckCircle2,
|
||||
Sparkles,
|
||||
Maximize2,
|
||||
Minimize2,
|
||||
Play,
|
||||
RotateCcw,
|
||||
Compass,
|
||||
Box,
|
||||
Layers,
|
||||
Eye,
|
||||
PaintBucket,
|
||||
Activity,
|
||||
Smartphone,
|
||||
Flame,
|
||||
} from "lucide-react";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
import {
|
||||
TUTORIAL_STEPS,
|
||||
type TutorialStep,
|
||||
type TutorialActionType,
|
||||
} from "@/lib/academyTutorialData";
|
||||
|
||||
export { TUTORIAL_STEPS, type TutorialStep, type TutorialActionType };
|
||||
|
||||
const TUTORIAL_STORAGE_KEY = "snapcad_interactive_tutorial_step";
|
||||
|
||||
export interface InteractiveTutorialModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onExecuteAction?: (actionType: TutorialActionType) => void;
|
||||
onOpenAR?: () => void;
|
||||
}
|
||||
|
||||
export const InteractiveTutorialModal: React.FC<InteractiveTutorialModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
onExecuteAction,
|
||||
onOpenAR,
|
||||
}) => {
|
||||
const [currentStepIndex, setCurrentStepIndex] = useState<number>(0);
|
||||
const [isMinimized, setIsMinimized] = useState<boolean>(false);
|
||||
|
||||
// Restore step from localStorage
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
const saved = window.localStorage.getItem(TUTORIAL_STORAGE_KEY);
|
||||
if (saved !== null) {
|
||||
const parsed = parseInt(saved, 10);
|
||||
if (!isNaN(parsed) && parsed >= 0 && parsed < TUTORIAL_STEPS.length) {
|
||||
setCurrentStepIndex(parsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
const goToStep = useCallback((index: number) => {
|
||||
const next = Math.max(0, Math.min(TUTORIAL_STEPS.length - 1, index));
|
||||
setCurrentStepIndex(next);
|
||||
if (typeof window !== "undefined") {
|
||||
window.localStorage.setItem(TUTORIAL_STORAGE_KEY, String(next));
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Keyboard navigation: ArrowLeft, ArrowRight, Escape
|
||||
useEffect(() => {
|
||||
if (!isOpen) return;
|
||||
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
// Ignore if user is typing in an input
|
||||
if (["INPUT", "TEXTAREA"].includes((e.target as HTMLElement)?.tagName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.key === "ArrowRight") {
|
||||
e.preventDefault();
|
||||
goToStep(currentStepIndex + 1);
|
||||
} else if (e.key === "ArrowLeft") {
|
||||
e.preventDefault();
|
||||
goToStep(currentStepIndex - 1);
|
||||
} else if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [isOpen, currentStepIndex, goToStep, onClose]);
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
const step = TUTORIAL_STEPS[currentStepIndex];
|
||||
const isFirst = currentStepIndex === 0;
|
||||
const isLast = currentStepIndex === TUTORIAL_STEPS.length - 1;
|
||||
const progressPercent = Math.round(((currentStepIndex + 1) / TUTORIAL_STEPS.length) * 100);
|
||||
|
||||
// Minimized floating pill view
|
||||
if (isMinimized) {
|
||||
return (
|
||||
<aside
|
||||
className="fixed bottom-6 left-6 z-50 flex items-center gap-3 rounded-2xl border border-sky-500/40 bg-slate-900/95 px-4 py-2.5 text-white shadow-2xl backdrop-blur-md"
|
||||
role="region"
|
||||
aria-label="Küçültülmüş Eğitim Modülü"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<GraduationCap className="h-5 w-5 text-sky-400" />
|
||||
<span className="text-xs font-bold text-slate-200">
|
||||
Adım {step.stepNumber}/{TUTORIAL_STEPS.length}:
|
||||
</span>
|
||||
<span className="text-xs font-medium text-sky-400 max-w-[180px] truncate">
|
||||
{step.title}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-1.5 border-l border-slate-700 pl-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => goToStep(currentStepIndex - 1)}
|
||||
disabled={isFirst}
|
||||
className="rounded-lg p-1 text-slate-400 hover:bg-slate-800 hover:text-white disabled:opacity-30"
|
||||
title="Önceki Adım (Sol Ok)"
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => goToStep(currentStepIndex + 1)}
|
||||
disabled={isLast}
|
||||
className="rounded-lg p-1 text-slate-400 hover:bg-slate-800 hover:text-white disabled:opacity-30"
|
||||
title="Sonraki Adım (Sağ Ok)"
|
||||
>
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsMinimized(false)}
|
||||
className="rounded-lg p-1 text-sky-400 hover:bg-sky-950/60"
|
||||
title="Genişlet"
|
||||
>
|
||||
<Maximize2 className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-lg p-1 text-slate-400 hover:bg-rose-950/60 hover:text-rose-400"
|
||||
title="Eğitimi Kapat"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<aside
|
||||
className="fixed bottom-6 right-6 z-50 flex w-[480px] max-w-[calc(100vw-32px)] flex-col rounded-3xl border border-sky-500/40 bg-slate-900/95 p-5 text-slate-100 shadow-[0_20px_60px_rgba(0,0,0,0.7)] backdrop-blur-xl transition-all"
|
||||
role="dialog"
|
||||
aria-modal="false"
|
||||
aria-label="SnapCAD Akademi Uygulamalı Eğitim"
|
||||
>
|
||||
{/* 1. Header */}
|
||||
<div className="flex items-center justify-between border-b border-slate-800 pb-3">
|
||||
<div className="flex items-center gap-2.5">
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-xl bg-gradient-to-tr from-sky-500 to-indigo-600 text-white shadow-md shadow-sky-500/30">
|
||||
<GraduationCap className="h-5 w-5" />
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs font-black tracking-wider text-sky-400 uppercase">
|
||||
SnapCAD Akademi
|
||||
</span>
|
||||
<span className="rounded-full bg-slate-800 px-2 py-0.5 text-[10px] font-bold text-slate-400">
|
||||
Adım {step.stepNumber} / {TUTORIAL_STEPS.length}
|
||||
</span>
|
||||
</div>
|
||||
<h3 className="text-sm font-bold text-white">Uygulamalı Mimarlık & 3B Modelleme</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsMinimized(true)}
|
||||
className="rounded-lg p-1.5 text-slate-400 hover:bg-slate-800 hover:text-white"
|
||||
title="Küçült (Pencereyi simge durumuna getir)"
|
||||
aria-label="Küçült"
|
||||
>
|
||||
<Minimize2 className="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-lg p-1.5 text-slate-400 hover:bg-rose-950/60 hover:text-rose-400"
|
||||
title="Kapat (ESC)"
|
||||
aria-label="Eğitimi Kapat"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Progress bar */}
|
||||
<div className="relative mt-2.5 h-1.5 w-full overflow-hidden rounded-full bg-slate-800">
|
||||
<div
|
||||
className="h-full bg-gradient-to-r from-sky-400 via-indigo-400 to-emerald-400 transition-all duration-300"
|
||||
style={{ width: `${progressPercent}%` }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 2. Step Content */}
|
||||
<div className="my-4 flex flex-col gap-3 overflow-y-auto max-h-[380px] pr-1 scrollbar-thin">
|
||||
{/* Category & Title */}
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex items-center justify-between">
|
||||
<span
|
||||
className="rounded-md px-2 py-0.5 text-[10px] font-extrabold uppercase tracking-wide text-white"
|
||||
style={{ backgroundColor: step.categoryColor }}
|
||||
>
|
||||
{step.category}
|
||||
</span>
|
||||
{step.shortcutKey && (
|
||||
<span className="flex items-center gap-1 rounded bg-slate-800 px-2 py-0.5 text-[11px] font-mono font-bold text-amber-300 border border-amber-400/20">
|
||||
Kısayol: {step.shortcutKey}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<h2 className="text-base font-extrabold text-white mt-1">{step.title}</h2>
|
||||
<p className="text-xs font-medium text-slate-400">{step.subtitle}</p>
|
||||
</div>
|
||||
|
||||
{/* Body points */}
|
||||
<div className="flex flex-col gap-2 rounded-2xl bg-slate-800/60 p-3.5 border border-slate-700/60 text-xs text-slate-200 leading-relaxed">
|
||||
{step.body.map((paragraph, idx) => (
|
||||
<p key={idx}>{paragraph}</p>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Tips Box */}
|
||||
{step.tips && step.tips.length > 0 && (
|
||||
<div className="flex items-start gap-2 rounded-xl bg-amber-500/10 border border-amber-500/30 p-2.5 text-xs text-amber-200">
|
||||
<Sparkles className="h-4 w-4 shrink-0 text-amber-400 mt-0.5" />
|
||||
<div className="flex flex-col gap-0.5">
|
||||
{step.tips.map((tip, idx) => (
|
||||
<span key={idx}>{tip}</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Interactive Action Button (Canlı Uygulama Butonu) */}
|
||||
{step.actionButton && (
|
||||
<div className="pt-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
const btn = step.actionButton;
|
||||
if (!btn) return;
|
||||
if (btn.actionType === "open_ar_preview") {
|
||||
onOpenAR?.();
|
||||
} else if (onExecuteAction) {
|
||||
onExecuteAction(btn.actionType);
|
||||
}
|
||||
}}
|
||||
className="flex w-full items-center justify-center gap-2 rounded-xl border border-sky-400/50 bg-gradient-to-r from-sky-600 to-indigo-600 px-4 py-2.5 text-xs font-bold text-white shadow-lg shadow-sky-600/30 transition-all hover:from-sky-500 hover:to-indigo-500 hover:shadow-sky-500/40 active:scale-[0.98]"
|
||||
>
|
||||
<Play className="h-3.5 w-3.5 fill-current" />
|
||||
<span>{step.actionButton.label}</span>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 3. Footer (Önceki, Noktalar, Sonraki, Kapat) */}
|
||||
<div className="flex items-center justify-between border-t border-slate-800 pt-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => goToStep(currentStepIndex - 1)}
|
||||
disabled={isFirst}
|
||||
className="flex items-center gap-1.5 rounded-xl border border-slate-700 bg-slate-800/80 px-3.5 py-2 text-xs font-semibold text-slate-200 transition-colors hover:bg-slate-700 hover:text-white disabled:opacity-40 disabled:cursor-not-allowed"
|
||||
title="Önceki Adıma Dön (Sol Ok)"
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4" />
|
||||
<span>Önceki</span>
|
||||
</button>
|
||||
|
||||
{/* Step dots */}
|
||||
<div className="flex items-center gap-1" aria-label="Eğitim Adımları">
|
||||
{TUTORIAL_STEPS.map((s, idx) => (
|
||||
<button
|
||||
key={s.id}
|
||||
type="button"
|
||||
onClick={() => goToStep(idx)}
|
||||
className={`h-2 rounded-full transition-all ${
|
||||
idx === currentStepIndex
|
||||
? "w-5 bg-sky-400"
|
||||
: idx < currentStepIndex
|
||||
? "w-2 bg-emerald-400/80"
|
||||
: "w-2 bg-slate-700 hover:bg-slate-600"
|
||||
}`}
|
||||
title={`${idx + 1}. Adım: ${s.title}`}
|
||||
aria-label={`${idx + 1}. Adım`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{isLast ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (typeof window !== "undefined") {
|
||||
window.localStorage.removeItem(TUTORIAL_STORAGE_KEY);
|
||||
}
|
||||
onClose();
|
||||
}}
|
||||
className="flex items-center gap-1.5 rounded-xl border border-emerald-400/60 bg-gradient-to-r from-emerald-600 to-teal-600 px-4 py-2 text-xs font-bold text-white shadow-lg shadow-emerald-600/30 transition-all hover:from-emerald-500 hover:to-teal-500"
|
||||
>
|
||||
<CheckCircle2 className="h-4 w-4" />
|
||||
<span>Eğitimi Bitir 🎉</span>
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => goToStep(currentStepIndex + 1)}
|
||||
className="flex items-center gap-1.5 rounded-xl border border-sky-400/60 bg-gradient-to-r from-sky-600 to-indigo-600 px-4 py-2 text-xs font-bold text-white shadow-lg shadow-sky-600/30 transition-all hover:from-sky-500 hover:to-indigo-500"
|
||||
title="Sonraki Adıma Geç (Sağ Ok)"
|
||||
>
|
||||
<span>Sonraki</span>
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
</button>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-xl border border-slate-700 bg-slate-800/80 px-3 py-2 text-xs font-semibold text-slate-300 hover:bg-slate-700 hover:text-white"
|
||||
title="Kapat (ESC)"
|
||||
>
|
||||
Kapat
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,319 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
ArrowLeft,
|
||||
Building2,
|
||||
CheckCircle2,
|
||||
Database,
|
||||
ExternalLink,
|
||||
EyeOff,
|
||||
FileText,
|
||||
Lock,
|
||||
Scale,
|
||||
ShieldCheck,
|
||||
UserCheck,
|
||||
} from "lucide-react";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
interface KVKKPageContentProps {
|
||||
onBackToDashboard?: () => void;
|
||||
onGoToTerms?: () => void;
|
||||
onGoToSecurity?: () => void;
|
||||
}
|
||||
|
||||
export function KVKKPageContent({
|
||||
onBackToDashboard,
|
||||
onGoToTerms,
|
||||
onGoToSecurity,
|
||||
}: KVKKPageContentProps) {
|
||||
const headingRef = useRef<HTMLHeadingElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
headingRef.current?.focus();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<article className="snapcad-content-page legal-page" aria-labelledby="kvkk-main-heading">
|
||||
{/* 1. Başlık Bölümü */}
|
||||
<header className="content-hero legal-hero">
|
||||
<div className="hero-badge">
|
||||
<ShieldCheck size={15} aria-hidden="true" />
|
||||
<span>6698 Sayılı KVKK & Veri Güvenliği Taahhüdü</span>
|
||||
</div>
|
||||
<h1
|
||||
id="kvkk-main-heading"
|
||||
ref={headingRef}
|
||||
tabIndex={-1}
|
||||
className="hero-title outline-none focus:ring-2 focus:ring-sky-500 rounded-md"
|
||||
>
|
||||
KVKK ve Gizlilik Politikası
|
||||
</h1>
|
||||
<p className="hero-lead">
|
||||
SnapCAD Studio, resmi bir <strong>YakNet</strong> hizmeti ve <strong>YakHub Ekosistemi</strong>{" "}
|
||||
platformudur. Kullanıcılarımızın kişisel verilerinin korunması, 3B modellerinin gizliliği ve
|
||||
dijital hakları en yüksek kurumsal güvenlik önceliğimizdir.
|
||||
</p>
|
||||
<div className="legal-meta-tag-bar">
|
||||
<span className="legal-tag">
|
||||
<strong>Hizmet Sahibi:</strong> YakNet & YakHub Bilişim Ekosistemi
|
||||
</span>
|
||||
<span className="legal-tag">
|
||||
<strong>Yürürlük Tarihi:</strong> 1 Ocak 2026
|
||||
</span>
|
||||
<span className="legal-tag">
|
||||
<strong>Son Güncelleme:</strong> Ekim 2026
|
||||
</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* 2. Resmi YakNet Hizmeti Beyanı Vurgusu */}
|
||||
<div className="yaknet-affiliation-card" role="region" aria-label="YakNet Hizmet Beyanı">
|
||||
<div className="yaknet-affiliation-icon">
|
||||
<Building2 size={28} className="text-sky-400" aria-hidden="true" />
|
||||
</div>
|
||||
<div className="yaknet-affiliation-body">
|
||||
<h2 className="yaknet-affiliation-title">Resmi YakNet Hizmet Beyanı ve Veri Sorumlusu</h2>
|
||||
<p className="yaknet-affiliation-text">
|
||||
SnapCAD Studio (<strong>snap.yakhub.com.tr</strong>), YakNet ağ altyapısı ve YakHub Ekosistemi
|
||||
bünyesinde faaliyet gösteren resmi bir 3B parametrik tasarım, eğitim ve mühendislik hizmetidir.
|
||||
6698 sayılı Kişisel Verilerin Korunması Kanunu (“KVKK”) kapsamında veri sorumlusu
|
||||
<strong> YakNet Bilgi ve İletişim Ağı (YakHub)</strong>’dır.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 3. Kanuni Maddeler Grid */}
|
||||
<div className="legal-sections-container">
|
||||
{/* Madde 1 */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-scope">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">01</span>
|
||||
<h2 id="sec-scope" className="article-title">
|
||||
Kapsam ve Amaç
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
İşbu Aydınlatma ve Gizlilik Metni; SnapCAD Studio web uygulamasını, 3D Katı CAD, İt / Çek,
|
||||
Teknik Resim, Elektronik Devreler ve Kod Blokları stüdyolarını ziyaret eden, YakNet SSO
|
||||
hesabı ile oturum açan veya platformu yerel (çevrimdışı) modda kullanan tüm bireysel,
|
||||
akademik ve kurumsal kullanıcıları kapsar.
|
||||
</p>
|
||||
<p>
|
||||
Amacımız, SnapCAD Studio üzerindeki tasarım ve modelleme faaliyetleriniz esnasında hangi
|
||||
verilerinizin işlendiğini, nasıl korunduğunu ve 6698 sayılı KVKK kapsamındaki haklarınızı
|
||||
tam bir şeffaflıkla açıklamaktır.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 2 */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-data">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">02</span>
|
||||
<h2 id="sec-data" className="article-title">
|
||||
İşlenen Kişisel Veriler ve Toplama Yöntemleri
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
SnapCAD Studio “Veri Minimizasyonu” (Privacy by Design) ilkesini benimser. Sadece
|
||||
hizmetin teknik olarak çalışması için zorunlu olan asgari veriler toplanır:
|
||||
</p>
|
||||
<ul className="legal-bullet-list">
|
||||
<li>
|
||||
<strong>YakNet Hesap Bilgileri:</strong> YakNet Tekil Oturum Açma (SSO) sistemi üzerinden
|
||||
sağlanan kullanıcı adı, kullanıcı rumuzu, YakNet profil tanımlayıcısı ve e-posta adresi.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Proje ve Model Meta Verileri:</strong> Kullanıcının oluşturduğu 3B modellerin başlığı,
|
||||
oluşturulma/düzenlenme zaman damgaları ve kullanıcının isteğiyle buluta yüklenen proje paketleri.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Teknik ve Oturum Verileri:</strong> Tarayıcı tipi, ekran çözünürlüğü, WebGL/GPU donanım
|
||||
kapasite uyumluluğu ve hata teşhis kayıtları (kişisel kimlikle eşleştirilmez).
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 3 */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-localfirst">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">03</span>
|
||||
<h2 id="sec-localfirst" className="article-title">
|
||||
İstemci Taraflı (Local-First) 3B Geometri Gizliliği
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<div className="highlight-callout">
|
||||
<EyeOff size={20} className="text-emerald-400 shrink-0" aria-hidden="true" />
|
||||
<div>
|
||||
<strong>3B Modelleriniz Cihazınızda Kalır:</strong> SnapCAD Studio, parametrik CSG,
|
||||
Manifold-3D ve OpenCASCADE geometri hesaplamalarını sunucuya ham veri göndermeksizin doğrudan
|
||||
kendi tarayıcınızın WebAssembly ve WebGL çekirdeğinde yerel olarak işler.
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
Siz “Buluta Kaydet” veya “Paylaş” düğmesine kasten basmadığınız sürece
|
||||
modelleriniz, teknik çizimleriniz ve elektronik devre tasarımlarınız yalnızca tarayıcınızın yerel
|
||||
belleğinde (IndexedDB / LocalStorage) saklanır. Şirketimiz veya üçüncü şahıslar tasarımlarınızı
|
||||
görüntüleyemez.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 4 */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-security">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">04</span>
|
||||
<h2 id="sec-security" className="article-title">
|
||||
Veri Güvenliği ve YakNet Altyapısı
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
Toplanan tüm veriler, YakNet güvenlik standartları çerçevesinde kurumsal düzeyde korunmaktadır:
|
||||
</p>
|
||||
<div className="legal-subgrid">
|
||||
<div className="legal-subbox">
|
||||
<Lock size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>TLS 1.3 ve HSTS</h4>
|
||||
<p>İstemci ile sunucu arasındaki tüm veri akışı uçtan uca modern TLS 1.3 protokolüyle şifrelenir.</p>
|
||||
</div>
|
||||
<div className="legal-subbox">
|
||||
<Database size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>AES-256 Depolama</h4>
|
||||
<p>YakNet Bulut Vault üzerinde depolanan kullanıcı projeleri AES-256 algoritmasıyla şifreli saklanır.</p>
|
||||
</div>
|
||||
<div className="legal-subbox">
|
||||
<UserCheck size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>YakNet SSO İzolasyonu</h4>
|
||||
<p>Oturum kimlikleri güvenli HTTP-Only çerezlerle korunur, üçüncü taraf betiklerin erişimi engellenir.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 5 */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-thirdparty">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">05</span>
|
||||
<h2 id="sec-thirdparty" className="article-title">
|
||||
Üçüncü Taraflarla Veri Paylaşımı ve Ticari Satış Yasağı
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
SnapCAD Studio ve YakNet; kullanıcıların kişisel verilerini, çizimlerini veya tasarımlarını
|
||||
<strong> kesinlikle üçüncü taraflarla paylaşmaz, reklam şirketlerine satmaz veya ticari kâr
|
||||
amacıyla pazarlamaz.</strong>
|
||||
</p>
|
||||
<p>
|
||||
Veriler yalnızca yetkili adli makamların kanuni gerekçelere dayalı resmi talepleri doğrultusunda
|
||||
ve yasal mevzuat sınırları dahilinde paylaşılabilir.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 6 */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-rights">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">06</span>
|
||||
<h2 id="sec-rights" className="article-title">
|
||||
İlgili Kişinin Hakları (KVKK Madde 11)
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>6698 sayılı Kanun’un 11. maddesi uyarınca veri sahibi olarak aşağıdaki haklara sahipsiniz:</p>
|
||||
<ul className="legal-bullet-list">
|
||||
<li>Kişisel verilerinizin işlenip işlenmediğini öğrenme,</li>
|
||||
<li>İşlenmişse buna ilişkin bilgi talep etme,</li>
|
||||
<li>İşlenme amacını ve bunların amacına uygun kullanılıp kullanılmadığını öğrenme,</li>
|
||||
<li>Eksik veya yanlış işlenmişse düzeltilmesini isteme,</li>
|
||||
<li>KVKK’nın 7. maddesi uyarınca verilerinizin silinmesini veya yok edilmesini talep etme,</li>
|
||||
<li>Tüm projelerinizi ve verilerinizi tek tıkla cihazınıza dışa aktarma (Veri Taşınabilirliği).</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 7 */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-contact-legal">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">07</span>
|
||||
<h2 id="sec-contact-legal" className="article-title">
|
||||
İletişim ve Veri Sorumlusuna Başvuru
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
KVKK kapsamındaki taleplerinizi, soru ve başvurularınızı YakNet Veri Masası’na iletebilirsiniz:
|
||||
</p>
|
||||
<div className="legal-contact-box">
|
||||
<p>
|
||||
<strong>Veri Sorumlusu:</strong> YakNet & YakHub Bilişim Ekosistemi
|
||||
</p>
|
||||
<p>
|
||||
<strong>Resmi E-Posta:</strong>{" "}
|
||||
<a href="mailto:[email protected]" className="text-sky-400 font-semibold underline">
|
||||
destek@yakhub.com.tr
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<strong>YakNet Portal:</strong>{" "}
|
||||
<a
|
||||
href="https://yakhub.com.tr"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="text-sky-400 inline-flex items-center gap-1 font-semibold underline"
|
||||
>
|
||||
yakhub.com.tr <ExternalLink size={12} aria-hidden="true" />
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{/* Alt Aksiyon Butonları */}
|
||||
<footer className="legal-page-actions">
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action-primary"
|
||||
onClick={() => {
|
||||
if (onBackToDashboard) onBackToDashboard();
|
||||
else window.location.href = "/";
|
||||
}}
|
||||
>
|
||||
<ArrowLeft size={16} aria-hidden="true" />
|
||||
<span>3B Stüdyoya Dön</span>
|
||||
</button>
|
||||
|
||||
<div className="legal-action-links">
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action-secondary"
|
||||
onClick={() => {
|
||||
if (onGoToTerms) onGoToTerms();
|
||||
else window.location.href = "/kullanim-kosullari";
|
||||
}}
|
||||
>
|
||||
<FileText size={16} aria-hidden="true" />
|
||||
<span>Kullanım Koşulları</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action-secondary"
|
||||
onClick={() => {
|
||||
if (onGoToSecurity) onGoToSecurity();
|
||||
else window.location.href = "/kurumsal-guvenlik";
|
||||
}}
|
||||
>
|
||||
<ShieldCheck size={16} aria-hidden="true" />
|
||||
<span>Kurumsal Güvenlik</span>
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { PaintBucket, X, Pipette, Check } from "lucide-react";
|
||||
import { ARCHITECTURAL_TEXTURES } from "@/lib/architecturalTextures";
|
||||
import type { ArchitecturalTextureId } from "@/types/sketchforge";
|
||||
|
||||
export interface PaintBucketHUDProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
activeTexture: ArchitecturalTextureId;
|
||||
onSelectTexture: (texture: ArchitecturalTextureId) => void;
|
||||
activeColor: string;
|
||||
onSelectColor: (color: string) => void;
|
||||
}
|
||||
|
||||
const TEXTURE_ICONS: Record<ArchitecturalTextureId, string> = {
|
||||
none: "⚪",
|
||||
brick: "🧱",
|
||||
wood: "🪵",
|
||||
tiles: "🔲",
|
||||
marble: "🏛️",
|
||||
concrete: "🏗️",
|
||||
metal: "⚙️",
|
||||
glass: "🪟",
|
||||
grass: "🌱",
|
||||
};
|
||||
|
||||
const PRESET_COLORS = [
|
||||
"#f8fafc", // Beyaz
|
||||
"#ef4444", // Kiremit Kırmızısı
|
||||
"#f59e0b", // Ahşap / Sarı
|
||||
"#10b981", // Çim Yeşili
|
||||
"#0ea5e9", // Cam / Gökyüzü Mavisi
|
||||
"#64748b", // Beton Grisi
|
||||
"#334155", // Koyu Füme
|
||||
"#1e293b", // Gece / Asfalt
|
||||
];
|
||||
|
||||
export const PaintBucketHUD: React.FC<PaintBucketHUDProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
activeTexture,
|
||||
onSelectTexture,
|
||||
activeColor,
|
||||
onSelectColor,
|
||||
}) => {
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="absolute top-16 left-1/2 z-30 flex -translate-x-1/2 flex-col items-center gap-2 rounded-2xl border border-sky-500/40 bg-slate-900/95 p-3 shadow-2xl backdrop-blur-md"
|
||||
role="toolbar"
|
||||
aria-label="Boya Kovası ve Malzeme Paleti"
|
||||
>
|
||||
{/* Top row: Title, Eyedropper hint, and Close button */}
|
||||
<div className="flex w-full items-center justify-between gap-4 border-b border-slate-700/60 pb-2">
|
||||
<div className="flex items-center gap-2 text-xs font-bold text-sky-400">
|
||||
<PaintBucket className="h-4 w-4" />
|
||||
<span>Boya Kovası (Paint Bucket - B)</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-3 text-[11px] text-slate-400">
|
||||
<span className="flex items-center gap-1 text-amber-300">
|
||||
<Pipette className="h-3 w-3" />
|
||||
<span>Alt + Tıkla: Malzeme Damlalığı</span>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-lg p-1 text-slate-400 hover:bg-slate-800 hover:text-white"
|
||||
aria-label="Kapat"
|
||||
title="Kapat (ESC veya B)"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Textures row */}
|
||||
<div className="flex items-center gap-1.5 overflow-x-auto py-1">
|
||||
{ARCHITECTURAL_TEXTURES.map((tex) => {
|
||||
const isSelected = activeTexture === tex.id;
|
||||
return (
|
||||
<button
|
||||
key={tex.id}
|
||||
type="button"
|
||||
onClick={() => onSelectTexture(tex.id)}
|
||||
className={`flex items-center gap-1.5 rounded-xl border px-2.5 py-1 text-xs font-medium transition-all ${
|
||||
isSelected
|
||||
? "border-sky-400 bg-sky-500/30 text-white shadow-sm ring-1 ring-sky-400"
|
||||
: "border-slate-700 bg-slate-800/80 text-slate-300 hover:border-slate-600 hover:bg-slate-700"
|
||||
}`}
|
||||
>
|
||||
<span className="text-sm">{TEXTURE_ICONS[tex.id] || "🎨"}</span>
|
||||
<span>{tex.name}</span>
|
||||
{isSelected && <Check className="h-3 w-3 text-sky-400" />}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Colors row */}
|
||||
<div className="flex w-full items-center justify-between gap-2 pt-1 border-t border-slate-700/40">
|
||||
<span className="text-[11px] text-slate-400">Renk Tonu:</span>
|
||||
<div className="flex items-center gap-1.5">
|
||||
{PRESET_COLORS.map((c) => (
|
||||
<button
|
||||
key={c}
|
||||
type="button"
|
||||
onClick={() => onSelectColor(c)}
|
||||
className={`h-5 w-5 rounded-full border transition-transform hover:scale-110 ${
|
||||
activeColor.toLowerCase() === c.toLowerCase()
|
||||
? "border-white ring-2 ring-sky-400 scale-110"
|
||||
: "border-slate-600"
|
||||
}`}
|
||||
style={{ backgroundColor: c }}
|
||||
title={c}
|
||||
aria-label={`Renk seç: ${c}`}
|
||||
/>
|
||||
))}
|
||||
<input
|
||||
type="color"
|
||||
value={activeColor}
|
||||
onChange={(e) => onSelectColor(e.target.value)}
|
||||
className="h-6 w-6 cursor-pointer rounded border-0 bg-transparent p-0"
|
||||
title="Özel Renk Seç"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,286 @@
|
||||
"use client";
|
||||
|
||||
import { Box, ShieldCheck } from "lucide-react";
|
||||
|
||||
interface PlatformFooterProps {
|
||||
onNavigateSection?: (
|
||||
section:
|
||||
| "home"
|
||||
| "drawing"
|
||||
| "circuits"
|
||||
| "codeblocks"
|
||||
| "challenges"
|
||||
| "customization"
|
||||
| "about"
|
||||
| "contact"
|
||||
| "kvkk"
|
||||
| "terms"
|
||||
| "security"
|
||||
) => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function PlatformFooter({ onNavigateSection, className = "" }: PlatformFooterProps) {
|
||||
const handleNav = (
|
||||
section:
|
||||
| "home"
|
||||
| "drawing"
|
||||
| "circuits"
|
||||
| "codeblocks"
|
||||
| "challenges"
|
||||
| "customization"
|
||||
| "about"
|
||||
| "contact"
|
||||
| "kvkk"
|
||||
| "terms"
|
||||
| "security",
|
||||
fallbackUrl?: string
|
||||
) => {
|
||||
if (onNavigateSection) {
|
||||
onNavigateSection(section);
|
||||
} else if (fallbackUrl) {
|
||||
window.location.href = fallbackUrl;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<footer className={`snapcad-platform-footer ${className}`} role="contentinfo" aria-label="SnapCAD Studio Kurumsal Altbilgi">
|
||||
<div className="footer-inner-container">
|
||||
{/* 1. Sütun: Marka & Kurumsal Tanım */}
|
||||
<div className="footer-col brand-col">
|
||||
<div className="footer-brand">
|
||||
<div className="footer-brand-gem" aria-hidden="true">
|
||||
<Box size={20} className="text-white" />
|
||||
</div>
|
||||
<div>
|
||||
<span className="footer-brand-title">
|
||||
SnapCAD <span className="text-sky-400 font-bold">Studio</span>
|
||||
</span>
|
||||
<span className="footer-brand-subtitle">Resmi YakNet Hizmeti • YakHub Ekosistemi</span>
|
||||
</div>
|
||||
</div>
|
||||
<p className="footer-brand-desc">
|
||||
SnapCAD Studio, YakNet bulut altyapısı ve YakHub ekosistemi üzerinde çalışan kurumsal,
|
||||
tam erişilebilir ve tarayıcı tabanlı 3B parametrik CAD ve mühendislik platformudur.
|
||||
</p>
|
||||
<div className="footer-badges-cluster">
|
||||
<span className="footer-pill-badge yaknet-badge" title="Resmi YakNet ve YakHub Ekosistemi Hizmeti">
|
||||
<ShieldCheck size={13} aria-hidden="true" />
|
||||
<span>Resmi YakNet Hizmeti</span>
|
||||
</span>
|
||||
<span className="footer-pill-badge wcag-badge" title="Web İçeriği Erişilebilirlik Yönergeleri 2.1 AAA Seviyesi">
|
||||
<ShieldCheck size={13} aria-hidden="true" />
|
||||
<span>WCAG 2.1 AAA</span>
|
||||
</span>
|
||||
<span className="footer-pill-badge oss-badge">
|
||||
<span>AGPLv3 Açık Kaynak</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 2. Sütun: Stüdyolar */}
|
||||
<div className="footer-col">
|
||||
<h3 className="footer-col-title">Stüdyolar</h3>
|
||||
<ul className="footer-links-list">
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn"
|
||||
onClick={() => handleNav("home", "/")}
|
||||
>
|
||||
3D Katı CAD
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn"
|
||||
onClick={() => handleNav("home", "/")}
|
||||
>
|
||||
İt / Çek
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn"
|
||||
onClick={() => handleNav("drawing", "/?section=drawing")}
|
||||
>
|
||||
Teknik Resim
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn"
|
||||
onClick={() => handleNav("circuits", "/?section=circuits")}
|
||||
>
|
||||
Elektronik Devreler
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn"
|
||||
onClick={() => handleNav("codeblocks", "/?section=codeblocks")}
|
||||
>
|
||||
Kod Blokları
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn"
|
||||
onClick={() => handleNav("challenges", "/?section=challenges")}
|
||||
>
|
||||
Görevler
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* 3. Sütun: Kurumsal & Yasal */}
|
||||
<div className="footer-col">
|
||||
<h3 className="footer-col-title">Kurumsal & Yasal</h3>
|
||||
<ul className="footer-links-list">
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn"
|
||||
onClick={() => handleNav("about", "/hakkimizda")}
|
||||
>
|
||||
Hakkımızda
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn"
|
||||
onClick={() => handleNav("contact", "/iletisim")}
|
||||
>
|
||||
İletişim
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn"
|
||||
onClick={() => handleNav("customization", "/?section=customization")}
|
||||
>
|
||||
Erişilebilirlik
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn highlight-link"
|
||||
onClick={() => handleNav("kvkk", "/kvkk")}
|
||||
>
|
||||
KVKK & Gizlilik
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn highlight-link"
|
||||
onClick={() => handleNav("terms", "/kullanim-kosullari")}
|
||||
>
|
||||
Kullanım Koşulları
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-link-btn highlight-link"
|
||||
onClick={() => handleNav("security", "/kurumsal-guvenlik")}
|
||||
>
|
||||
Kurumsal Güvenlik
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* 4. Sütun: YakNet Ekosistemi */}
|
||||
<div className="footer-col">
|
||||
<h3 className="footer-col-title">YakNet Ekosistemi</h3>
|
||||
<ul className="footer-links-list">
|
||||
<li>
|
||||
<a
|
||||
href="https://developer-console.yakhub.com.tr"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="footer-link-btn external"
|
||||
>
|
||||
Geliştirici Konsolu
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://cdnjs.yakhub.com.tr"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="footer-link-btn external"
|
||||
>
|
||||
CDNJS
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://yakhub.com.tr"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="footer-link-btn external"
|
||||
>
|
||||
YakHub Ana Portal
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
href="https://account.yakhub.com.tr"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="footer-link-btn external"
|
||||
>
|
||||
YakNet Hesap (SSO)
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Alt Telif Barı */}
|
||||
<div className="footer-bottom-bar">
|
||||
<div className="footer-bottom-inner">
|
||||
<p className="copyright-text">
|
||||
© 2026 SnapCAD Studio. Resmi bir YakNet hizmetidir. YakHub Ekosistemi çatısı altında geliştirilmektedir. Tüm hakları saklıdır.
|
||||
</p>
|
||||
<div className="footer-bottom-meta">
|
||||
<button
|
||||
type="button"
|
||||
className="footer-meta-link-btn"
|
||||
onClick={() => handleNav("kvkk", "/kvkk")}
|
||||
>
|
||||
KVKK & Gizlilik
|
||||
</button>
|
||||
<span aria-hidden="true">•</span>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-meta-link-btn"
|
||||
onClick={() => handleNav("terms", "/kullanim-kosullari")}
|
||||
>
|
||||
Kullanım Koşulları
|
||||
</button>
|
||||
<span aria-hidden="true">•</span>
|
||||
<button
|
||||
type="button"
|
||||
className="footer-meta-link-btn"
|
||||
onClick={() => handleNav("security", "/kurumsal-guvenlik")}
|
||||
>
|
||||
Kurumsal Güvenlik
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { SERVICE_WORKER_URL } from "@/lib/serviceWorker";
|
||||
|
||||
interface BeforeInstallPromptEvent extends Event {
|
||||
prompt: () => Promise<void>;
|
||||
userChoice: Promise<{ outcome: "accepted" | "dismissed" }>;
|
||||
}
|
||||
|
||||
export function PwaManager() {
|
||||
const [installPrompt, setInstallPrompt] = useState<BeforeInstallPromptEvent | null>(null);
|
||||
const [isInstalled, setIsInstalled] = useState(false);
|
||||
const [showBanner, setShowBanner] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// 1. Register Service Worker
|
||||
let removeLoadListener: (() => void) | undefined;
|
||||
if (typeof window !== "undefined" && "serviceWorker" in navigator) {
|
||||
const register = () => {
|
||||
navigator.serviceWorker
|
||||
.register(SERVICE_WORKER_URL, { scope: "/", updateViaCache: "none" })
|
||||
.then((reg) => {
|
||||
// Check for updates periodically
|
||||
reg.addEventListener("updatefound", () => {
|
||||
const newWorker = reg.installing;
|
||||
if (newWorker) {
|
||||
newWorker.addEventListener("statechange", () => {
|
||||
if (newWorker.state === "installed" && navigator.serviceWorker.controller) {
|
||||
console.log("[SnapCAD PWA] Yeni sürüm mevcut, bir sonraki ziyarette aktif olacak.");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.warn("[SnapCAD PWA] Service Worker kayıt uyarısı:", err);
|
||||
});
|
||||
};
|
||||
// Hidrasyon yükleme (load) olayından sonra çalışırsa kayıt hiç
|
||||
// yapılmayabilir; sayfa hazırsa hemen, değilse load olayında kaydet.
|
||||
if (document.readyState === "complete") {
|
||||
register();
|
||||
} else {
|
||||
const onLoad = () => register();
|
||||
window.addEventListener("load", onLoad, { once: true });
|
||||
removeLoadListener = () => window.removeEventListener("load", onLoad);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Check if already running in standalone mode (installed app)
|
||||
const isStandalone =
|
||||
window.matchMedia("(display-mode: standalone)").matches ||
|
||||
(window.navigator as unknown as { standalone?: boolean }).standalone === true;
|
||||
if (isStandalone) {
|
||||
setIsInstalled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. Listen for browser install prompt (PWA installability)
|
||||
const handleBeforeInstall = (e: Event) => {
|
||||
e.preventDefault();
|
||||
setInstallPrompt(e as BeforeInstallPromptEvent);
|
||||
// Only show banner if user hasn't dismissed it recently
|
||||
const dismissed = localStorage.getItem("snapcad.pwa.dismissed");
|
||||
if (!dismissed) {
|
||||
setShowBanner(true);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("beforeinstallprompt", handleBeforeInstall);
|
||||
|
||||
// 4. Listen for app installed
|
||||
const handleAppInstalled = () => {
|
||||
setIsInstalled(true);
|
||||
setShowBanner(false);
|
||||
setInstallPrompt(null);
|
||||
};
|
||||
|
||||
window.addEventListener("appinstalled", handleAppInstalled);
|
||||
|
||||
return () => {
|
||||
removeLoadListener?.();
|
||||
window.removeEventListener("beforeinstallprompt", handleBeforeInstall);
|
||||
window.removeEventListener("appinstalled", handleAppInstalled);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleInstallClick = async () => {
|
||||
if (!installPrompt) return;
|
||||
try {
|
||||
await installPrompt.prompt();
|
||||
const choice = await installPrompt.userChoice;
|
||||
if (choice.outcome === "accepted") {
|
||||
setShowBanner(false);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("PWA install error:", err);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDismiss = () => {
|
||||
setShowBanner(false);
|
||||
try {
|
||||
localStorage.setItem("snapcad.pwa.dismissed", Date.now().toString());
|
||||
} catch {}
|
||||
};
|
||||
|
||||
if (!showBanner || isInstalled || !installPrompt) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: "fixed",
|
||||
bottom: "16px",
|
||||
left: "16px",
|
||||
zIndex: 9999,
|
||||
background: "rgba(15, 23, 42, 0.94)",
|
||||
backdropFilter: "blur(12px)",
|
||||
border: "1px solid rgba(56, 189, 248, 0.35)",
|
||||
borderRadius: "12px",
|
||||
boxShadow: "0 10px 30px rgba(0,0,0,0.45)",
|
||||
padding: "12px 16px",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "12px",
|
||||
maxWidth: "380px",
|
||||
animation: "fadeInUp 0.3s ease-out",
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src="/icons/icon-192.png"
|
||||
alt="SnapCAD"
|
||||
style={{
|
||||
width: "36px",
|
||||
height: "36px",
|
||||
borderRadius: "8px",
|
||||
flexShrink: 0,
|
||||
}}
|
||||
/>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<strong style={{ display: "block", color: "#f8fafc", fontSize: "13px", fontWeight: 600 }}>
|
||||
SnapCAD Uygulamasını Yükle
|
||||
</strong>
|
||||
<span style={{ display: "block", color: "#94a3b8", fontSize: "11px", lineHeight: 1.3 }}>
|
||||
Masaüstü veya mobil cihazınıza bağımsız uygulama olarak ekleyin.
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ display: "flex", gap: "6px" }}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleInstallClick}
|
||||
style={{
|
||||
background: "#0284c7",
|
||||
color: "#ffffff",
|
||||
border: "none",
|
||||
borderRadius: "6px",
|
||||
padding: "6px 10px",
|
||||
fontSize: "12px",
|
||||
fontWeight: 600,
|
||||
cursor: "pointer",
|
||||
whiteSpace: "nowrap",
|
||||
}}
|
||||
>
|
||||
Yükle
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleDismiss}
|
||||
style={{
|
||||
background: "transparent",
|
||||
color: "#64748b",
|
||||
border: "none",
|
||||
borderRadius: "6px",
|
||||
padding: "6px",
|
||||
fontSize: "14px",
|
||||
cursor: "pointer",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
title="Kapat"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect, useRef } from "react";
|
||||
import {
|
||||
Camera,
|
||||
Play,
|
||||
Pause,
|
||||
Plus,
|
||||
Trash2,
|
||||
Video,
|
||||
ChevronRight,
|
||||
Sparkles,
|
||||
Compass,
|
||||
} from "lucide-react";
|
||||
import type { ArchitecturalScene } from "@/types/sketchforge";
|
||||
|
||||
export interface ScenesBarProps {
|
||||
scenes: ArchitecturalScene[];
|
||||
onAddScene: () => void;
|
||||
onDeleteScene: (id: string) => void;
|
||||
onSelectScene: (scene: ArchitecturalScene) => void;
|
||||
}
|
||||
|
||||
export const ScenesBar: React.FC<ScenesBarProps> = ({
|
||||
scenes,
|
||||
onAddScene,
|
||||
onDeleteScene,
|
||||
onSelectScene,
|
||||
}) => {
|
||||
const [isPlaying, setIsPlaying] = useState(false);
|
||||
const [activeSceneId, setActiveSceneId] = useState<string | null>(null);
|
||||
const tourIndexRef = useRef(0);
|
||||
const tourTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
// Auto-play tour lifecycle
|
||||
useEffect(() => {
|
||||
if (!isPlaying || scenes.length < 2) {
|
||||
if (tourTimerRef.current) clearInterval(tourTimerRef.current);
|
||||
return;
|
||||
}
|
||||
|
||||
const playNext = () => {
|
||||
tourIndexRef.current = (tourIndexRef.current + 1) % scenes.length;
|
||||
const targetScene = scenes[tourIndexRef.current];
|
||||
if (targetScene) {
|
||||
setActiveSceneId(targetScene.id);
|
||||
onSelectScene(targetScene);
|
||||
}
|
||||
};
|
||||
|
||||
tourTimerRef.current = setInterval(playNext, 3800);
|
||||
return () => {
|
||||
if (tourTimerRef.current) clearInterval(tourTimerRef.current);
|
||||
};
|
||||
}, [isPlaying, scenes, onSelectScene]);
|
||||
|
||||
const handleToggleTour = () => {
|
||||
if (scenes.length === 0) return;
|
||||
if (!isPlaying) {
|
||||
// Start tour from first scene
|
||||
tourIndexRef.current = 0;
|
||||
setActiveSceneId(scenes[0].id);
|
||||
onSelectScene(scenes[0]);
|
||||
setIsPlaying(true);
|
||||
} else {
|
||||
setIsPlaying(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSelect = (scene: ArchitecturalScene) => {
|
||||
setIsPlaying(false);
|
||||
setActiveSceneId(scene.id);
|
||||
onSelectScene(scene);
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className="absolute bottom-12 left-1/2 z-20 flex -translate-x-1/2 items-center gap-2 rounded-2xl border border-slate-700/60 bg-slate-900/90 p-1.5 shadow-2xl backdrop-blur-md"
|
||||
role="toolbar"
|
||||
aria-label="Mimari Sahneler ve Sunum Turu"
|
||||
>
|
||||
{/* Label / Icon */}
|
||||
<div className="flex items-center gap-1.5 px-2.5 py-1 text-xs font-semibold text-sky-400">
|
||||
<Video className="h-4 w-4" />
|
||||
<span>Sahneler</span>
|
||||
</div>
|
||||
|
||||
{/* Scene Pills List */}
|
||||
<div className="flex max-w-[55vw] items-center gap-1.5 overflow-x-auto px-1 py-0.5 scrollbar-thin">
|
||||
{scenes.map((scene, idx) => {
|
||||
const isActive = activeSceneId === scene.id;
|
||||
return (
|
||||
<div
|
||||
key={scene.id}
|
||||
className={`group flex items-center gap-1.5 rounded-xl border px-3 py-1.5 text-xs font-medium transition-all ${
|
||||
isActive
|
||||
? "border-sky-500 bg-sky-500/20 text-sky-200 shadow-sm"
|
||||
: "border-slate-700 bg-slate-800/80 text-slate-300 hover:border-slate-600 hover:bg-slate-700/70"
|
||||
}`}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleSelect(scene)}
|
||||
className="flex items-center gap-1"
|
||||
title={`${scene.name} açısına geç`}
|
||||
>
|
||||
<Compass className="h-3 w-3 text-sky-400" />
|
||||
<span>{scene.name || `Sahne ${idx + 1}`}</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onDeleteScene(scene.id);
|
||||
}}
|
||||
className="ml-1 opacity-0 transition-opacity hover:text-rose-400 group-hover:opacity-100"
|
||||
title="Sahneyi sil"
|
||||
aria-label="Sahneyi sil"
|
||||
>
|
||||
<Trash2 className="h-3 w-3" />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Add Scene Button */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={onAddScene}
|
||||
className="flex items-center gap-1 rounded-xl bg-blue-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition-all hover:bg-blue-500 active:scale-95"
|
||||
title="Mevcut kamera açısını yeni bir sahne olarak kaydet"
|
||||
>
|
||||
<Plus className="h-3.5 w-3.5" />
|
||||
<span>Sahne Kaydet</span>
|
||||
</button>
|
||||
|
||||
{/* Play / Tour Button */}
|
||||
{scenes.length >= 2 && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleToggleTour}
|
||||
className={`flex items-center gap-1 rounded-xl px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition-all active:scale-95 ${
|
||||
isPlaying
|
||||
? "bg-amber-600 hover:bg-amber-500"
|
||||
: "bg-emerald-600 hover:bg-emerald-500"
|
||||
}`}
|
||||
title={isPlaying ? "Sinematik turu duraklat" : "Tüm sahneleri sırayla otomatik gez"}
|
||||
>
|
||||
{isPlaying ? (
|
||||
<>
|
||||
<Pause className="h-3.5 w-3.5" />
|
||||
<span>Durdur</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Play className="h-3.5 w-3.5 fill-current" />
|
||||
<span>Sinematik Tur</span>
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,303 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
ArrowLeft,
|
||||
Building2,
|
||||
CheckCircle2,
|
||||
Code2,
|
||||
Cpu,
|
||||
Database,
|
||||
EyeOff,
|
||||
FileText,
|
||||
KeyRound,
|
||||
Lock,
|
||||
Network,
|
||||
Server,
|
||||
Shield,
|
||||
ShieldCheck,
|
||||
Terminal,
|
||||
Zap,
|
||||
} from "lucide-react";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
interface SecurityPageContentProps {
|
||||
onBackToDashboard?: () => void;
|
||||
onGoToKVKK?: () => void;
|
||||
onGoToTerms?: () => void;
|
||||
}
|
||||
|
||||
export function SecurityPageContent({
|
||||
onBackToDashboard,
|
||||
onGoToKVKK,
|
||||
onGoToTerms,
|
||||
}: SecurityPageContentProps) {
|
||||
const headingRef = useRef<HTMLHeadingElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
headingRef.current?.focus();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<article className="snapcad-content-page legal-page" aria-labelledby="security-main-heading">
|
||||
{/* 1. Başlık Bölümü */}
|
||||
<header className="content-hero legal-hero">
|
||||
<div className="hero-badge">
|
||||
<ShieldCheck size={15} aria-hidden="true" />
|
||||
<span>Kurumsal Seviye Altyapı & Siber Güvenlik Mimarisi</span>
|
||||
</div>
|
||||
<h1
|
||||
id="security-main-heading"
|
||||
ref={headingRef}
|
||||
tabIndex={-1}
|
||||
className="hero-title outline-none focus:ring-2 focus:ring-sky-500 rounded-md"
|
||||
>
|
||||
Kurumsal Güvenlik
|
||||
</h1>
|
||||
<p className="hero-lead">
|
||||
SnapCAD Studio, resmi bir <strong>YakNet</strong> hizmetidir. Tasarımlarınızın, fikri mülkiyetinizin
|
||||
ve kurumsal projelerinizin güvenliği; sıfır bilgi (Zero-Knowledge) mimarisi ve YakNet ekosisteminin
|
||||
sağlam siber savunma kalkanı ile güvence altındadır.
|
||||
</p>
|
||||
<div className="legal-meta-tag-bar">
|
||||
<span className="legal-tag">
|
||||
<strong>Güvenlik Standardı:</strong> YakNet Kurumsal Altyapı
|
||||
</span>
|
||||
<span className="legal-tag">
|
||||
<strong>Şifreleme:</strong> TLS 1.3 & AES-256
|
||||
</span>
|
||||
<span className="legal-tag">
|
||||
<strong>Çekirdek Modeli:</strong> İstemci Taraflı (Local-First)
|
||||
</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* 2. YakNet Güvenlik Hizmet Kartı */}
|
||||
<div className="yaknet-affiliation-card" role="region" aria-label="YakNet Güvenlik Kalkanı">
|
||||
<div className="yaknet-affiliation-icon">
|
||||
<Shield size={28} className="text-sky-400" aria-hidden="true" />
|
||||
</div>
|
||||
<div className="yaknet-affiliation-body">
|
||||
<h2 className="yaknet-affiliation-title">YakNet Kurumsal Güvenlik Şemsiyesi</h2>
|
||||
<p className="yaknet-affiliation-text">
|
||||
SnapCAD Studio, YakNet bilgi ve iletişim ağının kurumsal altyapısı üzerinde çalışır.
|
||||
YakNet Güvenlik Operasyonları (SecOps), platformu 7/24 ağ tehditlerine, yetkisiz erişimlere ve
|
||||
hizmet kesintilerine karşı proaktif olarak izler ve savunur.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 3. Güvenlik Sütunları */}
|
||||
<div className="legal-sections-container">
|
||||
{/* Güvenlik Sütunu 1: İstemci Taraflı (Local-First) Güvenlik */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-localarch">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">01</span>
|
||||
<h2 id="sec-localarch" className="article-title">
|
||||
Sıfır Bilgi (Zero-Knowledge) & İstemci Taraflı CAD Çekirdeği
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
Geleneksel bulut CAD sistemlerinin aksine SnapCAD Studio, 3B geometri işleme motorunu
|
||||
(Manifold-3D ve OpenCASCADE WebAssembly) tamamen kullanıcının web tarayıcısında çalıştırır:
|
||||
</p>
|
||||
<div className="legal-subgrid">
|
||||
<div className="legal-subbox">
|
||||
<Cpu size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>Yerel Donanım Gücü</h4>
|
||||
<p>3B katı modelleme, pah kırma ve boolean işlemleri doğrudan kendi GPU ve CPU’nuzda hesaplanır.</p>
|
||||
</div>
|
||||
<div className="legal-subbox">
|
||||
<EyeOff size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>Ham Veri İletimi Yoktur</h4>
|
||||
<p>Tasarım adımlarınız sunucuya akmaz; endüstriyel sırlar ve patent taslakları tarayıcınızda kalır.</p>
|
||||
</div>
|
||||
<div className="legal-subbox">
|
||||
<Database size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>İsteğe Bağlı Bulut Yedekleme</h4>
|
||||
<p>Projeler sadece siz açıkça “Buluta Eşitle” dediğinizde şifreli paket olarak aktarılır.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Güvenlik Sütunu 2: YakNet SSO ve Kimlik Güvenliği */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-sso-auth">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">02</span>
|
||||
<h2 id="sec-sso-auth" className="article-title">
|
||||
YakNet SSO Tekil Oturum ve Yetkilendirme Güvenliği
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
SnapCAD Studio kullanıcı kimlik doğrulaması, YakNet ekosisteminin merkezi kimlik sağlayıcısı
|
||||
(OAuth 2.0 / OpenID Connect tabanlı SSO) ile korunur:
|
||||
</p>
|
||||
<ul className="legal-bullet-list">
|
||||
<li>
|
||||
<strong>HttpOnly ve SameSite Çerezler:</strong> Oturum anahtarları JavaScript tarafından okunamaz,
|
||||
XSS (Cross-Site Scripting) saldırılarına karşı tam yalıtım sağlanır.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Çapraz Alt Alan Güvenliği:</strong> <code>.yakhub.com.tr</code> alt alanları arasında
|
||||
güvenli kriptografik bilet değişimi uygulanır.
|
||||
</li>
|
||||
<li>
|
||||
<strong>Otomatik Oturum Senkronizasyonu:</strong> YakNet oturumu kapandığında SnapCAD Studio
|
||||
oturumları da güvenli şekilde sonlandırılır.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Güvenlik Sütunu 3: İletim ve Depolama Şifrelemesi */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-encryption">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">03</span>
|
||||
<h2 id="sec-encryption" className="article-title">
|
||||
Uçtan Uca İletim ve Depolama Şifrelemesi
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<div className="highlight-callout">
|
||||
<Lock size={20} className="text-sky-400 shrink-0" aria-hidden="true" />
|
||||
<div>
|
||||
<strong>Kurumsal Standartta Kriptografi:</strong> SnapCAD Studio ve YakNet arasındaki tüm
|
||||
ağ trafiği zorunlu TLS 1.3 protokolüyle şifrelenir. Güvenli olmayan (HTTP) bağlantılar
|
||||
anında engellenir ve HTTPS’e yönlendirilir.
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
YakNet Bulut Vault üzerinde depolanan kullanıcı tasarımları, projeleri ve sınıf ödevleri
|
||||
disk üzerinde dinlenme halinde (at-rest) AES-256 standardında şifrelenerek saklanır.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Güvenlik Sütunu 4: Kod Blokları Kum Havuzu (Sandbox) */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-sandbox">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">04</span>
|
||||
<h2 id="sec-sandbox" className="article-title">
|
||||
Kod Blokları ve Betik Kum Havuzu (Web Worker Sandbox)
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
Kod Blokları stüdyosunda kullanıcı tarafından oluşturulan parametrik döngüler ve kod parçacıkları,
|
||||
ana tarayıcı iş parçacığından izole edilmiş ayrı bir Web Worker kum havuzunda yürütülür:
|
||||
</p>
|
||||
<ul className="legal-bullet-list">
|
||||
<li>Kullanıcı betikleri ana sayfa DOM’una veya çerezlere doğrudan erişemez.</li>
|
||||
<li>İşlemci kilitlenmelerini önlemek için yürütme zaman aşımı ve kaynak kotaları uygulanır.</li>
|
||||
<li>Kötü amaçlı dış kaynak yükleme (remote script injection) katı CSP politikaları ile engellenir.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Güvenlik Sütunu 5: Sınıf ve Çoklu Kullanıcı İzolasyonu */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-class-isolation">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">05</span>
|
||||
<h2 id="sec-class-isolation" className="article-title">
|
||||
Sınıf Modülü ve Kurumsal Veri İzolasyonu
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
Eğitim kurumları ve atölyeler için Sınıfım modülünde rol tabanlı erişim kontrolü (RBAC) uygulanır:
|
||||
</p>
|
||||
<div className="legal-subgrid">
|
||||
<div className="legal-subbox">
|
||||
<KeyRound size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>Erişim Kodu Doğrulaması</h4>
|
||||
<p>Öğrenciler sınıflara rastgele giremez; benzersiz güvenli katılım kodları ile yetkilendirilir.</p>
|
||||
</div>
|
||||
<div className="legal-subbox">
|
||||
<ShieldCheck size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>Öğrenci Verisi Koruma</h4>
|
||||
<p>Öğrencilerin proje teslimleri sadece sınıf eğitmeni tarafından görüntülenebilir.</p>
|
||||
</div>
|
||||
<div className="legal-subbox">
|
||||
<Zap size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>Anında Erişim İptali</h4>
|
||||
<p>Eğitmen veya yönetici, sınıf erişim kodunu tek tıkla yenileyebilir veya oturumu kapatabilir.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Güvenlik Sütunu 6: Güvenlik Bildirimi & Bug Bounty */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-bug-bounty">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">06</span>
|
||||
<h2 id="sec-bug-bounty" className="article-title">
|
||||
Güvenlik Açığı Bildirimi ve Yanıt Süreci
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
SnapCAD Studio veya YakNet altyapısında olası bir güvenlik zafiyeti tespit ettiğinizi düşünüyorsanız,
|
||||
lütfen doğrudan YakNet Güvenlik Ekibi ile iletişime geçiniz:
|
||||
</p>
|
||||
<div className="legal-contact-box">
|
||||
<p>
|
||||
<strong>YakNet SecOps E-Posta:</strong>{" "}
|
||||
<a href="mailto:[email protected]" className="text-sky-400 font-semibold underline">
|
||||
destek@yakhub.com.tr
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<strong>Konu Başlığı:</strong> <code>[GÜVENLİK BİLDİRİMİ] SnapCAD Studio</code>
|
||||
</p>
|
||||
<p>
|
||||
Tüm güvenlik bildirimleri en geç 24 saat içerisinde teknik ekibimizce değerlendirmeye alınır.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{/* Alt Aksiyon Butonları */}
|
||||
<footer className="legal-page-actions">
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action-primary"
|
||||
onClick={() => {
|
||||
if (onBackToDashboard) onBackToDashboard();
|
||||
else window.location.href = "/";
|
||||
}}
|
||||
>
|
||||
<ArrowLeft size={16} aria-hidden="true" />
|
||||
<span>3B Stüdyoya Dön</span>
|
||||
</button>
|
||||
|
||||
<div className="legal-action-links">
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action-secondary"
|
||||
onClick={() => {
|
||||
if (onGoToKVKK) onGoToKVKK();
|
||||
else window.location.href = "/kvkk";
|
||||
}}
|
||||
>
|
||||
<ShieldCheck size={16} aria-hidden="true" />
|
||||
<span>KVKK & Gizlilik</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action-secondary"
|
||||
onClick={() => {
|
||||
if (onGoToTerms) onGoToTerms();
|
||||
else window.location.href = "/kullanim-kosullari";
|
||||
}}
|
||||
>
|
||||
<FileText size={16} aria-hidden="true" />
|
||||
<span>Kullanım Koşulları</span>
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
"use client";
|
||||
|
||||
import { Box, RefreshCw, RotateCcw } from "lucide-react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
interface SnapCADAppPreloaderProps {
|
||||
onComplete?: () => void;
|
||||
minDurationMs?: number;
|
||||
}
|
||||
|
||||
interface LoadingStage {
|
||||
progress: number;
|
||||
label: string;
|
||||
announcement: string;
|
||||
}
|
||||
|
||||
const STAGES: LoadingStage[] = [
|
||||
{
|
||||
progress: 15,
|
||||
label: "Sistem bileşenleri ve YakNet oturumu doğrulanıyor...",
|
||||
announcement: "SnapCAD Studio başlatılıyor. Yüzde 15, YakNet oturumu ve sistem bileşenleri doğrulanıyor.",
|
||||
},
|
||||
{
|
||||
progress: 45,
|
||||
label: "3B Geometri çekirdeği (OpenCASCADE & Manifold) yükleniyor...",
|
||||
announcement: "Yüzde 45, 3B Geometri çekirdeği ve matematiksel kütüphaneler yükleniyor.",
|
||||
},
|
||||
{
|
||||
progress: 80,
|
||||
label: "Çalışma alanı, mimari katmanlar ve projeler hazırlanıyor...",
|
||||
announcement: "Yüzde 80, Çalışma alanı, mimari katmanlar ve projeler eşitleniyor.",
|
||||
},
|
||||
{
|
||||
progress: 100,
|
||||
label: "Çalışma alanı hazır! Sayfa üstten alta yükleniyor...",
|
||||
announcement: "Yüzde 100, SnapCAD Studio hazır. Sayfa üstten alta başarıyla yüklendi.",
|
||||
},
|
||||
];
|
||||
|
||||
export function SnapCADAppPreloader({
|
||||
onComplete,
|
||||
minDurationMs = 850,
|
||||
}: SnapCADAppPreloaderProps) {
|
||||
const [stageIndex, setStageIndex] = useState(0);
|
||||
const [fadingOut, setFadingOut] = useState(false);
|
||||
const [showRecovery, setShowRecovery] = useState(false);
|
||||
const announcementRef = useRef<string>(STAGES[0].announcement);
|
||||
|
||||
useEffect(() => {
|
||||
// Toplam süreyi 4 aşamaya dengeli paylaştır
|
||||
const stageInterval = Math.max(160, Math.floor(minDurationMs / STAGES.length));
|
||||
|
||||
const intervalTimer = window.setInterval(() => {
|
||||
setStageIndex((prev) => {
|
||||
const next = prev + 1;
|
||||
if (next < STAGES.length) {
|
||||
announcementRef.current = STAGES[next].announcement;
|
||||
return next;
|
||||
} else {
|
||||
window.clearInterval(intervalTimer);
|
||||
return prev;
|
||||
}
|
||||
});
|
||||
}, stageInterval);
|
||||
|
||||
// Tamamlandığında yumuşak kapanış
|
||||
const finishTimer = window.setTimeout(() => {
|
||||
setFadingOut(true);
|
||||
const exitTimer = window.setTimeout(() => {
|
||||
onComplete?.();
|
||||
}, 260);
|
||||
return () => window.clearTimeout(exitTimer);
|
||||
}, minDurationMs + 80);
|
||||
|
||||
// 5 saniye aşılırsa kurtarma butonu sun
|
||||
const recoveryTimer = window.setTimeout(() => {
|
||||
setShowRecovery(true);
|
||||
}, 5000);
|
||||
|
||||
return () => {
|
||||
window.clearInterval(intervalTimer);
|
||||
window.clearTimeout(finishTimer);
|
||||
window.clearTimeout(recoveryTimer);
|
||||
};
|
||||
}, [minDurationMs, onComplete]);
|
||||
|
||||
const currentStage = STAGES[stageIndex] || STAGES[STAGES.length - 1];
|
||||
|
||||
const handleHardRefresh = () => {
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
const handleClearCacheAndRestart = () => {
|
||||
try {
|
||||
window.sessionStorage.clear();
|
||||
window.localStorage.removeItem("sketchforge.active_challenge");
|
||||
window.localStorage.removeItem("sketchforge.last_active_project");
|
||||
} catch {}
|
||||
window.location.href = "/";
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`snapcad-preloader-overlay ${fadingOut ? "preloader-fading-out" : ""}`}
|
||||
role="region"
|
||||
aria-label="SnapCAD Studio Yükleme Ekranı"
|
||||
>
|
||||
{/* Ekran Okuyucu Canlı Bölgesi (Screen Reader Announcement) */}
|
||||
<div
|
||||
className="sr-only"
|
||||
role="status"
|
||||
aria-live="assertive"
|
||||
aria-atomic="true"
|
||||
>
|
||||
{currentStage.announcement}
|
||||
</div>
|
||||
|
||||
<div className="preloader-content-card">
|
||||
{/* Parıldayan 3B Gem Rozeti */}
|
||||
<div className="preloader-gem-glow-wrapper" aria-hidden="true">
|
||||
<div className="preloader-gem-halo" />
|
||||
<div className="preloader-gem-box">
|
||||
<Box size={30} className="text-white" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Marka Başlığı & Ekosistem Etiketi */}
|
||||
<div className="preloader-brand-area">
|
||||
<h1 className="preloader-title">
|
||||
SnapCAD <span className="text-sky-400 font-bold">Studio</span>
|
||||
</h1>
|
||||
<span className="preloader-subtitle">Resmi YakNet Hizmeti • YakHub Ekosistemi</span>
|
||||
</div>
|
||||
|
||||
{/* Google Cloud Console Tarzı Kademeli ve Erişilebilir İlerleme Çubuğu */}
|
||||
<div
|
||||
className="preloader-progress-track"
|
||||
role="progressbar"
|
||||
aria-valuenow={currentStage.progress}
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuetext={`${currentStage.progress} yüzde, ${currentStage.label}`}
|
||||
>
|
||||
<div
|
||||
className="preloader-progress-bar"
|
||||
style={{ width: `${currentStage.progress}%` }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Canlı Yüzde ve Aşama Bilgisi */}
|
||||
<div className="preloader-status-container">
|
||||
<span className="preloader-percent-badge font-mono">%{currentStage.progress}</span>
|
||||
<p className="preloader-status-text">{currentStage.label}</p>
|
||||
</div>
|
||||
|
||||
{/* Uzun sürmesi durumunda beliren kurtarma kontrolleri */}
|
||||
{showRecovery ? (
|
||||
<div className="preloader-recovery-cluster snapcad-page-transition">
|
||||
<p className="recovery-notice-text">
|
||||
Yükleme beklenenden uzun mu sürdü? Tarayıcı önbelleğinizi tazeleyebilirsiniz:
|
||||
</p>
|
||||
<div className="recovery-buttons-row">
|
||||
<button
|
||||
type="button"
|
||||
className="recovery-action-btn primary"
|
||||
onClick={handleHardRefresh}
|
||||
>
|
||||
<RefreshCw size={14} aria-hidden="true" />
|
||||
<span>Sayfayı Yenile</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="recovery-action-btn secondary"
|
||||
onClick={handleClearCacheAndRestart}
|
||||
>
|
||||
<RotateCcw size={14} aria-hidden="true" />
|
||||
<span>Önbelleği Temizle & Başlat</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useId } from "react";
|
||||
import {
|
||||
Sun,
|
||||
X,
|
||||
Compass,
|
||||
Clock,
|
||||
Calendar,
|
||||
MapPin,
|
||||
Sparkles,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
calculateSunPosition,
|
||||
SOLAR_LOCATIONS,
|
||||
type SolarStudySettings,
|
||||
} from "@/lib/solarSystem";
|
||||
|
||||
export interface SolarStudyModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
settings: SolarStudySettings;
|
||||
onChange: (nextSettings: SolarStudySettings) => void;
|
||||
}
|
||||
|
||||
export const SolarStudyModal: React.FC<SolarStudyModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
settings,
|
||||
onChange,
|
||||
}) => {
|
||||
const baseId = useId();
|
||||
|
||||
// Escape to close
|
||||
useEffect(() => {
|
||||
if (!isOpen) return;
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape") onClose();
|
||||
};
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||
}, [isOpen, onClose]);
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
const handleSettingsChange = (nextSettings: SolarStudySettings) => {
|
||||
onChange(nextSettings);
|
||||
if (typeof window !== "undefined") {
|
||||
const sun = calculateSunPosition(nextSettings);
|
||||
window.dispatchEvent(new CustomEvent("snapcad:solar-update", { detail: sun }));
|
||||
}
|
||||
};
|
||||
|
||||
const sunData = calculateSunPosition(settings);
|
||||
|
||||
const formatHour = (val: number) => {
|
||||
const h = Math.floor(val);
|
||||
const m = Math.round((val - h) * 60);
|
||||
return `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}`;
|
||||
};
|
||||
|
||||
const seasons = [
|
||||
{ label: "İlkbahar (21 Mart)", month: 2, day: 21 },
|
||||
{ label: "Yaz (21 Haziran)", month: 5, day: 21 },
|
||||
{ label: "Sonbahar (23 Eylül)", month: 8, day: 23 },
|
||||
{ label: "Kış (21 Aralık)", month: 11, day: 21 },
|
||||
];
|
||||
|
||||
return (
|
||||
<div
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby={`${baseId}-title`}
|
||||
className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm"
|
||||
style={{
|
||||
position: "fixed",
|
||||
inset: 0,
|
||||
zIndex: 9999,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
background: "rgba(0,0,0,0.65)",
|
||||
backdropFilter: "blur(6px)",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="w-full max-w-lg rounded-2xl bg-slate-900 border border-slate-700 shadow-2xl p-6 text-slate-100 space-y-6"
|
||||
style={{
|
||||
width: "100%",
|
||||
maxWidth: "520px",
|
||||
background: "#0f172a",
|
||||
border: "1px solid #334155",
|
||||
borderRadius: "16px",
|
||||
padding: "24px",
|
||||
boxShadow: "0 20px 40px rgba(0,0,0,0.5)",
|
||||
color: "#f8fafc",
|
||||
}}
|
||||
>
|
||||
{/* Header */}
|
||||
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", borderBottom: "1px solid #1e293b", paddingBottom: "12px" }}>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "10px" }}>
|
||||
<div style={{ padding: "8px", borderRadius: "10px", background: "rgba(234, 179, 8, 0.15)", color: "#eab308" }}>
|
||||
<Sun size={22} />
|
||||
</div>
|
||||
<div>
|
||||
<h2 id={`${baseId}-title`} style={{ margin: 0, fontSize: "18px", fontWeight: 700 }}>
|
||||
Mimari Güneş & Gölge Etüdü
|
||||
</h2>
|
||||
<span style={{ fontSize: "12px", color: "#94a3b8" }}>
|
||||
Gerçek astronomik hesaplamalarla canlı bina gölgesi simülasyonu
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
aria-label="Kapat"
|
||||
style={{ background: "transparent", border: 0, color: "#94a3b8", cursor: "pointer", padding: "6px" }}
|
||||
>
|
||||
<X size={20} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Live Metrics Display */}
|
||||
<div
|
||||
style={{
|
||||
display: "grid",
|
||||
gridTemplateColumns: "1fr 1fr 1fr",
|
||||
gap: "10px",
|
||||
background: "#1e293b",
|
||||
padding: "12px",
|
||||
borderRadius: "10px",
|
||||
border: "1px solid #334155",
|
||||
textAlign: "center",
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<span style={{ fontSize: "11px", color: "#94a3b8", display: "block" }}>Güneş Yüksekliği</span>
|
||||
<strong style={{ fontSize: "16px", color: "#facc15" }}>
|
||||
{sunData.altitudeDegrees}°
|
||||
</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span style={{ fontSize: "11px", color: "#94a3b8", display: "block" }}>Azimuth (Yön)</span>
|
||||
<strong style={{ fontSize: "16px", color: "#38bdf8" }}>
|
||||
{sunData.azimuthDegrees}°
|
||||
</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span style={{ fontSize: "11px", color: "#94a3b8", display: "block" }}>Durum</span>
|
||||
<strong style={{ fontSize: "14px", color: sunData.isDaylight ? "#4ade80" : "#f87171" }}>
|
||||
{sunData.isDaylight ? "Gündüz" : "Gece"}
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Controls */}
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>
|
||||
{/* Hour Slider */}
|
||||
<div>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "6px" }}>
|
||||
<label style={{ fontSize: "13px", fontWeight: 600, display: "flex", alignItems: "center", gap: "6px" }}>
|
||||
<Clock size={16} className="text-amber-400" />
|
||||
<span>Günün Saati:</span>
|
||||
</label>
|
||||
<strong style={{ fontSize: "15px", color: "#facc15", fontFamily: "monospace" }}>
|
||||
{formatHour(settings.hour)}
|
||||
</strong>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min={6}
|
||||
max={21}
|
||||
step={0.25}
|
||||
value={settings.hour}
|
||||
onChange={(e) => handleSettingsChange({ ...settings, hour: parseFloat(e.target.value) })}
|
||||
style={{ width: "100%", accentColor: "#eab308", cursor: "pointer" }}
|
||||
/>
|
||||
{/* Quick Time Presets */}
|
||||
<div style={{ display: "flex", gap: "6px", marginTop: "8px" }}>
|
||||
{[
|
||||
{ label: "Sabah 08:30", h: 8.5 },
|
||||
{ label: "Öğle 12:00", h: 12.0 },
|
||||
{ label: "İkindi 16:30", h: 16.5 },
|
||||
{ label: "Gün Batımı 19:30", h: 19.5 },
|
||||
].map((preset) => (
|
||||
<button
|
||||
key={preset.label}
|
||||
type="button"
|
||||
onClick={() => handleSettingsChange({ ...settings, hour: preset.h })}
|
||||
style={{
|
||||
flex: 1,
|
||||
fontSize: "11px",
|
||||
padding: "4px 6px",
|
||||
borderRadius: "6px",
|
||||
background: Math.abs(settings.hour - preset.h) < 0.2 ? "#eab308" : "#1e293b",
|
||||
color: Math.abs(settings.hour - preset.h) < 0.2 ? "#0f172a" : "#cbd5e1",
|
||||
fontWeight: 600,
|
||||
border: "1px solid #334155",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
{preset.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Season / Month Presets */}
|
||||
<div>
|
||||
<label style={{ fontSize: "13px", fontWeight: 600, display: "flex", alignItems: "center", gap: "6px", marginBottom: "6px" }}>
|
||||
<Calendar size={16} className="text-sky-400" />
|
||||
<span>Mevsim & Ekinoks Dönemi:</span>
|
||||
</label>
|
||||
<div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "8px" }}>
|
||||
{seasons.map((s) => {
|
||||
const isSelected = settings.month === s.month && settings.day === s.day;
|
||||
return (
|
||||
<button
|
||||
key={s.label}
|
||||
type="button"
|
||||
onClick={() => handleSettingsChange({ ...settings, month: s.month, day: s.day })}
|
||||
style={{
|
||||
padding: "8px 10px",
|
||||
borderRadius: "8px",
|
||||
fontSize: "12px",
|
||||
fontWeight: 600,
|
||||
background: isSelected ? "#0284c7" : "#1e293b",
|
||||
color: isSelected ? "#ffffff" : "#cbd5e1",
|
||||
border: `1px solid ${isSelected ? "#38bdf8" : "#334155"}`,
|
||||
cursor: "pointer",
|
||||
textAlign: "left",
|
||||
}}
|
||||
>
|
||||
{s.label}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* City / Location */}
|
||||
<div>
|
||||
<label style={{ fontSize: "13px", fontWeight: 600, display: "flex", alignItems: "center", gap: "6px", marginBottom: "6px" }}>
|
||||
<MapPin size={16} className="text-emerald-400" />
|
||||
<span>Coğrafi Konum & Enlem:</span>
|
||||
</label>
|
||||
<select
|
||||
value={settings.locationIndex}
|
||||
onChange={(e) => handleSettingsChange({ ...settings, locationIndex: parseInt(e.target.value, 10) })}
|
||||
style={{
|
||||
width: "100%",
|
||||
padding: "8px 12px",
|
||||
borderRadius: "8px",
|
||||
background: "#1e293b",
|
||||
border: "1px solid #334155",
|
||||
color: "#f8fafc",
|
||||
fontSize: "13px",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
{SOLAR_LOCATIONS.map((loc, idx) => (
|
||||
<option key={loc.name} value={idx}>
|
||||
{loc.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div style={{ display: "flex", justifyContent: "flex-end", borderTop: "1px solid #1e293b", paddingTop: "14px" }}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
style={{
|
||||
padding: "8px 22px",
|
||||
borderRadius: "8px",
|
||||
background: "#0284c7",
|
||||
color: "#ffffff",
|
||||
fontSize: "13px",
|
||||
fontWeight: 600,
|
||||
border: 0,
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
Tamam
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,225 @@
|
||||
"use client";
|
||||
|
||||
import { Box, Compass, Download, FileText, Layers, Plus, Ruler, Search, Sparkles } from "lucide-react";
|
||||
import { useState, useMemo } from "react";
|
||||
import { VOCATIONAL_PRESETS, type VocationalDepartmentId } from "./TechnicalDrawingStudio";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
export type TechnicalDrawingProjectsDashboardProps = {
|
||||
projectShapes: WorkplaneShape[];
|
||||
projectName: string;
|
||||
onOpenProject: (presetId: VocationalDepartmentId) => void;
|
||||
onExportWorkpieceTo3D: (shapes: WorkplaneShape[], title: string) => void;
|
||||
};
|
||||
|
||||
export function TechnicalDrawingProjectsDashboard({
|
||||
projectShapes,
|
||||
projectName,
|
||||
onOpenProject,
|
||||
onExportWorkpieceTo3D,
|
||||
}: TechnicalDrawingProjectsDashboardProps) {
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [selectedDept, setSelectedDept] = useState<string>("all");
|
||||
|
||||
const departments = useMemo(() => {
|
||||
const list = Array.from(new Set(VOCATIONAL_PRESETS.map((p) => p.departmentBadge)));
|
||||
return ["all", ...list];
|
||||
}, []);
|
||||
|
||||
const filteredPresets = useMemo(() => {
|
||||
return VOCATIONAL_PRESETS.filter((p) => {
|
||||
const matchDept = selectedDept === "all" || p.departmentBadge === selectedDept;
|
||||
const matchQuery =
|
||||
!searchQuery ||
|
||||
p.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
p.description.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
p.subtitle.toLowerCase().includes(searchQuery.toLowerCase());
|
||||
return matchDept && matchQuery;
|
||||
});
|
||||
}, [selectedDept, searchQuery]);
|
||||
|
||||
return (
|
||||
<div className="snapcad-projects-dashboard">
|
||||
<div className="snapcad-dashboard-hero">
|
||||
<div>
|
||||
<span className="snapcad-pill-badge">
|
||||
<Ruler size={14} /> Mimari & Teknik Resim Projeleri
|
||||
</span>
|
||||
<h2>Teknik Resim & Mimari Pafta Projeleri Galerisi</h2>
|
||||
<p>
|
||||
Modüler proje galerisi mimarisiyle mimari kat planları, makine temrinleri, CNC lazer kesim ve mobilya paftalarınızı
|
||||
yönetin; dilediğiniz projeyi açıp düzenleyin, 3D modele aktarın veya DXF/PDF olarak indirin.
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="dashboard-primary"
|
||||
onClick={() => onOpenProject("mimari_plan")}
|
||||
>
|
||||
<Plus size={18} strokeWidth={2.6} />
|
||||
<span>Yeni Mimari / Teknik Pafta Başlat</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Hızlı Başlatma Kartları (Action Tiles) */}
|
||||
<div className="dashboard-actions-band snapcad-actions-band">
|
||||
<button
|
||||
className="dashboard-action-tile create"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("mimari_plan")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Plus size={24} strokeWidth={2.6} />
|
||||
</span>
|
||||
<span>Yeni Boş Pafta Başlat</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile snapcad-tile-drawing"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("mimari_plan")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Compass size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Mimari Villa Kat Planı (1/50)</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("makine_flans")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Ruler size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Kademeli Flanşlı Yatak (Makine)</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("metal_braket")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Layers size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>L-Tipi Motor Braketi (Metal CNC)</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="dashboard-action-tile"
|
||||
type="button"
|
||||
onClick={() => onOpenProject("project")}
|
||||
>
|
||||
<span className="dashboard-action-icon">
|
||||
<Box size={24} strokeWidth={2.4} />
|
||||
</span>
|
||||
<span>Aktif 3D Sahneyi Paftala ({projectShapes.length} Parça)</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Arama & Departman Filtreleri */}
|
||||
<div className="snapcad-dashboard-filter-bar">
|
||||
<div className="snapcad-search-box">
|
||||
<Search size={16} />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Mimari ve teknik resim projelerinde ara..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-filter-chips">
|
||||
{departments.map((dept) => (
|
||||
<button
|
||||
key={dept}
|
||||
type="button"
|
||||
className={`snapcad-filter-chip ${selectedDept === dept ? "active" : ""}`}
|
||||
onClick={() => setSelectedDept(dept)}
|
||||
>
|
||||
{dept === "all" ? "Tüm Projeler" : dept}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Proje Kartları Izgarası (Project Cards Grid) */}
|
||||
<div className="project-grid">
|
||||
{/* Özel: Aktif 3D Sahnenin Paftası Kartı */}
|
||||
<article className="project-card snapcad-project-card">
|
||||
<div className="snapcad-card-banner blueprint">
|
||||
<div className="snapcad-blueprint-grid" />
|
||||
<div className="snapcad-card-icon-badge">3D SAHNE</div>
|
||||
<span className="snapcad-card-source-tag">Özel İmalat Paftası</span>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-card-content">
|
||||
<div className="snapcad-card-head">
|
||||
<span className="snapcad-card-dept">Aktif 3D Tasarım</span>
|
||||
<span className="snapcad-card-std">TS EN ISO 128</span>
|
||||
</div>
|
||||
<h3 className="snapcad-card-title">{projectName || "Mevcut 3D Tasarım Paftası"}</h3>
|
||||
<p className="snapcad-card-desc">
|
||||
Şu anki 3D sahnenizdeki {projectShapes.length} nesnenin Ön, Üst, Yan epüz görünüşleri ve A-A kesiti.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-card-footer">
|
||||
<button
|
||||
type="button"
|
||||
className="snapcad-btn-tinker"
|
||||
onClick={() => onOpenProject("project")}
|
||||
>
|
||||
<Ruler size={16} />
|
||||
<span>Paftayı Aç & Düzenle</span>
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
{/* Standart & Mesleki Hazır Projeler */}
|
||||
{filteredPresets.map((preset) => (
|
||||
<article className="project-card snapcad-project-card" key={preset.id}>
|
||||
<div className={`snapcad-card-banner ${preset.id === "mimari_plan" ? "architectural" : "blueprint"}`}>
|
||||
<div className="snapcad-blueprint-grid" />
|
||||
<div className="snapcad-card-icon-badge">{preset.drawingNo}</div>
|
||||
<span className="snapcad-card-source-tag">{preset.material.split("(")[0]}</span>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-card-content">
|
||||
<div className="snapcad-card-head">
|
||||
<span className="snapcad-card-dept">{preset.departmentBadge}</span>
|
||||
<span className="snapcad-card-std">{preset.toleranceStd}</span>
|
||||
</div>
|
||||
<h3 className="snapcad-card-title">{preset.title}</h3>
|
||||
<p className="snapcad-card-subtitle">{preset.subtitle}</p>
|
||||
<p className="snapcad-card-desc">{preset.description}</p>
|
||||
</div>
|
||||
|
||||
<div className="snapcad-card-footer">
|
||||
<button
|
||||
type="button"
|
||||
className="snapcad-btn-tinker"
|
||||
onClick={() => onOpenProject(preset.id)}
|
||||
title="Teknik Resim ve Pafta Stüdyosunda Aç"
|
||||
>
|
||||
<Ruler size={16} />
|
||||
<span>Çizimi Aç / Paftala</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="snapcad-btn-ghost-icon"
|
||||
onClick={() => onExportWorkpieceTo3D(preset.shapes, preset.title)}
|
||||
title="Bu Projeyi 3D Tasarım Çalışma Düzlemine Gönder"
|
||||
>
|
||||
<Box size={16} />
|
||||
<span>3D'ye Aktar</span>
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,292 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
ArrowLeft,
|
||||
Award,
|
||||
Building2,
|
||||
CheckCircle2,
|
||||
ExternalLink,
|
||||
FileCheck,
|
||||
FileText,
|
||||
GraduationCap,
|
||||
Layers,
|
||||
Scale,
|
||||
ShieldAlert,
|
||||
ShieldCheck,
|
||||
Sparkles,
|
||||
} from "lucide-react";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
interface TermsPageContentProps {
|
||||
onBackToDashboard?: () => void;
|
||||
onGoToKVKK?: () => void;
|
||||
onGoToSecurity?: () => void;
|
||||
}
|
||||
|
||||
export function TermsPageContent({
|
||||
onBackToDashboard,
|
||||
onGoToKVKK,
|
||||
onGoToSecurity,
|
||||
}: TermsPageContentProps) {
|
||||
const headingRef = useRef<HTMLHeadingElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
headingRef.current?.focus();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<article className="snapcad-content-page legal-page" aria-labelledby="terms-main-heading">
|
||||
{/* 1. Başlık Bölümü */}
|
||||
<header className="content-hero legal-hero">
|
||||
<div className="hero-badge">
|
||||
<Scale size={15} aria-hidden="true" />
|
||||
<span>Resmi Hizmet Şartları & Kullanıcı Hakları Sözleşmesi</span>
|
||||
</div>
|
||||
<h1
|
||||
id="terms-main-heading"
|
||||
ref={headingRef}
|
||||
tabIndex={-1}
|
||||
className="hero-title outline-none focus:ring-2 focus:ring-sky-500 rounded-md"
|
||||
>
|
||||
Kullanım Koşulları
|
||||
</h1>
|
||||
<p className="hero-lead">
|
||||
SnapCAD Studio, bir <strong>YakNet</strong> hizmetidir ve <strong>YakHub Ekosistemi</strong>{" "}
|
||||
altyapısıyla sunulmaktadır. Platformumuzu kullanarak tasarımlarınızı oluştururken sahip olduğunuz
|
||||
hakları, fikri mülkiyet güvencelerini ve adil kullanım esaslarını bu metinde bulabilirsiniz.
|
||||
</p>
|
||||
<div className="legal-meta-tag-bar">
|
||||
<span className="legal-tag">
|
||||
<strong>Hizmet Ağı:</strong> YakNet Bulut Tasarım Platformu
|
||||
</span>
|
||||
<span className="legal-tag">
|
||||
<strong>Lisans Türü:</strong> AGPLv3 Açık Kaynak & Kurumsal Bulut
|
||||
</span>
|
||||
<span className="legal-tag">
|
||||
<strong>Son Güncelleme:</strong> Ekim 2026
|
||||
</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* 2. Resmi YakNet Hizmet Kartı */}
|
||||
<div className="yaknet-affiliation-card" role="region" aria-label="YakNet Hizmet Beyanı">
|
||||
<div className="yaknet-affiliation-icon">
|
||||
<Building2 size={28} className="text-sky-400" aria-hidden="true" />
|
||||
</div>
|
||||
<div className="yaknet-affiliation-body">
|
||||
<h2 className="yaknet-affiliation-title">Resmi YakNet ve YakHub Ekosistemi Hizmeti</h2>
|
||||
<p className="yaknet-affiliation-text">
|
||||
SnapCAD Studio, YakNet bilgi ağı tarafından geliştirilen ve barındırılan resmi bir 3B modelleme
|
||||
hizmetidir. YakNet Tekil Hesap (SSO) sistemi ile entegre çalışır; kullanıcılar YakNet kimlikleriyle
|
||||
ekosistem genelinde (YakTube, Geliştirici Konsolu, CDNJS ve SnapCAD) kesintisiz tek oturumla
|
||||
güvenli işlem yapabilirler.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 3. Maddeler Grid */}
|
||||
<div className="legal-sections-container">
|
||||
{/* Madde 1: Fikri Mülkiyet ve Tasarım Sahipliği */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-ip">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">01</span>
|
||||
<h2 id="sec-ip" className="article-title">
|
||||
3B Modellerinizin Mülkiyeti: %100 Size Aittir
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<div className="highlight-callout success-callout">
|
||||
<Award size={20} className="text-emerald-400 shrink-0" aria-hidden="true" />
|
||||
<div>
|
||||
<strong>Tam Fikri Hak Sahipliği:</strong> SnapCAD Studio stüdyolarında (Katı CAD, İt / Çek,
|
||||
Teknik Resim, Elektronik Devreler, Kod Blokları) tasarladığınız her geometrik model, parça,
|
||||
montaj veya devre şemasının fikri mülkiyet ve telif hakkı kayıtsız şartsız <strong>size aittir</strong>.
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
SnapCAD Studio veya YakNet; kullanıcıların ürettiği 3B tasarımlar, patentli endüstriyel modeller
|
||||
veya ticari prototipler üzerinde herhangi bir mülkiyet, lisans ücreti veya kullanım hakkı talep
|
||||
etmez. Modellerinizi dilediğiniz gibi ticari ürün haline getirebilir, satabilir, 3D yazıcı ile
|
||||
üretebilir veya açık kaynak olarak paylaşabilirsiniz.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 2: Hizmet Kullanımı ve YakNet Hesabı */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-account">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">02</span>
|
||||
<h2 id="sec-account" className="article-title">
|
||||
YakNet Hesabı ve Adil Kullanım İlkeleri
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
SnapCAD Studio’yu yerel tarayıcı belleğinizde hesap oluşturmadan da özgürce kullanabilirsiniz.
|
||||
Bulut eşitleme, sınıflar arası proje paylaşımı ve uzak yedekleme özelliklerinden yararlanmak için
|
||||
bir <strong>YakNet Hesabı</strong> kullanılır.
|
||||
</p>
|
||||
<ul className="legal-bullet-list">
|
||||
<li>Kullanıcı, YakNet hesabı üzerinden gerçekleştirdiği işlemlerden bizzat sorumludur.</li>
|
||||
<li>
|
||||
Platform altyapısına yönelik hizmet engelleme (DDoS), otomatik bot saldırısı veya tersine
|
||||
mühendislikle kötü amaçlı kod enjekte etme girişimleri yasaktır.
|
||||
</li>
|
||||
<li>
|
||||
Kod Blokları ortamında tarayıcıyı veya sunucuyu kilitleyecek sonsuz döngülü kötü niyetli betikler
|
||||
çalıştırılamaz.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 3: Eğitim ve Akademik Kullanım Garantisi */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-edu">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">03</span>
|
||||
<h2 id="sec-edu" className="article-title">
|
||||
Eğitim ve Okullar İçin Ücretsiz & Kapsayıcı Erişim
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
YakNet Ekosistemi, eğitimin dijitalleşmesini ve fırsat eşitliğini destekler.
|
||||
</p>
|
||||
<div className="legal-subgrid">
|
||||
<div className="legal-subbox">
|
||||
<GraduationCap size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>Eğitim Kurumlarına Ücretsiz</h4>
|
||||
<p>İlkokul, ortaokul, lise ve üniversite sınıfları için Sınıfım modülü tamamen ücretsizdir.</p>
|
||||
</div>
|
||||
<div className="legal-subbox">
|
||||
<Layers size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>WCAG 2.1 AAA Erişilebilirlik</h4>
|
||||
<p>Engelli öğrenciler ve mimarlar için ekran okuyucu ve sesli geri bildirim desteği sunar.</p>
|
||||
</div>
|
||||
<div className="legal-subbox">
|
||||
<FileCheck size={18} className="text-sky-400" aria-hidden="true" />
|
||||
<h4>Açık Standartlar</h4>
|
||||
<p>STL, OBJ, STEP, DXF, GLTF, SVG çıktıları hiçbir tescilli yazılıma bağımlı olmadan alınabilir.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 4: Açık Kaynak ve AGPLv3 Lisansı */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-opensource">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">04</span>
|
||||
<h2 id="sec-opensource" className="article-title">
|
||||
Açık Kaynak Şeffaflığı (AGPLv3)
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
SnapCAD Studio çekirdek motoru, özgür yazılım hareketine olan inancımız doğrultusunda AGPLv3
|
||||
(GNU Affero General Public License) lisansı altında geliştirilmektedir. Kaynak kodlarımız,
|
||||
topluluk denetimine ve şeffaf katkılara açıktır.
|
||||
</p>
|
||||
<p>
|
||||
Açık kaynak bileşenlerimizi incelemek, hata bildiriminde bulunmak veya katkı sağlamak için
|
||||
YakNet Geliştirici Konsolu’nu ve GitHub depolarımızı ziyaret edebilirsiniz.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 5: Sorumluluk Sınırları ve Endüstriyel İmalat */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-liability">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">05</span>
|
||||
<h2 id="sec-liability" className="article-title">
|
||||
Mühendislik ve İmalat Sorumluluk Reddi
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<div className="highlight-callout warning-callout">
|
||||
<ShieldAlert size={20} className="text-amber-400 shrink-0" aria-hidden="true" />
|
||||
<div>
|
||||
<strong>Fiziksel İmalat Öncesi Doğrulama Tavsiyesi:</strong> SnapCAD Studio, yüksek hassasiyetli
|
||||
parametrik modelleme sunmakla birlikte, CNC, döküm veya kritik havacılık/medikal parça imalatı
|
||||
öncesinde modellerin profesyonel metroloji ve analiz yazılımlarında doğrulanması kullanıcının
|
||||
sorumluluğundadır.
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
Platform “olduğu gibi” (as-is) sunulur. YakNet, yazılımın kullanımından kaynaklanabilecek
|
||||
fiziksel baskı fireleri, imalat toleransı uyuşmazlıkları veya veri aktarım kesintilerinden doğabilecek
|
||||
dolaylı zararlardan hukuken sorumlu tutulamaz.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Madde 6: Değişiklikler ve Yürürlük */}
|
||||
<section className="legal-article-card" aria-labelledby="sec-changes">
|
||||
<div className="legal-article-header">
|
||||
<span className="article-number">06</span>
|
||||
<h2 id="sec-changes" className="article-title">
|
||||
Şartlarda Değişiklik ve İletişim
|
||||
</h2>
|
||||
</div>
|
||||
<div className="article-body">
|
||||
<p>
|
||||
YakNet, bu kullanım koşullarını mevzuat değişiklikleri veya platforma eklenen yeni teknolojiler
|
||||
doğrultusunda güncelleme hakkını saklı tutar. Önemli değişiklikler platform üzerinden kullanıcılara
|
||||
duyurulur.
|
||||
</p>
|
||||
<div className="legal-contact-box">
|
||||
<p>
|
||||
<strong>Hukuki Bildirimler:</strong> YakNet & YakHub Hukuk Masası
|
||||
</p>
|
||||
<p>
|
||||
<strong>E-Posta:</strong>{" "}
|
||||
<a href="mailto:[email protected]" className="text-sky-400 font-semibold underline">
|
||||
destek@yakhub.com.tr
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{/* Alt Aksiyon Butonları */}
|
||||
<footer className="legal-page-actions">
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action-primary"
|
||||
onClick={() => {
|
||||
if (onBackToDashboard) onBackToDashboard();
|
||||
else window.location.href = "/";
|
||||
}}
|
||||
>
|
||||
<ArrowLeft size={16} aria-hidden="true" />
|
||||
<span>3B Stüdyoya Dön</span>
|
||||
</button>
|
||||
|
||||
<div className="legal-action-links">
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action-secondary"
|
||||
onClick={() => {
|
||||
if (onGoToKVKK) onGoToKVKK();
|
||||
else window.location.href = "/kvkk";
|
||||
}}
|
||||
>
|
||||
<ShieldCheck size={16} aria-hidden="true" />
|
||||
<span>KVKK & Gizlilik</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn-action-secondary"
|
||||
onClick={() => {
|
||||
if (onGoToSecurity) onGoToSecurity();
|
||||
else window.location.href = "/kurumsal-guvenlik";
|
||||
}}
|
||||
>
|
||||
<ShieldCheck size={16} aria-hidden="true" />
|
||||
<span>Kurumsal Güvenlik</span>
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useId } from "react";
|
||||
import {
|
||||
Mountain,
|
||||
X,
|
||||
Sparkles,
|
||||
Layers,
|
||||
Check,
|
||||
Sliders,
|
||||
} from "lucide-react";
|
||||
import { createLocalId } from "@/lib/localIds";
|
||||
import type { WorkplaneShape, ArchitecturalTextureId } from "@/types/sketchforge";
|
||||
|
||||
export interface TerrainGeneratorModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onAddShape: (shape: WorkplaneShape) => void;
|
||||
}
|
||||
|
||||
type TerrainPreset = "hills" | "slope" | "terrace" | "valley";
|
||||
|
||||
export const TerrainGeneratorModal: React.FC<TerrainGeneratorModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
onAddShape,
|
||||
}) => {
|
||||
const baseId = useId();
|
||||
const [preset, setPreset] = useState<TerrainPreset>("hills");
|
||||
const [width, setWidth] = useState(200);
|
||||
const [depth, setDepth] = useState(200);
|
||||
const [maxHeight, setMaxHeight] = useState(18);
|
||||
const [texture, setTexture] = useState<ArchitecturalTextureId>("grass");
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
const handleGenerate = () => {
|
||||
// Generate grid vertices (e.g. 16x16 grid for clean performance)
|
||||
const segments = 16;
|
||||
const halfW = width / 2;
|
||||
const halfD = depth / 2;
|
||||
const positions: number[] = [];
|
||||
const normals: number[] = [];
|
||||
|
||||
// Height function based on preset
|
||||
const getHeight = (u: number, v: number) => {
|
||||
// u, v in [0, 1]
|
||||
if (preset === "hills") {
|
||||
return (
|
||||
Math.sin(u * Math.PI * 2) * Math.cos(v * Math.PI * 2) * maxHeight * 0.5 +
|
||||
Math.sin(u * Math.PI * 4 + v * 2) * (maxHeight * 0.25) +
|
||||
maxHeight * 0.5
|
||||
);
|
||||
}
|
||||
if (preset === "slope") {
|
||||
return u * maxHeight + Math.sin(v * Math.PI * 3) * (maxHeight * 0.15);
|
||||
}
|
||||
if (preset === "valley") {
|
||||
const distFromCenter = Math.abs(u - 0.5) * 2;
|
||||
return distFromCenter * distFromCenter * maxHeight;
|
||||
}
|
||||
// terrace
|
||||
const stepped = Math.floor(u * 4) / 4;
|
||||
return stepped * maxHeight;
|
||||
};
|
||||
|
||||
const getNormal = (u: number, v: number) => {
|
||||
const eps = 0.01;
|
||||
const hL = getHeight(Math.max(0, u - eps), v);
|
||||
const hR = getHeight(Math.min(1, u + eps), v);
|
||||
const hD = getHeight(u, Math.max(0, v - eps));
|
||||
const hU = getHeight(u, Math.min(1, v + eps));
|
||||
const dx = (hR - hL) / (2 * eps * width);
|
||||
const dz = (hU - hD) / (2 * eps * depth);
|
||||
const len = Math.sqrt(dx * dx + 1 + dz * dz);
|
||||
return [-dx / len, 1 / len, -dz / len];
|
||||
};
|
||||
|
||||
// Build triangles
|
||||
for (let i = 0; i < segments; i++) {
|
||||
for (let j = 0; j < segments; j++) {
|
||||
const u0 = i / segments;
|
||||
const u1 = (i + 1) / segments;
|
||||
const v0 = j / segments;
|
||||
const v1 = (j + 1) / segments;
|
||||
|
||||
const x0 = -halfW + u0 * width;
|
||||
const x1 = -halfW + u1 * width;
|
||||
const z0 = -halfD + v0 * depth;
|
||||
const z1 = -halfD + v1 * depth;
|
||||
|
||||
const y00 = getHeight(u0, v0);
|
||||
const y10 = getHeight(u1, v0);
|
||||
const y01 = getHeight(u0, v1);
|
||||
const y11 = getHeight(u1, v1);
|
||||
|
||||
const n00 = getNormal(u0, v0);
|
||||
const n10 = getNormal(u1, v0);
|
||||
const n01 = getNormal(u0, v1);
|
||||
const n11 = getNormal(u1, v1);
|
||||
|
||||
// Triangle 1: (0,0), (1,0), (0,1)
|
||||
positions.push(x0, y00, z0, x1, y10, z0, x0, y01, z1);
|
||||
normals.push(...n00, ...n10, ...n01);
|
||||
|
||||
// Triangle 2: (1,0), (1,1), (0,1)
|
||||
positions.push(x1, y10, z0, x1, y11, z1, x0, y01, z1);
|
||||
normals.push(...n10, ...n11, ...n01);
|
||||
}
|
||||
}
|
||||
|
||||
const terrainShape: WorkplaneShape = {
|
||||
id: createLocalId("terrain"),
|
||||
name:
|
||||
preset === "hills"
|
||||
? "Dalgalı Tepe Arazisi"
|
||||
: preset === "slope"
|
||||
? "Eğimli Arsa"
|
||||
: preset === "valley"
|
||||
? "Vadi Arazisi"
|
||||
: "Teraslı Arsa",
|
||||
kind: "mesh",
|
||||
color: texture === "grass" ? "#22c55e" : "#64748b",
|
||||
texture,
|
||||
tag: "Arazi / Topoğrafya",
|
||||
x: 0,
|
||||
z: 0,
|
||||
elevation: 0,
|
||||
size: Math.max(width, depth),
|
||||
width,
|
||||
depth,
|
||||
height: Math.max(5, maxHeight),
|
||||
rotation: 0,
|
||||
importedMesh: {
|
||||
positions,
|
||||
normals,
|
||||
baseWidth: width,
|
||||
baseDepth: depth,
|
||||
baseHeight: maxHeight,
|
||||
triangleCount: positions.length / 9,
|
||||
sourceFormat: "json",
|
||||
},
|
||||
};
|
||||
|
||||
onAddShape(terrainShape);
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="terrain-title"
|
||||
>
|
||||
<div className="relative flex max-h-[90vh] w-full max-w-md flex-col rounded-2xl border border-slate-200 bg-white shadow-2xl dark:border-slate-800 dark:bg-slate-900">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between border-b border-slate-200 px-6 py-4 dark:border-slate-800">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-emerald-500/10 text-emerald-600 dark:bg-emerald-500/20 dark:text-emerald-400">
|
||||
<Mountain className="h-5 w-5" />
|
||||
</div>
|
||||
<div>
|
||||
<h2
|
||||
id="terrain-title"
|
||||
className="text-lg font-bold text-slate-900 dark:text-white"
|
||||
>
|
||||
Arazi & Topoğrafya Oluşturucu
|
||||
</h2>
|
||||
<p className="text-xs text-slate-500 dark:text-slate-400">
|
||||
Binanızı kot farkı ve eğimli araziye oturtun
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-lg p-2 text-slate-400 transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
aria-label="Kapat"
|
||||
>
|
||||
<X className="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="flex-1 space-y-4 overflow-y-auto px-6 py-4 text-sm">
|
||||
{/* Preset Selection */}
|
||||
<div>
|
||||
<label className="mb-2 block text-xs font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400">
|
||||
Arazi Tipi
|
||||
</label>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{[
|
||||
{ id: "hills", label: "Dalgalı Tepe", desc: "Doğal yükseltiler" },
|
||||
{ id: "slope", label: "Eğimli Arsa", desc: "Tek yöne meyil" },
|
||||
{ id: "terrace", label: "Teraslı Plato", desc: "Kademeli kotlar" },
|
||||
{ id: "valley", label: "Vadi / Çukur", desc: "Ortası alçak" },
|
||||
].map((item) => (
|
||||
<button
|
||||
key={item.id}
|
||||
type="button"
|
||||
onClick={() => setPreset(item.id as TerrainPreset)}
|
||||
className={`flex flex-col items-start rounded-xl border p-2.5 text-left transition-all ${
|
||||
preset === item.id
|
||||
? "border-emerald-500 bg-emerald-50/70 text-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-200"
|
||||
: "border-slate-200 hover:border-slate-300 dark:border-slate-800 dark:hover:border-slate-700"
|
||||
}`}
|
||||
>
|
||||
<span className="font-semibold text-xs">{item.label}</span>
|
||||
<span className="text-[10px] text-slate-400">{item.desc}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Sliders */}
|
||||
<div className="space-y-3 rounded-xl border border-slate-100 bg-slate-50/60 p-3.5 dark:border-slate-800 dark:bg-slate-900/40">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs text-slate-600 dark:text-slate-300">Genişlik & Derinlik</span>
|
||||
<span className="font-mono text-xs font-semibold">{width} × {depth} mm</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min="100"
|
||||
max="350"
|
||||
step="10"
|
||||
value={width}
|
||||
onChange={(e) => {
|
||||
const val = Number(e.target.value);
|
||||
setWidth(val);
|
||||
setDepth(val);
|
||||
}}
|
||||
className="w-full accent-emerald-600"
|
||||
/>
|
||||
|
||||
<div className="flex items-center justify-between pt-1">
|
||||
<span className="text-xs text-slate-600 dark:text-slate-300">Tepe / Kot Yüksekliği</span>
|
||||
<span className="font-mono text-xs font-semibold">{maxHeight} mm</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min="4"
|
||||
max="45"
|
||||
step="1"
|
||||
value={maxHeight}
|
||||
onChange={(e) => setMaxHeight(Number(e.target.value))}
|
||||
className="w-full accent-emerald-600"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Texture */}
|
||||
<div>
|
||||
<label className="mb-2 block text-xs font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400">
|
||||
Yüzey Kaplaması
|
||||
</label>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setTexture("grass")}
|
||||
className={`flex-1 rounded-xl border py-2 text-xs font-medium transition-all ${
|
||||
texture === "grass"
|
||||
? "border-emerald-500 bg-emerald-500 text-white shadow-sm"
|
||||
: "border-slate-200 dark:border-slate-700"
|
||||
}`}
|
||||
>
|
||||
🌱 Çim & Doğa
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setTexture("concrete")}
|
||||
className={`flex-1 rounded-xl border py-2 text-xs font-medium transition-all ${
|
||||
texture === "concrete"
|
||||
? "border-emerald-500 bg-emerald-500 text-white shadow-sm"
|
||||
: "border-slate-200 dark:border-slate-700"
|
||||
}`}
|
||||
>
|
||||
🧱 Toprak & Beton
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="flex items-center justify-end gap-2 border-t border-slate-200 bg-slate-50 px-6 py-3.5 dark:border-slate-800 dark:bg-slate-950/50">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-xl px-4 py-2 text-xs font-semibold text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
>
|
||||
İptal
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleGenerate}
|
||||
className="flex items-center gap-1.5 rounded-xl bg-emerald-600 px-5 py-2 text-xs font-semibold text-white shadow-sm hover:bg-emerald-500 active:scale-95"
|
||||
>
|
||||
<Sparkles className="h-4 w-4" />
|
||||
<span>Araziyi Oluştur</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,355 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useMemo } from "react";
|
||||
import {
|
||||
X,
|
||||
Scissors,
|
||||
Check,
|
||||
DoorOpen,
|
||||
Maximize,
|
||||
Sliders,
|
||||
Layers,
|
||||
Sparkles,
|
||||
} from "lucide-react";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
export interface WallCutoutConfig {
|
||||
kind: "window" | "door";
|
||||
width: number;
|
||||
height: number;
|
||||
elevation: number;
|
||||
offsetX: number; // offset along wall length from center in mm
|
||||
addFrameAndGlass: boolean;
|
||||
frameColor?: string;
|
||||
glassColor?: string;
|
||||
}
|
||||
|
||||
export interface WallOpeningModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
shapes: WorkplaneShape[];
|
||||
selectedShapeId?: string | null;
|
||||
onApplyCutout: (wallId: string, config: WallCutoutConfig) => void;
|
||||
}
|
||||
|
||||
interface OpeningPreset {
|
||||
id: string;
|
||||
label: string;
|
||||
kind: "window" | "door";
|
||||
icon: string;
|
||||
width: number;
|
||||
height: number;
|
||||
elevation: number;
|
||||
description: string;
|
||||
}
|
||||
|
||||
const PRESETS: OpeningPreset[] = [
|
||||
{
|
||||
id: "std-window",
|
||||
label: "Standart Tek Kanat Pencere",
|
||||
kind: "window",
|
||||
icon: "🪟",
|
||||
width: 30,
|
||||
height: 30,
|
||||
elevation: 20,
|
||||
description: "30x30 mm (Parapet/Denizlik yüksekliği: 20 mm)",
|
||||
},
|
||||
{
|
||||
id: "wide-window",
|
||||
label: "Geniş Salon / Manzara Penceresi",
|
||||
kind: "window",
|
||||
icon: "🖼️",
|
||||
width: 60,
|
||||
height: 35,
|
||||
elevation: 18,
|
||||
description: "60x35 mm geniş açılı panoramik açıklık",
|
||||
},
|
||||
{
|
||||
id: "room-door",
|
||||
label: "Standart İç Oda Kapısı",
|
||||
kind: "door",
|
||||
icon: "🚪",
|
||||
width: 25,
|
||||
height: 50,
|
||||
elevation: 0,
|
||||
description: "25x50 mm (Zeminden sıfır parapet)",
|
||||
},
|
||||
{
|
||||
id: "balcony-door",
|
||||
label: "Çift Kanatlı Balkon / Fransız Kapı",
|
||||
kind: "door",
|
||||
icon: "🚪",
|
||||
width: 45,
|
||||
height: 52,
|
||||
elevation: 0,
|
||||
description: "45x52 mm geniş balkon ve bahçe kapısı",
|
||||
},
|
||||
];
|
||||
|
||||
export const WallOpeningModal: React.FC<WallOpeningModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
shapes,
|
||||
selectedShapeId,
|
||||
onApplyCutout,
|
||||
}) => {
|
||||
// Candidate walls: rectangular solid shapes
|
||||
const candidateWalls = useMemo(() => {
|
||||
return shapes.filter(
|
||||
(s) =>
|
||||
!s.hole &&
|
||||
!s.hidden &&
|
||||
(s.kind === "box" || Boolean(s.groupedShapes?.length))
|
||||
);
|
||||
}, [shapes]);
|
||||
|
||||
const [activeWallId, setActiveWallId] = useState<string>(() => {
|
||||
if (selectedShapeId && candidateWalls.some((w) => w.id === selectedShapeId)) {
|
||||
return selectedShapeId;
|
||||
}
|
||||
return candidateWalls[0]?.id || "";
|
||||
});
|
||||
|
||||
const selectedWall = useMemo(() => {
|
||||
return candidateWalls.find((w) => w.id === activeWallId) || candidateWalls[0] || null;
|
||||
}, [candidateWalls, activeWallId]);
|
||||
|
||||
const wallWidth = selectedWall?.width ?? selectedWall?.size ?? 120;
|
||||
const wallHeight = selectedWall?.height ?? selectedWall?.size ?? 60;
|
||||
|
||||
const [selectedPresetId, setSelectedPresetId] = useState<string>("std-window");
|
||||
const [kind, setKind] = useState<"window" | "door">("window");
|
||||
const [width, setWidth] = useState<number>(30);
|
||||
const [height, setHeight] = useState<number>(30);
|
||||
const [elevation, setElevation] = useState<number>(20);
|
||||
const [offsetX, setOffsetX] = useState<number>(0);
|
||||
const [addFrameAndGlass, setAddFrameAndGlass] = useState<boolean>(true);
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
const handleSelectPreset = (preset: OpeningPreset) => {
|
||||
setSelectedPresetId(preset.id);
|
||||
setKind(preset.kind);
|
||||
setWidth(preset.width);
|
||||
setHeight(preset.height);
|
||||
setElevation(preset.elevation);
|
||||
};
|
||||
|
||||
const handleApply = () => {
|
||||
if (!selectedWall) return;
|
||||
onApplyCutout(selectedWall.id, {
|
||||
kind,
|
||||
width,
|
||||
height,
|
||||
elevation,
|
||||
offsetX,
|
||||
addFrameAndGlass,
|
||||
frameColor: "#475569",
|
||||
glassColor: "#38bdf8",
|
||||
});
|
||||
onClose();
|
||||
};
|
||||
|
||||
const maxOffsetX = Math.max(0, Math.floor((wallWidth - width) / 2));
|
||||
|
||||
return (
|
||||
<div
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="Duvar Pencere ve Kapı Boşluğu Aç"
|
||||
className="fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4 backdrop-blur-md"
|
||||
>
|
||||
<div className="relative flex w-full max-w-lg flex-col gap-4 rounded-3xl border border-sky-500/40 bg-slate-900/95 p-6 text-slate-100 shadow-2xl backdrop-blur-xl">
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between border-b border-slate-800 pb-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-2xl bg-gradient-to-tr from-amber-500 to-rose-600 text-white shadow-lg shadow-amber-500/30">
|
||||
<Scissors className="h-5 w-5" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-base font-extrabold text-white">
|
||||
Duvar Boşluğu Aç (Pencere & Kapı Kesimi)
|
||||
</h2>
|
||||
<p className="text-xs text-slate-400">
|
||||
Seçilen duvarın ortasını kesip net bir pencere/kapı boşluğu oluşturun
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-xl p-1.5 text-slate-400 hover:bg-slate-800 hover:text-white"
|
||||
title="Kapat (ESC)"
|
||||
>
|
||||
<X className="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 1. Wall Selector */}
|
||||
<div className="flex flex-col gap-1.5">
|
||||
<label className="text-xs font-semibold text-slate-300 flex items-center gap-1.5">
|
||||
<Layers className="h-4 w-4 text-sky-400" />
|
||||
<span>Kesilecek Duvar / Gövde:</span>
|
||||
</label>
|
||||
{candidateWalls.length === 0 ? (
|
||||
<div className="rounded-xl border border-rose-500/40 bg-rose-500/10 p-3 text-xs text-rose-300">
|
||||
Sahnede uygun bir duvar veya kutu kütlesi bulunamadı. Lütfen önce sahneye bir duvar ekleyin.
|
||||
</div>
|
||||
) : (
|
||||
<select
|
||||
value={selectedWall?.id || ""}
|
||||
onChange={(e) => setActiveWallId(e.target.value)}
|
||||
className="w-full rounded-xl border border-slate-700 bg-slate-800 px-3 py-2 text-xs font-medium text-white focus:border-sky-500 focus:outline-none"
|
||||
>
|
||||
{candidateWalls.map((w) => (
|
||||
<option key={w.id} value={w.id}>
|
||||
{w.name || "Duvar"} ({w.width ?? w.size ?? 120}x{w.depth ?? w.size ?? 20}x{w.height ?? w.size ?? 60} mm)
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 2. Presets */}
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-xs font-semibold text-slate-300">Hazır Boşluk Şablonları:</span>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{PRESETS.map((p) => {
|
||||
const isSelected = selectedPresetId === p.id;
|
||||
return (
|
||||
<button
|
||||
key={p.id}
|
||||
type="button"
|
||||
onClick={() => handleSelectPreset(p)}
|
||||
className={`flex flex-col items-start rounded-2xl border p-2.5 text-left transition-all ${
|
||||
isSelected
|
||||
? "border-amber-400 bg-amber-500/20 text-white shadow-md ring-1 ring-amber-400"
|
||||
: "border-slate-800 bg-slate-800/60 text-slate-300 hover:border-slate-700 hover:bg-slate-800"
|
||||
}`}
|
||||
>
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<span className="text-base">{p.icon}</span>
|
||||
{isSelected && <Check className="h-4 w-4 text-amber-400" />}
|
||||
</div>
|
||||
<span className="mt-1 text-xs font-bold text-white">{p.label}</span>
|
||||
<span className="text-[10px] text-slate-400">{p.description}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 3. Dimensional Fine-Tuning */}
|
||||
<div className="flex flex-col gap-2 rounded-2xl border border-slate-800 bg-slate-800/40 p-3 text-xs">
|
||||
<div className="flex items-center justify-between text-slate-300">
|
||||
<span className="font-semibold flex items-center gap-1.5">
|
||||
<Sliders className="h-3.5 w-3.5 text-amber-400" />
|
||||
<span>Ölçü ve Konum Ayarları</span>
|
||||
</span>
|
||||
<span className="text-[10px] text-slate-400">
|
||||
Duvar: {wallWidth} x {wallHeight} mm
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-3 gap-2 pt-1">
|
||||
<div className="flex flex-col gap-1">
|
||||
<label className="text-[11px] text-slate-400">Genişlik (mm):</label>
|
||||
<input
|
||||
type="number"
|
||||
min={10}
|
||||
max={wallWidth - 5}
|
||||
value={width}
|
||||
onChange={(e) => {
|
||||
setSelectedPresetId("custom");
|
||||
setWidth(Math.max(5, Number(e.target.value)));
|
||||
}}
|
||||
className="rounded-lg border border-slate-700 bg-slate-900 px-2 py-1 text-xs font-bold text-white"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<label className="text-[11px] text-slate-400">Yükseklik (mm):</label>
|
||||
<input
|
||||
type="number"
|
||||
min={10}
|
||||
max={wallHeight - 5}
|
||||
value={height}
|
||||
onChange={(e) => {
|
||||
setSelectedPresetId("custom");
|
||||
setHeight(Math.max(5, Number(e.target.value)));
|
||||
}}
|
||||
className="rounded-lg border border-slate-700 bg-slate-900 px-2 py-1 text-xs font-bold text-white"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<label className="text-[11px] text-slate-400">Denizlik/Yerden (mm):</label>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={wallHeight - height - 2}
|
||||
value={elevation}
|
||||
onChange={(e) => {
|
||||
setSelectedPresetId("custom");
|
||||
setElevation(Math.max(0, Number(e.target.value)));
|
||||
}}
|
||||
className="rounded-lg border border-slate-700 bg-slate-900 px-2 py-1 text-xs font-bold text-white"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Position along wall length slider */}
|
||||
<div className="flex flex-col gap-1 pt-2">
|
||||
<div className="flex justify-between text-[11px] text-slate-400">
|
||||
<span>Duvar Boyunca Konum:</span>
|
||||
<span className="font-bold text-amber-300">
|
||||
{offsetX === 0 ? "Tam Ortada (0 mm)" : offsetX < 0 ? `Sola ${Math.abs(offsetX)} mm` : `Sağa ${offsetX} mm`}
|
||||
</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min={-maxOffsetX}
|
||||
max={maxOffsetX}
|
||||
step={1}
|
||||
value={offsetX}
|
||||
onChange={(e) => setOffsetX(Number(e.target.value))}
|
||||
className="w-full accent-amber-500 cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 4. Glass + Frame Checkbox */}
|
||||
<label className="flex items-center gap-2.5 rounded-xl border border-slate-800 bg-slate-800/30 p-2.5 text-xs text-slate-200 cursor-pointer hover:bg-slate-800/60">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={addFrameAndGlass}
|
||||
onChange={(e) => setAddFrameAndGlass(e.target.checked)}
|
||||
className="h-4 w-4 rounded accent-sky-500"
|
||||
/>
|
||||
<span className="flex items-center gap-1.5 font-medium">
|
||||
<Sparkles className="h-4 w-4 text-sky-400" />
|
||||
<span>Açılan boşluğa otomatik doğrama kasası ve cam panel yerleştir</span>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
{/* Footer actions */}
|
||||
<div className="flex items-center justify-end gap-2 border-t border-slate-800 pt-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="rounded-xl border border-slate-700 bg-slate-800 px-4 py-2 text-xs font-semibold text-slate-300 hover:bg-slate-700 hover:text-white"
|
||||
>
|
||||
İptal
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!selectedWall}
|
||||
onClick={handleApply}
|
||||
className="flex items-center gap-2 rounded-xl border border-amber-400/60 bg-gradient-to-r from-amber-500 to-rose-600 px-5 py-2 text-xs font-bold text-white shadow-lg shadow-amber-500/30 transition-all hover:from-amber-400 hover:to-rose-500 disabled:opacity-40"
|
||||
>
|
||||
<Scissors className="h-4 w-4" />
|
||||
<span>Boşluğu Kes ve Aç</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,871 @@
|
||||
"use client";
|
||||
|
||||
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
CheckCircle2,
|
||||
Cloud,
|
||||
CloudOff,
|
||||
Loader2,
|
||||
LogIn,
|
||||
LogOut,
|
||||
RefreshCw,
|
||||
Trash2,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import type { GridSize, WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
|
||||
import type { PlacementWorkplane } from "@/lib/placementWorkplane";
|
||||
import { formatByteSize, type CloudProjectCollection, type CloudProjectSyncSkip } from "@/lib/cloudProjectSync";
|
||||
|
||||
export interface CloudProjectPayload {
|
||||
id: string;
|
||||
name: string;
|
||||
category?: string;
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
revision: number;
|
||||
accent: "cyan" | "green" | "gold" | "red";
|
||||
workspace?: WorkplaneWorkspaceSettings;
|
||||
snapGrid?: GridSize;
|
||||
placementElevation?: number;
|
||||
placementWorkplane?: PlacementWorkplane;
|
||||
sketchPlacementWorkplane?: PlacementWorkplane;
|
||||
shapes: WorkplaneShape[];
|
||||
cloudSynced?: boolean;
|
||||
cloudUpdatedAt?: string;
|
||||
shareCode?: string;
|
||||
isPublic?: boolean;
|
||||
}
|
||||
|
||||
export interface YakNetUser {
|
||||
id: number;
|
||||
name: string;
|
||||
email: string;
|
||||
avatar?: string | null;
|
||||
auth_source?: string;
|
||||
}
|
||||
|
||||
const SNAPCAD_OAUTH_CLIENT_ID = "01a1315f-9db9-70ee-9983-0d3397773ecd";
|
||||
const SNAPCAD_CALLBACK_URI = "https://snap.yakhub.com.tr/callback.php";
|
||||
const YAKNET_AUTH_BASE = "https://developer-console.yakhub.com.tr";
|
||||
|
||||
interface YakNetCloudBarProps {
|
||||
onCollectLocalProjectsForCloud: (options?: { maxProjectBytes?: number }) => Promise<CloudProjectCollection<CloudProjectPayload>>;
|
||||
onApplyCloudProjects: (cloudProjects: CloudProjectPayload[]) => Promise<void>;
|
||||
autoSyncTrigger?: number;
|
||||
onNotice?: (message: string) => void;
|
||||
}
|
||||
|
||||
export function YakNetCloudBar({
|
||||
onCollectLocalProjectsForCloud,
|
||||
onApplyCloudProjects,
|
||||
autoSyncTrigger = 0,
|
||||
onNotice,
|
||||
}: YakNetCloudBarProps) {
|
||||
const [user, setUser] = useState<YakNetUser | null>(null);
|
||||
const [dbConnected, setDbConnected] = useState<boolean>(false);
|
||||
const [cloudProjectCount, setCloudProjectCount] = useState<number>(0);
|
||||
const [lastSyncedAt, setLastSyncedAt] = useState<string | null>(null);
|
||||
|
||||
const [syncing, setSyncing] = useState<boolean>(false);
|
||||
const [modalOpen, setModalOpen] = useState<boolean>(false);
|
||||
const [cloudList, setCloudList] = useState<CloudProjectPayload[]>([]);
|
||||
const [localOnlyProjects, setLocalOnlyProjects] = useState<CloudProjectSyncSkip[]>([]);
|
||||
const [maxProjectBytes, setMaxProjectBytes] = useState<number>(0);
|
||||
const [statusBanner, setStatusBanner] = useState<{ type: "ok" | "err" | "info"; text: string } | null>(null);
|
||||
|
||||
const accountWidgetHostRef = useRef<HTMLDivElement | null>(null);
|
||||
const initialSyncDoneRef = useRef<boolean>(false);
|
||||
const userRef = useRef<YakNetUser | null>(null);
|
||||
const isSyncingSsoRef = useRef<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
userRef.current = user;
|
||||
}, [user]);
|
||||
|
||||
// 1. CDNJS YakNet Hesap Menüsü Web Component'ini ve Silent SSO Frame'ini yükle
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
// YakNet SSO Script'ini CDN üzerinden yükle
|
||||
const scriptId = "yaknet-account-cdn-script";
|
||||
if (!document.getElementById(scriptId)) {
|
||||
const script = document.createElement("script");
|
||||
script.id = scriptId;
|
||||
script.src = "https://cdnjs.yakhub.com.tr/ajax/libs/yaknet-account/latest/yaknet-account.js";
|
||||
script.async = true;
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
// YakNet Silent Cross-Subdomain SSO Frame'i doğrudan developer-console üzerinden hazırla
|
||||
const iframeId = "yaknet-sso-iframe-instance";
|
||||
let iframe = document.getElementById(iframeId) as HTMLIFrameElement | null;
|
||||
if (!iframe) {
|
||||
iframe = document.createElement("iframe");
|
||||
iframe.id = iframeId;
|
||||
iframe.src = `${YAKNET_AUTH_BASE}/sdk/sso-frame`;
|
||||
iframe.title = "YakNet Oturum Kontrolü";
|
||||
iframe.setAttribute("aria-hidden", "true");
|
||||
iframe.setAttribute("tabindex", "-1");
|
||||
iframe.style.display = "none";
|
||||
iframe.style.width = "0";
|
||||
iframe.style.height = "0";
|
||||
iframe.style.border = "0";
|
||||
document.body.appendChild(iframe);
|
||||
} else if (!iframe.src || !iframe.src.includes("developer-console.yakhub.com.tr")) {
|
||||
iframe.src = `${YAKNET_AUTH_BASE}/sdk/sso-frame`;
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 2. Bulut projelerini çek ve yerel çalışma alanıyla eşitle
|
||||
const performCloudSync = useCallback(
|
||||
async (silent = false) => {
|
||||
setSyncing(true);
|
||||
try {
|
||||
const collection = await onCollectLocalProjectsForCloud({ maxProjectBytes });
|
||||
const localPayloads = collection.projects;
|
||||
const res = await fetch("/cloud-api.php?action=sync_all", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
action: "sync_all",
|
||||
projects: localPayloads,
|
||||
}),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok && data.ok && Array.isArray(data.projects)) {
|
||||
const serverSkipped: CloudProjectSyncSkip[] = Array.isArray(data.skipped)
|
||||
? data.skipped.map((entry: { id?: string; name?: string; reason?: string; bytes?: number }) => ({
|
||||
id: String(entry?.id ?? ""),
|
||||
name: String(entry?.name ?? "Adsız Tasarım"),
|
||||
shapeCount: 0,
|
||||
bytes: Number(entry?.bytes ?? 0),
|
||||
reason: "too-large" as const,
|
||||
}))
|
||||
: [];
|
||||
const skippedById = new Map<string, CloudProjectSyncSkip>();
|
||||
for (const skip of [...collection.skipped, ...serverSkipped]) {
|
||||
if (skip.id && !skippedById.has(skip.id)) skippedById.set(skip.id, skip);
|
||||
}
|
||||
const skippedProjects = Array.from(skippedById.values());
|
||||
setLocalOnlyProjects(skippedProjects);
|
||||
setCloudList(data.projects);
|
||||
setCloudProjectCount(data.projects.length);
|
||||
setLastSyncedAt(data.synced_at || new Date().toISOString());
|
||||
await onApplyCloudProjects(data.projects);
|
||||
if (skippedProjects.length) {
|
||||
const names = skippedProjects
|
||||
.slice(0, 3)
|
||||
.map((project) => `"${project.name}"${project.reason === "too-large" ? ` (${formatByteSize(project.bytes)})` : ""}`)
|
||||
.join(", ");
|
||||
const extra = skippedProjects.length > 3 ? ` ve ${skippedProjects.length - 3} proje daha` : "";
|
||||
const warning = `${names}${extra} boyutu veya yerel kopyası nedeniyle buluta yedeklenemedi. Bu projeler yalnızca bu tarayıcıda saklanıyor; yedek için "Dosyayı Dışa Aktar" ile .skf dosyası oluşturun.`;
|
||||
setStatusBanner({ type: "info", text: warning });
|
||||
onNotice?.(`YakNet Bulut: ${warning}`);
|
||||
} else if (!silent) {
|
||||
setStatusBanner({
|
||||
type: "ok",
|
||||
text: `Tasarımlarınız YakNet Bulut ile eşitlendi (${data.projects.length} proje).`,
|
||||
});
|
||||
onNotice?.(`YakNet Bulut: ${data.projects.length} proje eşitlendi.`);
|
||||
}
|
||||
} else if (!silent) {
|
||||
setStatusBanner({
|
||||
type: "err",
|
||||
text: data.error || "Bulut senkronizasyonu tamamlanamadı.",
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
if (!silent) {
|
||||
setStatusBanner({
|
||||
type: "err",
|
||||
text: "YakNet Bulut servisine şu anda ulaşılamıyor.",
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
setSyncing(false);
|
||||
}
|
||||
},
|
||||
[maxProjectBytes, onApplyCloudProjects, onCollectLocalProjectsForCloud, onNotice],
|
||||
);
|
||||
|
||||
// 3. YakNet SSO Oturumunu Sunucu ile Eşitle (accessibility-console & yaktube mimarisi)
|
||||
const syncSsoSession = useCallback(
|
||||
async (ssoUser: Partial<YakNetUser>) => {
|
||||
if (!ssoUser || isSyncingSsoRef.current) return;
|
||||
if (
|
||||
userRef.current &&
|
||||
(userRef.current.id === Number(ssoUser.id) ||
|
||||
(ssoUser.email && userRef.current.email === ssoUser.email))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
isSyncingSsoRef.current = true;
|
||||
try {
|
||||
// İstemciden gelen SSO verisi güvenilmez; sunucudaki doğrulanmış OAuth
|
||||
// oturumunu sorgularız. Oturum yoksa hiçbir şey yapmayız.
|
||||
const res = await fetch("/cloud-api.php?action=session", {
|
||||
method: "GET",
|
||||
cache: "no-store",
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.ok && data.authenticated && data.user) {
|
||||
const syncedUser: YakNetUser = data.user || {
|
||||
id: Number(ssoUser.id || 1),
|
||||
name: ssoUser.name || "YakNet Kullanıcısı",
|
||||
email: ssoUser.email || "",
|
||||
avatar: ssoUser.avatar || null,
|
||||
auth_source: "yaknet_sso_script",
|
||||
};
|
||||
|
||||
setUser(syncedUser);
|
||||
userRef.current = syncedUser;
|
||||
setDbConnected(Boolean(data.db_connected ?? true));
|
||||
setMaxProjectBytes(Number(data.limits?.max_project_bytes ?? 0) || 0);
|
||||
|
||||
if (data.cloud_stats) {
|
||||
setCloudProjectCount(Number(data.cloud_stats.project_count || 0));
|
||||
setLastSyncedAt(data.cloud_stats.last_synced_at || null);
|
||||
}
|
||||
|
||||
setStatusBanner({
|
||||
type: "ok",
|
||||
text: `YakNet oturumunuz otomatik algılandı: ${syncedUser.name}`,
|
||||
});
|
||||
onNotice?.(`YakNet Bulut: ${syncedUser.name} oturumu otomatik bağlandı.`);
|
||||
|
||||
window.dispatchEvent(
|
||||
new CustomEvent("yaknet-session-synced", {
|
||||
detail: { authenticated: true, user: syncedUser },
|
||||
}),
|
||||
);
|
||||
|
||||
if (!initialSyncDoneRef.current) {
|
||||
initialSyncDoneRef.current = true;
|
||||
void performCloudSync(true);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("[SnapCAD] YakNet SSO eşitleme bildirimi:", err);
|
||||
} finally {
|
||||
isSyncingSsoRef.current = false;
|
||||
}
|
||||
},
|
||||
[onNotice, performCloudSync],
|
||||
);
|
||||
|
||||
// 4. SSO Çıkış İşlemi
|
||||
const handleSsoLogout = useCallback(
|
||||
async (redirect = false) => {
|
||||
setUser(null);
|
||||
userRef.current = null;
|
||||
setCloudList([]);
|
||||
setCloudProjectCount(0);
|
||||
try {
|
||||
await fetch("/cloud-api.php?action=logout", { method: "POST" });
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
window.dispatchEvent(
|
||||
new CustomEvent("yaknet-session-synced", {
|
||||
detail: { authenticated: false, user: null },
|
||||
}),
|
||||
);
|
||||
if (redirect) {
|
||||
window.location.href = "/logout.php";
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
// 5. Oturum durumunu sunucudan kontrol et
|
||||
const checkSession = useCallback(async () => {
|
||||
try {
|
||||
const res = await fetch("/cloud-api.php?action=session", { cache: "no-store" });
|
||||
if (!res.ok) return;
|
||||
const data = await res.json();
|
||||
if (data.ok) {
|
||||
setDbConnected(Boolean(data.db_connected));
|
||||
setMaxProjectBytes(Number(data.limits?.max_project_bytes ?? 0) || 0);
|
||||
if (data.cloud_stats) {
|
||||
setCloudProjectCount(Number(data.cloud_stats.project_count || 0));
|
||||
setLastSyncedAt(data.cloud_stats.last_synced_at || null);
|
||||
}
|
||||
if (data.authenticated && data.user) {
|
||||
setUser(data.user);
|
||||
userRef.current = data.user;
|
||||
if (!initialSyncDoneRef.current) {
|
||||
initialSyncDoneRef.current = true;
|
||||
void performCloudSync(true);
|
||||
}
|
||||
} else {
|
||||
setUser(null);
|
||||
userRef.current = null;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// ignore offline
|
||||
}
|
||||
}, [performCloudSync]);
|
||||
|
||||
// 6. Global SSO Olaylarını Dinle (YAKNET_SSO_STATUS & yaknet-auth)
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
const handleWindowMessage = (e: MessageEvent) => {
|
||||
if (!e.data || e.data.type !== "YAKNET_SSO_STATUS") return;
|
||||
if (e.data.authenticated && e.data.user) {
|
||||
void syncSsoSession(e.data.user);
|
||||
} else if (e.data.authenticated === false && userRef.current) {
|
||||
void handleSsoLogout(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleYaknetAuthEvent = (e: Event) => {
|
||||
const customEvt = e as CustomEvent<{ authenticated?: boolean; user?: YakNetUser | null }>;
|
||||
if (customEvt.detail) {
|
||||
if (customEvt.detail.authenticated && customEvt.detail.user) {
|
||||
void syncSsoSession(customEvt.detail.user);
|
||||
} else if (customEvt.detail.authenticated === false && userRef.current) {
|
||||
void handleSsoLogout(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("message", handleWindowMessage);
|
||||
window.addEventListener("yaknet-auth", handleYaknetAuthEvent);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("message", handleWindowMessage);
|
||||
window.removeEventListener("yaknet-auth", handleYaknetAuthEvent);
|
||||
};
|
||||
}, [handleSsoLogout, syncSsoSession]);
|
||||
|
||||
useEffect(() => {
|
||||
void checkSession();
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
if (params.get("cloud_login") === "1") {
|
||||
onNotice?.("YakNet hesabınızla giriş yapıldı. Tasarımlarınız eşitleniyor...");
|
||||
window.history.replaceState(null, "", window.location.pathname);
|
||||
} else if (params.get("logged_out") === "1") {
|
||||
setUser(null);
|
||||
userRef.current = null;
|
||||
setCloudList([]);
|
||||
setCloudProjectCount(0);
|
||||
onNotice?.("YakNet oturumunuz güvenli bir şekilde kapatıldı.");
|
||||
window.history.replaceState(null, "", window.location.pathname);
|
||||
} else if (params.get("oauth_error")) {
|
||||
const errText = params.get("oauth_error") || "Oturum hatası";
|
||||
setModalOpen(true);
|
||||
setStatusBanner({ type: "err", text: `YakNet Giriş Hatası: ${errText}` });
|
||||
window.history.replaceState(null, "", window.location.pathname);
|
||||
}
|
||||
}
|
||||
}, [checkSession, onNotice]);
|
||||
|
||||
// 7. <yaknet-account> Web Component'ini DOM içinde oluştur / güncelle ve Çıkış olaylarını dinle
|
||||
useEffect(() => {
|
||||
const host = accountWidgetHostRef.current;
|
||||
if (!host) return;
|
||||
|
||||
let el = host.querySelector("yaknet-account") as HTMLElement | null;
|
||||
if (!el) {
|
||||
el = document.createElement("yaknet-account");
|
||||
// connectedCallback öncesinde özellikleri eksiksiz ata (SSO frame URL doğruluğu için kritik)
|
||||
el.setAttribute("base-url", YAKNET_AUTH_BASE);
|
||||
el.setAttribute("client-id", SNAPCAD_OAUTH_CLIENT_ID);
|
||||
el.setAttribute("redirect-uri", SNAPCAD_CALLBACK_URI);
|
||||
el.setAttribute("login-url", "/login.php");
|
||||
el.setAttribute("logout-url", "/logout.php");
|
||||
el.setAttribute("theme", "light");
|
||||
if (user) {
|
||||
el.setAttribute("authenticated", "true");
|
||||
el.setAttribute("user-name", user.name);
|
||||
el.setAttribute("user-email", user.email);
|
||||
} else {
|
||||
el.setAttribute("authenticated", "false");
|
||||
}
|
||||
host.innerHTML = "";
|
||||
host.appendChild(el);
|
||||
} else {
|
||||
const setAttrIfChanged = (target: HTMLElement, attr: string, val: string | null) => {
|
||||
if (val === null) {
|
||||
if (target.hasAttribute(attr)) target.removeAttribute(attr);
|
||||
} else if (target.getAttribute(attr) !== val) {
|
||||
target.setAttribute(attr, val);
|
||||
}
|
||||
};
|
||||
|
||||
setAttrIfChanged(el, "base-url", YAKNET_AUTH_BASE);
|
||||
setAttrIfChanged(el, "login-url", "/login.php");
|
||||
setAttrIfChanged(el, "logout-url", "/logout.php");
|
||||
setAttrIfChanged(el, "redirect-uri", SNAPCAD_CALLBACK_URI);
|
||||
setAttrIfChanged(el, "client-id", SNAPCAD_OAUTH_CLIENT_ID);
|
||||
setAttrIfChanged(el, "theme", "light");
|
||||
if (user) {
|
||||
setAttrIfChanged(el, "authenticated", "true");
|
||||
setAttrIfChanged(el, "user-name", user.name);
|
||||
setAttrIfChanged(el, "user-email", user.email);
|
||||
} else {
|
||||
setAttrIfChanged(el, "authenticated", "false");
|
||||
setAttrIfChanged(el, "user-name", null);
|
||||
setAttrIfChanged(el, "user-email", null);
|
||||
}
|
||||
}
|
||||
|
||||
// Menüden "Oturumu Kapat" tıklandığında yerel + merkezi çıkışı tetikle
|
||||
const handleLogoutEvent = () => {
|
||||
void handleSsoLogout(true);
|
||||
};
|
||||
|
||||
el.addEventListener("yaknet-logout", handleLogoutEvent);
|
||||
return () => {
|
||||
el?.removeEventListener("yaknet-logout", handleLogoutEvent);
|
||||
};
|
||||
}, [handleSsoLogout, user]);
|
||||
|
||||
// 8. Otomatik bulut kaydı (kullanıcı projede değişiklik yaptığında arka planda eşitle)
|
||||
useEffect(() => {
|
||||
if (!user || autoSyncTrigger <= 0) return;
|
||||
const timer = window.setTimeout(() => {
|
||||
void performCloudSync(true);
|
||||
}, 2500);
|
||||
return () => window.clearTimeout(timer);
|
||||
}, [autoSyncTrigger, performCloudSync, user]);
|
||||
|
||||
const handleDeleteCloudProject = async (projectUid: string) => {
|
||||
try {
|
||||
const res = await fetch("/cloud-api.php?action=delete", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ action: "delete", project_uid: projectUid }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok && data.ok) {
|
||||
setCloudList((prev) => prev.filter((p) => p.id !== projectUid));
|
||||
setCloudProjectCount((prev) => Math.max(0, prev - 1));
|
||||
setStatusBanner({ type: "ok", text: "Tasarım bulut hesabınızdan kaldırıldı." });
|
||||
}
|
||||
} catch {
|
||||
setStatusBanner({ type: "err", text: "Tasarım silinemedi." });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="yaknet-topbar-cluster"
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "10px",
|
||||
marginLeft: "auto",
|
||||
marginRight: "8px",
|
||||
}}
|
||||
>
|
||||
{/* YakNet Bulut Durum Butonu */}
|
||||
<button
|
||||
type="button"
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded={modalOpen}
|
||||
onClick={() => {
|
||||
setModalOpen(true);
|
||||
if (user) {
|
||||
void performCloudSync(true);
|
||||
}
|
||||
}}
|
||||
title="YakNet Bulut"
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: "7px",
|
||||
padding: "7px 12px",
|
||||
borderRadius: "10px",
|
||||
border: user
|
||||
? "1px solid rgba(16, 185, 129, 0.45)"
|
||||
: "1px solid rgba(255, 255, 255, 0.22)",
|
||||
background: user
|
||||
? "rgba(16, 185, 129, 0.16)"
|
||||
: "rgba(15, 23, 42, 0.35)",
|
||||
color: "#ffffff",
|
||||
fontSize: "12.5px",
|
||||
fontWeight: 600,
|
||||
cursor: "pointer",
|
||||
whiteSpace: "nowrap",
|
||||
}}
|
||||
>
|
||||
{syncing ? (
|
||||
<Loader2 size={15} className="spinning" />
|
||||
) : user ? (
|
||||
<Cloud size={15} color="#34d399" />
|
||||
) : (
|
||||
<CloudOff size={15} color="#94a3b8" />
|
||||
)}
|
||||
<span>
|
||||
{user
|
||||
? `Bulut (${cloudProjectCount})`
|
||||
: "YakNet Bulut"}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{/* YakNet Hesabı Menüsü Web Component (<yaknet-account>) */}
|
||||
<div
|
||||
ref={accountWidgetHostRef}
|
||||
aria-label="YakNet Hesabı ve Ekosistem Menüsü"
|
||||
style={{ display: "flex", alignItems: "center", minHeight: "36px" }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* YakNet Bulut Tasarım Yönetimi Modalı */}
|
||||
{modalOpen ? (
|
||||
<div
|
||||
style={{
|
||||
position: "fixed",
|
||||
inset: 0,
|
||||
zIndex: 9999,
|
||||
background: "rgba(15, 23, 42, 0.68)",
|
||||
backdropFilter: "blur(6px)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
padding: "16px",
|
||||
}}
|
||||
onClick={(e) => {
|
||||
if (e.target === e.currentTarget) setModalOpen(false);
|
||||
}}
|
||||
>
|
||||
<div
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="yaknet-cloud-modal-title"
|
||||
aria-describedby="yaknet-cloud-modal-desc"
|
||||
tabIndex={-1}
|
||||
style={{
|
||||
width: "100%",
|
||||
maxWidth: "680px",
|
||||
maxHeight: "88vh",
|
||||
overflowY: "auto",
|
||||
background: "#0f172a",
|
||||
color: "#f8fafc",
|
||||
borderRadius: "18px",
|
||||
border: "1px solid #1e293b",
|
||||
boxShadow: "0 25px 60px rgba(0,0,0,0.5)",
|
||||
padding: "22px",
|
||||
}}
|
||||
>
|
||||
{/* Üst Başlık */}
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
gap: "12px",
|
||||
paddingBottom: "14px",
|
||||
borderBottom: "1px solid #1e293b",
|
||||
marginBottom: "16px",
|
||||
}}
|
||||
>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "10px" }}>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
width: "40px",
|
||||
height: "40px",
|
||||
borderRadius: "12px",
|
||||
background: "linear-gradient(135deg, #2563eb, #10b981)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Cloud size={20} color="#fff" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 id="yaknet-cloud-modal-title" style={{ margin: 0, fontSize: "17px", fontWeight: 700 }}>
|
||||
YakNet Bulut Depolama
|
||||
</h2>
|
||||
<p id="yaknet-cloud-modal-desc" style={{ margin: "2px 0 0", fontSize: "12.5px", color: "#94a3b8" }}>
|
||||
Tasarımlarınız YakNet hesabınızla otomatik eşitlenir ve tüm cihazlarınızdan güvenle erişilebilir.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
data-modal-close="true"
|
||||
data-modal-focus-key="yaknet-cloud-close"
|
||||
onClick={() => setModalOpen(false)}
|
||||
aria-label="YakNet Bulut penceresini kapat"
|
||||
style={{
|
||||
background: "#1e293b",
|
||||
border: "none",
|
||||
color: "#cbd5e1",
|
||||
borderRadius: "8px",
|
||||
padding: "6px",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
<X size={18} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{statusBanner ? (
|
||||
<div
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
style={{
|
||||
padding: "10px 14px",
|
||||
borderRadius: "10px",
|
||||
marginBottom: "14px",
|
||||
fontSize: "13px",
|
||||
background:
|
||||
statusBanner.type === "ok"
|
||||
? "rgba(16, 185, 129, 0.16)"
|
||||
: statusBanner.type === "err"
|
||||
? "rgba(239, 68, 68, 0.18)"
|
||||
: "rgba(59, 130, 246, 0.18)",
|
||||
border:
|
||||
statusBanner.type === "ok"
|
||||
? "1px solid rgba(16, 185, 129, 0.4)"
|
||||
: statusBanner.type === "err"
|
||||
? "1px solid rgba(239, 68, 68, 0.4)"
|
||||
: "1px solid rgba(59, 130, 246, 0.4)",
|
||||
color: "#f8fafc",
|
||||
}}
|
||||
>
|
||||
{statusBanner.text}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{/* Kullanıcı Durum Kartı */}
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
gap: "12px",
|
||||
padding: "14px 16px",
|
||||
borderRadius: "12px",
|
||||
background: "#1e293b",
|
||||
marginBottom: "16px",
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
width: "10px",
|
||||
height: "10px",
|
||||
borderRadius: "999px",
|
||||
background: user ? "#10b981" : "#f59e0b",
|
||||
}}
|
||||
/>
|
||||
<strong style={{ fontSize: "14px" }}>
|
||||
{user ? `${user.name} (${user.email})` : "YakNet Oturumu Açık Değil"}
|
||||
</strong>
|
||||
</div>
|
||||
<div style={{ fontSize: "12px", color: "#94a3b8", marginTop: "4px" }}>
|
||||
{dbConnected ? "Bulut Bağlantısı Aktif" : "Çevrimdışı Mod"}
|
||||
{lastSyncedAt ? ` • Son Eşitleme: ${new Date(lastSyncedAt).toLocaleTimeString("tr-TR")}` : ""}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>
|
||||
{user ? (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
data-modal-initial-focus="true"
|
||||
data-modal-focus-key="yaknet-cloud-sync-btn"
|
||||
aria-disabled={syncing}
|
||||
onClick={() => {
|
||||
if (!syncing) void performCloudSync(false);
|
||||
}}
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: "6px",
|
||||
padding: "8px 14px",
|
||||
borderRadius: "8px",
|
||||
border: "none",
|
||||
background: "#2563eb",
|
||||
color: "#fff",
|
||||
fontWeight: 600,
|
||||
fontSize: "12.5px",
|
||||
cursor: syncing ? "wait" : "pointer",
|
||||
opacity: syncing ? 0.8 : 1,
|
||||
}}
|
||||
>
|
||||
<RefreshCw size={14} className={syncing ? "spinning" : undefined} />
|
||||
<span>{syncing ? "Eşitleniyor..." : "Şimdi Eşitle"}</span>
|
||||
</button>
|
||||
<a
|
||||
href="/logout.php"
|
||||
data-modal-focus-key="yaknet-cloud-logout-link"
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: "6px",
|
||||
padding: "8px 12px",
|
||||
borderRadius: "8px",
|
||||
background: "rgba(239, 68, 68, 0.16)",
|
||||
color: "#fca5a5",
|
||||
textDecoration: "none",
|
||||
fontWeight: 600,
|
||||
fontSize: "12.5px",
|
||||
}}
|
||||
>
|
||||
<LogOut size={14} />
|
||||
<span>Çıkış Yap</span>
|
||||
</a>
|
||||
</>
|
||||
) : (
|
||||
<a
|
||||
href="/login.php"
|
||||
data-modal-initial-focus="true"
|
||||
data-modal-focus-key="yaknet-cloud-login-link"
|
||||
style={{
|
||||
display: "inline-flex",
|
||||
alignItems: "center",
|
||||
gap: "7px",
|
||||
padding: "9px 16px",
|
||||
borderRadius: "9px",
|
||||
background: "linear-gradient(135deg, #2563eb, #1d4ed8)",
|
||||
color: "#fff",
|
||||
textDecoration: "none",
|
||||
fontWeight: 700,
|
||||
fontSize: "13px",
|
||||
}}
|
||||
>
|
||||
<LogIn size={15} />
|
||||
<span>YakNet ile Giriş Yap</span>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Buluttaki Tasarımlar Listesi */}
|
||||
<div style={{ marginBottom: "10px", fontSize: "13px", fontWeight: 600, color: "#cbd5e1" }}>
|
||||
Buluttaki Tasarımlarım ({cloudProjectCount})
|
||||
</div>
|
||||
|
||||
{cloudList.length === 0 ? (
|
||||
<div
|
||||
style={{
|
||||
padding: "24px",
|
||||
textAlign: "center",
|
||||
background: "#1e293b",
|
||||
borderRadius: "12px",
|
||||
color: "#94a3b8",
|
||||
fontSize: "13px",
|
||||
}}
|
||||
>
|
||||
{user
|
||||
? "Henüz bulutta kayıtlı tasarımınız bulunmuyor. 'Şimdi Eşitle' butonuna tıklayarak mevcut çalışmalarınızı yedekleyebilirsiniz."
|
||||
: "Tasarımlarınızı bulutta yedeklemek ve tüm cihazlarınızdan erişmek için YakNet hesabınızla giriş yapın."}
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ display: "grid", gap: "8px", maxHeight: "300px", overflowY: "auto" }}>
|
||||
{cloudList.map((proj) => {
|
||||
const dateLabel = proj.cloudUpdatedAt
|
||||
? new Date(proj.cloudUpdatedAt).toLocaleString("tr-TR", {
|
||||
day: "2-digit",
|
||||
month: "short",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
})
|
||||
: "Eşitlendi";
|
||||
return (
|
||||
<div
|
||||
key={proj.id}
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
gap: "10px",
|
||||
padding: "11px 14px",
|
||||
borderRadius: "10px",
|
||||
background: "#1e293b",
|
||||
border: "1px solid #334155",
|
||||
}}
|
||||
>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "10px" }}>
|
||||
<CheckCircle2 size={16} color="#34d399" aria-hidden="true" />
|
||||
<div>
|
||||
<div style={{ fontWeight: 700, fontSize: "13.5px", color: "#f8fafc" }}>
|
||||
{proj.name}
|
||||
</div>
|
||||
<div style={{ fontSize: "11.5px", color: "#94a3b8", marginTop: "2px" }}>
|
||||
{proj.shapes?.length ?? 0} nesne • {dateLabel}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void handleDeleteCloudProject(proj.id)}
|
||||
title="Buluttan Kaldır"
|
||||
aria-label={`${proj.name} tasarımını buluttan kaldır`}
|
||||
style={{
|
||||
padding: "6px 8px",
|
||||
borderRadius: "7px",
|
||||
border: "none",
|
||||
background: "rgba(239, 68, 68, 0.16)",
|
||||
color: "#fca5a5",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{localOnlyProjects.length > 0 ? (
|
||||
<div style={{ marginTop: "18px" }}>
|
||||
<div style={{ marginBottom: "8px", fontSize: "13px", fontWeight: 600, color: "#fbbf24" }}>
|
||||
Yalnızca bu tarayıcıda saklanan projeler ({localOnlyProjects.length})
|
||||
</div>
|
||||
<div role="status" style={{ fontSize: "12px", color: "#cbd5e1", marginBottom: "8px", lineHeight: 1.5 }}>
|
||||
Bu projeler bulut boyut sınırını aştığı veya yerel şekilleri okunamadığı için buluta yedeklenemedi.
|
||||
Yerel kopyaları korunuyor. Yedek almak için projeyi açıp "Dosyayı Dışa Aktar" ile .skf dosyası oluşturun.
|
||||
</div>
|
||||
<div style={{ display: "grid", gap: "8px" }}>
|
||||
{localOnlyProjects.map((project) => (
|
||||
<div
|
||||
key={project.id}
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "10px",
|
||||
padding: "11px 14px",
|
||||
borderRadius: "10px",
|
||||
background: "rgba(251, 191, 36, 0.1)",
|
||||
border: "1px solid rgba(251, 191, 36, 0.35)",
|
||||
}}
|
||||
>
|
||||
<CloudOff size={16} color="#fbbf24" aria-hidden="true" />
|
||||
<div>
|
||||
<div style={{ fontWeight: 700, fontSize: "13.5px", color: "#f8fafc" }}>{project.name}</div>
|
||||
<div style={{ fontSize: "11.5px", color: "#cbd5e1", marginTop: "2px" }}>
|
||||
{project.shapeCount} nesne •{" "}
|
||||
{project.reason === "too-large"
|
||||
? `buluta sığmıyor (${formatByteSize(project.bytes)})`
|
||||
: "yerel şekiller okunamadı"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,149 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
export type SerialPlotterProps = {
|
||||
dataPoints: Array<{ time: number; values: Record<string, number> }>;
|
||||
running: boolean;
|
||||
};
|
||||
|
||||
const CHANNEL_COLORS = [
|
||||
"#38bdf8", // Sky blue
|
||||
"#22c55e", // Green
|
||||
"#f59e0b", // Amber
|
||||
"#ef4444", // Red
|
||||
"#a855f7", // Purple
|
||||
"#ec4899", // Pink
|
||||
"#06b6d4", // Cyan
|
||||
];
|
||||
|
||||
export default function SerialPlotter({ dataPoints, running }: SerialPlotterProps) {
|
||||
const canvasRef = useRef<HTMLCanvasElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const canvas = canvasRef.current;
|
||||
if (!canvas) return;
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) return;
|
||||
|
||||
const width = canvas.width;
|
||||
const height = canvas.height;
|
||||
|
||||
// Clear background
|
||||
ctx.fillStyle = "#090d16";
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
||||
// Draw grid lines
|
||||
ctx.strokeStyle = "rgba(148, 163, 184, 0.12)";
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
for (let x = 0; x < width; x += 40) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, 0);
|
||||
ctx.lineTo(x, height);
|
||||
ctx.stroke();
|
||||
}
|
||||
for (let y = 0; y < height; y += 30) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, y);
|
||||
ctx.lineTo(width, y);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
if (dataPoints.length === 0) {
|
||||
ctx.fillStyle = "#64748b";
|
||||
ctx.font = "12px monospace";
|
||||
ctx.textAlign = "center";
|
||||
ctx.fillText(
|
||||
running ? "Veriler bekleniyor..." : "Simülasyon durduruldu. Başlatarak canlı sinyalleri izleyin.",
|
||||
width / 2,
|
||||
height / 2,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine channels
|
||||
const channels = Array.from(
|
||||
new Set(dataPoints.flatMap((dp) => Object.keys(dp.values))),
|
||||
);
|
||||
|
||||
// Find global min/max across visible points
|
||||
let maxVal = -Infinity;
|
||||
let minVal = Infinity;
|
||||
for (const dp of dataPoints) {
|
||||
for (const ch of channels) {
|
||||
const val = dp.values[ch];
|
||||
if (typeof val === "number") {
|
||||
if (val > maxVal) maxVal = val;
|
||||
if (val < minVal) minVal = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (maxVal === -Infinity) maxVal = 5;
|
||||
if (minVal === Infinity) minVal = 0;
|
||||
if (maxVal === minVal) {
|
||||
maxVal += 1;
|
||||
minVal -= 1;
|
||||
}
|
||||
// Add slight padding
|
||||
const range = maxVal - minVal || 1;
|
||||
const padTop = 20;
|
||||
const padBottom = 20;
|
||||
const chartHeight = height - padTop - padBottom;
|
||||
|
||||
// Draw channels
|
||||
channels.forEach((ch, chIdx) => {
|
||||
const color = CHANNEL_COLORS[chIdx % CHANNEL_COLORS.length];
|
||||
ctx.strokeStyle = color;
|
||||
ctx.lineWidth = 2;
|
||||
ctx.beginPath();
|
||||
|
||||
dataPoints.forEach((dp, i) => {
|
||||
const x = (i / Math.max(1, dataPoints.length - 1)) * (width - 60) + 10;
|
||||
const val = dp.values[ch] ?? minVal;
|
||||
const norm = (val - minVal) / range;
|
||||
const y = height - padBottom - norm * chartHeight;
|
||||
|
||||
if (i === 0) {
|
||||
ctx.moveTo(x, y);
|
||||
} else {
|
||||
ctx.lineTo(x, y);
|
||||
}
|
||||
});
|
||||
ctx.stroke();
|
||||
});
|
||||
|
||||
// Draw legend
|
||||
let legendX = 14;
|
||||
channels.forEach((ch, chIdx) => {
|
||||
const color = CHANNEL_COLORS[chIdx % CHANNEL_COLORS.length];
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillRect(legendX, 8, 10, 10);
|
||||
ctx.fillStyle = "#f8fafc";
|
||||
ctx.font = "bold 11px sans-serif";
|
||||
ctx.textAlign = "left";
|
||||
ctx.fillText(ch, legendX + 14, 17);
|
||||
legendX += ctx.measureText(ch).width + 32;
|
||||
});
|
||||
|
||||
// Draw Y-axis labels
|
||||
ctx.fillStyle = "#94a3b8";
|
||||
ctx.font = "10px monospace";
|
||||
ctx.textAlign = "right";
|
||||
ctx.fillText(maxVal.toFixed(1), width - 6, padTop + 8);
|
||||
ctx.fillText(((maxVal + minVal) / 2).toFixed(1), width - 6, height / 2);
|
||||
ctx.fillText(minVal.toFixed(1), width - 6, height - padBottom);
|
||||
}, [dataPoints, running]);
|
||||
|
||||
return (
|
||||
<div className="snapcad-serial-plotter-wrap">
|
||||
<canvas
|
||||
ref={canvasRef}
|
||||
width={680}
|
||||
height={220}
|
||||
className="snapcad-plotter-canvas"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
export type CircuitBlockType =
|
||||
| "pin_digital"
|
||||
| "pin_pwm"
|
||||
| "servo_write"
|
||||
| "play_tone"
|
||||
| "stop_tone"
|
||||
| "delay_ms"
|
||||
| "serial_print"
|
||||
| "lcd_print"
|
||||
| "if_distance";
|
||||
|
||||
export type CircuitBlock = {
|
||||
id: string;
|
||||
type: CircuitBlockType;
|
||||
pin?: number;
|
||||
state?: "HIGH" | "LOW";
|
||||
valNumber?: number;
|
||||
text?: string;
|
||||
};
|
||||
|
||||
export const DEFAULT_BLOCKS: CircuitBlock[] = [
|
||||
{ id: "b1", type: "pin_digital", pin: 13, state: "HIGH" },
|
||||
{ id: "b2", type: "serial_print", text: "LED D13 Yandi" },
|
||||
{ id: "b3", type: "delay_ms", valNumber: 1000 },
|
||||
{ id: "b4", type: "pin_digital", pin: 13, state: "LOW" },
|
||||
{ id: "b5", type: "serial_print", text: "LED D13 Sondu" },
|
||||
{ id: "b6", type: "delay_ms", valNumber: 1000 },
|
||||
];
|
||||
|
||||
export function compileBlocksToCpp(blocks: CircuitBlock[]): string {
|
||||
const setupLines: string[] = [" Serial.begin(9600);"];
|
||||
const loopLines: string[] = [];
|
||||
const configuredPins = new Set<number>();
|
||||
let hasServo = false;
|
||||
let hasLcd = false;
|
||||
|
||||
for (const b of blocks) {
|
||||
if (b.type === "servo_write") hasServo = true;
|
||||
if (b.type === "lcd_print") hasLcd = true;
|
||||
|
||||
if (b.pin !== undefined && !configuredPins.has(b.pin)) {
|
||||
configuredPins.add(b.pin);
|
||||
setupLines.push(` pinMode(${b.pin}, OUTPUT);`);
|
||||
}
|
||||
|
||||
switch (b.type) {
|
||||
case "pin_digital":
|
||||
loopLines.push(` digitalWrite(${b.pin ?? 13}, ${b.state ?? "HIGH"});`);
|
||||
break;
|
||||
case "pin_pwm":
|
||||
loopLines.push(` analogWrite(${b.pin ?? 9}, ${b.valNumber ?? 128});`);
|
||||
break;
|
||||
case "servo_write":
|
||||
loopLines.push(` myServo.write(${b.valNumber ?? 90});`);
|
||||
break;
|
||||
case "play_tone":
|
||||
loopLines.push(` tone(${b.pin ?? 8}, ${b.valNumber ?? 880});`);
|
||||
break;
|
||||
case "stop_tone":
|
||||
loopLines.push(` noTone(${b.pin ?? 8});`);
|
||||
break;
|
||||
case "delay_ms":
|
||||
loopLines.push(` delay(${b.valNumber ?? 1000});`);
|
||||
break;
|
||||
case "serial_print":
|
||||
loopLines.push(` Serial.println("${b.text ?? "SnapCAD"}");`);
|
||||
break;
|
||||
case "lcd_print":
|
||||
loopLines.push(` lcd.setCursor(0, 0);`);
|
||||
loopLines.push(` lcd.print("${b.text ?? "SnapCAD Circuits"}");`);
|
||||
break;
|
||||
case "if_distance":
|
||||
loopLines.push(` if (distanceCm < ${b.valNumber ?? 25}) {`);
|
||||
loopLines.push(` digitalWrite(13, HIGH);`);
|
||||
loopLines.push(` tone(8, 880);`);
|
||||
loopLines.push(` } else {`);
|
||||
loopLines.push(` digitalWrite(13, LOW);`);
|
||||
loopLines.push(` noTone(8);`);
|
||||
loopLines.push(` }`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const includes: string[] = [];
|
||||
if (hasServo) {
|
||||
includes.push("#include <Servo.h>\nServo myServo;\n");
|
||||
}
|
||||
if (hasLcd) {
|
||||
includes.push("#include <Wire.h>\n#include <LiquidCrystal_I2C.h>\nLiquidCrystal_I2C lcd(0x27, 16, 2);\n");
|
||||
}
|
||||
|
||||
return `// SnapCAD Otomatik Üretilen Arduino Kodu (Blok Kodlama)
|
||||
${includes.join("\n")}
|
||||
void setup() {
|
||||
${setupLines.join("\n")}
|
||||
${hasServo ? " myServo.attach(9);\n" : ""}${hasLcd ? " lcd.init();\n lcd.backlight();\n" : ""}}
|
||||
|
||||
void loop() {
|
||||
${loopLines.join("\n")}
|
||||
}
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,976 @@
|
||||
import type { CircuitComponent, CircuitComponentCategory, CircuitComponentKind, CircuitPin } from "./types";
|
||||
|
||||
export type ComponentMetadata = {
|
||||
kind: CircuitComponentKind;
|
||||
name: string;
|
||||
category: CircuitComponentCategory;
|
||||
description: string;
|
||||
width: number;
|
||||
height: number;
|
||||
pins: CircuitPin[];
|
||||
createDefault: (id: string, offset?: number) => CircuitComponent;
|
||||
};
|
||||
|
||||
export const COMPONENT_CATEGORIES: { id: CircuitComponentCategory; label: string; count?: number }[] = [
|
||||
{ id: "all", label: "Tüm Bileşenler" },
|
||||
{ id: "microcontroller", label: "Geliştirme Kartları" },
|
||||
{ id: "basic", label: "Temel & Pasif" },
|
||||
{ id: "inputs", label: "Giriş & Sensörler" },
|
||||
{ id: "outputs", label: "Çıkış & Göstergeler" },
|
||||
{ id: "power", label: "Güç & Breadboard" },
|
||||
];
|
||||
|
||||
export const COMPONENTS_CATALOG: Record<CircuitComponentKind, ComponentMetadata> = {
|
||||
arduino_uno: {
|
||||
kind: "arduino_uno",
|
||||
name: "Arduino Uno R3",
|
||||
category: "microcontroller",
|
||||
description: "ATmega328P tabanlı mikrodenetleyici kartı. 14 dijital I/O pini (6 PWM), 6 analog giriş pini.",
|
||||
width: 250,
|
||||
height: 180,
|
||||
pins: [
|
||||
{ id: "AREF", label: "AREF", relX: 30, relY: 10, direction: "input" },
|
||||
{ id: "GND_TOP", label: "GND", relX: 44, relY: 10, direction: "ground" },
|
||||
{ id: "D13", label: "D13", relX: 58, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D12", label: "D12", relX: 72, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D11", label: "D11~", relX: 86, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D10", label: "D10~", relX: 100, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D9", label: "D9~", relX: 114, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D8", label: "D8", relX: 128, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D7", label: "D7", relX: 148, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D6", label: "D6~", relX: 162, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D5", label: "D5~", relX: 176, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D4", label: "D4", relX: 190, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D3", label: "D3~", relX: 204, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D2", label: "D2", relX: 218, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D1", label: "TX (D1)", relX: 232, relY: 10, direction: "bidirectional" },
|
||||
{ id: "D0", label: "RX (D0)", relX: 246, relY: 10, direction: "bidirectional" },
|
||||
{ id: "RESET", label: "RESET", relX: 30, relY: 170, direction: "input" },
|
||||
{ id: "3V3", label: "3.3V", relX: 44, relY: 170, direction: "power" },
|
||||
{ id: "5V", label: "5V", relX: 58, relY: 170, direction: "power" },
|
||||
{ id: "GND", label: "GND", relX: 72, relY: 170, direction: "ground" },
|
||||
{ id: "VIN", label: "VIN", relX: 86, relY: 170, direction: "power" },
|
||||
{ id: "A0", label: "A0", relX: 140, relY: 170, direction: "input" },
|
||||
{ id: "A1", label: "A1", relX: 156, relY: 170, direction: "input" },
|
||||
{ id: "A2", label: "A2", relX: 172, relY: 170, direction: "input" },
|
||||
{ id: "A3", label: "A3", relX: 188, relY: 170, direction: "input" },
|
||||
{ id: "A4", label: "A4 (SDA)", relX: 204, relY: 170, direction: "bidirectional" },
|
||||
{ id: "A5", label: "A5 (SCL)", relX: 220, relY: 170, direction: "bidirectional" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "arduino_uno",
|
||||
name: "Arduino Uno R3",
|
||||
x: 40 + offset,
|
||||
y: 100 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
breadboard: {
|
||||
kind: "breadboard",
|
||||
name: "Breadboard (Yarım Boy 400 Pin)",
|
||||
category: "power",
|
||||
description: "Lehimsiz devre kurma tahtası. Üst ve alt güç hatları (+/-) ile 30 sütunluk 5'li dikey delik grupları.",
|
||||
width: 290,
|
||||
height: 160,
|
||||
pins: [
|
||||
{ id: "VCC_TOP", label: "+5V Üst", relX: 25, relY: 18, direction: "power" },
|
||||
{ id: "GND_TOP", label: "-GND Üst", relX: 25, relY: 34, direction: "ground" },
|
||||
{ id: "T1", label: "1A", relX: 60, relY: 62 },
|
||||
{ id: "T2", label: "5A", relX: 100, relY: 62 },
|
||||
{ id: "T3", label: "10A", relX: 140, relY: 62 },
|
||||
{ id: "T4", label: "15A", relX: 180, relY: 62 },
|
||||
{ id: "T5", label: "20A", relX: 220, relY: 62 },
|
||||
{ id: "B1", label: "1J", relX: 60, relY: 104 },
|
||||
{ id: "B2", label: "5J", relX: 100, relY: 104 },
|
||||
{ id: "B3", label: "10J", relX: 140, relY: 104 },
|
||||
{ id: "B4", label: "15J", relX: 180, relY: 104 },
|
||||
{ id: "B5", label: "20J", relX: 220, relY: 104 },
|
||||
{ id: "VCC_BOT", label: "+5V Alt", relX: 25, relY: 132, direction: "power" },
|
||||
{ id: "GND_BOT", label: "-GND Alt", relX: 25, relY: 148, direction: "ground" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "breadboard",
|
||||
name: "Breadboard (400 Pin)",
|
||||
x: 330 + offset,
|
||||
y: 110 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
breadboard_mini: {
|
||||
kind: "breadboard_mini",
|
||||
name: "Mini Breadboard (170 Pin)",
|
||||
category: "power",
|
||||
description: "Kompakt prototip tahtası. Küçük taşınabilir robotik projeler için ideal.",
|
||||
width: 190,
|
||||
height: 120,
|
||||
pins: [
|
||||
{ id: "P1", label: "A1", relX: 25, relY: 28 },
|
||||
{ id: "P2", label: "A5", relX: 65, relY: 28 },
|
||||
{ id: "P3", label: "A10", relX: 115, relY: 28 },
|
||||
{ id: "P4", label: "A15", relX: 165, relY: 28 },
|
||||
{ id: "P5", label: "E1", relX: 25, relY: 92 },
|
||||
{ id: "P6", label: "E5", relX: 65, relY: 92 },
|
||||
{ id: "P7", label: "E10", relX: 115, relY: 92 },
|
||||
{ id: "P8", label: "E15", relX: 165, relY: 92 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "breadboard_mini",
|
||||
name: "Mini Breadboard (170 Pin)",
|
||||
x: 350 + offset,
|
||||
y: 130 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
battery_9v: {
|
||||
kind: "battery_9v",
|
||||
name: "9V Blok Pil",
|
||||
category: "power",
|
||||
description: "9 Volt DC harici güç kaynağı. Motorlar, röleler ve bağımsız projeler için.",
|
||||
width: 120,
|
||||
height: 90,
|
||||
pins: [
|
||||
{ id: "POS", label: "+9V (Kırmızı)", relX: 35, relY: 20, direction: "power" },
|
||||
{ id: "NEG", label: "-GND (Siyah)", relX: 85, relY: 20, direction: "ground" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "battery_9v",
|
||||
name: "9V Blok Pil",
|
||||
batteryVoltage: 9,
|
||||
x: 480 + offset,
|
||||
y: 280 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
coin_cell: {
|
||||
kind: "coin_cell",
|
||||
name: "3V Madeni Para Pil (CR2032)",
|
||||
category: "power",
|
||||
description: "3V lityum düğme pil. RTC saat modülleri ve düşük güçlü giyilebilir projeler için.",
|
||||
width: 100,
|
||||
height: 80,
|
||||
pins: [
|
||||
{ id: "POS", label: "+3V", relX: 30, relY: 22, direction: "power" },
|
||||
{ id: "NEG", label: "-GND", relX: 70, relY: 22, direction: "ground" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "coin_cell",
|
||||
name: "3V CR2032 Pil",
|
||||
batteryVoltage: 3,
|
||||
x: 500 + offset,
|
||||
y: 300 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
led: {
|
||||
kind: "led",
|
||||
name: "LED (Işık Yayan Diyot)",
|
||||
category: "outputs",
|
||||
description: "5mm tek renkli LED. Anot (+) uzun bacak, Katot (-) düz kesik bacak.",
|
||||
width: 90,
|
||||
height: 95,
|
||||
pins: [
|
||||
{ id: "ANODE", label: "Anot (+)", relX: 25, relY: 82, direction: "input" },
|
||||
{ id: "CATHODE", label: "Katot (-)", relX: 65, relY: 82, direction: "ground" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "led",
|
||||
name: "Kırmızı LED",
|
||||
ledColor: "red",
|
||||
digitalPin: 13,
|
||||
x: 360 + offset,
|
||||
y: 40 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
rgb_led: {
|
||||
kind: "rgb_led",
|
||||
name: "RGB LED (4 Bacaklı)",
|
||||
category: "outputs",
|
||||
description: "Kırmızı, Yeşil ve Mavi renkleri PWM ile karıştırarak 16 milyon renk üretebilen 4 bacaklı ortak katot LED.",
|
||||
width: 120,
|
||||
height: 100,
|
||||
pins: [
|
||||
{ id: "RED", label: "K (D11)", relX: 20, relY: 86, direction: "input" },
|
||||
{ id: "CATHODE", label: "Katot (GND)", relX: 47, relY: 86, direction: "ground" },
|
||||
{ id: "GREEN", label: "Y (D10)", relX: 73, relY: 86, direction: "input" },
|
||||
{ id: "BLUE", label: "M (D9)", relX: 100, relY: 86, direction: "input" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "rgb_led",
|
||||
name: "RGB LED (Ortak Katot)",
|
||||
rgbColor: { r: 255, g: 0, b: 128 },
|
||||
x: 420 + offset,
|
||||
y: 50 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
seven_segment: {
|
||||
kind: "seven_segment",
|
||||
name: "7-Segment LED Gösterge",
|
||||
category: "outputs",
|
||||
description: "0'dan 9'a kadar rakamları ve harfleri gösteren 7 segmentli kırmızı LED dijital gösterge.",
|
||||
width: 110,
|
||||
height: 125,
|
||||
pins: [
|
||||
{ id: "A", label: "A (D7)", relX: 20, relY: 14 },
|
||||
{ id: "B", label: "B (D8)", relX: 42, relY: 14 },
|
||||
{ id: "COM", label: "COM/GND", relX: 65, relY: 14, direction: "ground" },
|
||||
{ id: "F", label: "F (D9)", relX: 90, relY: 14 },
|
||||
{ id: "E", label: "E (D4)", relX: 20, relY: 114 },
|
||||
{ id: "D", label: "D (D3)", relX: 42, relY: 114 },
|
||||
{ id: "C", label: "C (D2)", relX: 65, relY: 114 },
|
||||
{ id: "DP", label: "DP (Nokta)", relX: 90, relY: 114 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "seven_segment",
|
||||
name: "7-Segment Gösterge",
|
||||
sevenSegmentValue: "8",
|
||||
x: 480 + offset,
|
||||
y: 60 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
resistor: {
|
||||
kind: "resistor",
|
||||
name: "Direnç (Resistor)",
|
||||
category: "basic",
|
||||
description: "Elektrik akımını sınırlayan karbon film direnç. Renk kodları değere göre otomatik değişir.",
|
||||
width: 115,
|
||||
height: 60,
|
||||
pins: [
|
||||
{ id: "T1", label: "Terminal 1", relX: 12, relY: 30 },
|
||||
{ id: "T2", label: "Terminal 2", relX: 102, relY: 30 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "resistor",
|
||||
name: "220Ω Direnç",
|
||||
resistanceOhms: 220,
|
||||
x: 380 + offset,
|
||||
y: 290 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
capacitor: {
|
||||
kind: "capacitor",
|
||||
name: "Kondansatör (Kapasitör)",
|
||||
category: "basic",
|
||||
description: "Elektrik yükünü depolayan elektrolitik kutuplu filtre kondansatörü.",
|
||||
width: 90,
|
||||
height: 70,
|
||||
pins: [
|
||||
{ id: "POS", label: "Anot (+)", relX: 26, relY: 58 },
|
||||
{ id: "NEG", label: "Katot (-)", relX: 64, relY: 58 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "capacitor",
|
||||
name: "100µF Kondansatör",
|
||||
capacitanceUf: 100,
|
||||
x: 400 + offset,
|
||||
y: 300 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
diode: {
|
||||
kind: "diode",
|
||||
name: "1N4007 Doğrultucu Diyot",
|
||||
category: "basic",
|
||||
description: "Akımı tek yönde ileten doğrultucu silikon diyot. Ters EMK koruması için motor devrelerinde kullanılır.",
|
||||
width: 100,
|
||||
height: 60,
|
||||
pins: [
|
||||
{ id: "ANODE", label: "Anot (+)", relX: 12, relY: 30 },
|
||||
{ id: "CATHODE", label: "Katot (- Gri Çizgi)", relX: 88, relY: 30 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "diode",
|
||||
name: "1N4007 Diyot",
|
||||
x: 420 + offset,
|
||||
y: 310 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
transistor: {
|
||||
kind: "transistor",
|
||||
name: "NPN Transistör (2N2222)",
|
||||
category: "basic",
|
||||
description: "Elektronik anahtarlama ve akım yükseltme için NPN bipolar transistör (BJT).",
|
||||
width: 90,
|
||||
height: 75,
|
||||
pins: [
|
||||
{ id: "C", label: "Kolektör (C)", relX: 20, relY: 62 },
|
||||
{ id: "B", label: "Beyz (B)", relX: 45, relY: 62 },
|
||||
{ id: "E", label: "Emitör (E)", relX: 70, relY: 62 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "transistor",
|
||||
name: "2N2222 Transistör",
|
||||
x: 440 + offset,
|
||||
y: 310 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
relay: {
|
||||
kind: "relay",
|
||||
name: "5V Röle Modülü (Optokuplörlü)",
|
||||
category: "basic",
|
||||
description: "Yüksek voltajlı cihazları (220V lamba, güçlü motorlar) izole anahtarlayan elektromekanik röle.",
|
||||
width: 130,
|
||||
height: 90,
|
||||
pins: [
|
||||
{ id: "VCC", label: "VCC (5V)", relX: 20, relY: 20, direction: "power" },
|
||||
{ id: "GND", label: "GND", relX: 20, relY: 45, direction: "ground" },
|
||||
{ id: "IN", label: "IN (D8)", relX: 20, relY: 70, direction: "input" },
|
||||
{ id: "COM", label: "COM (Ortak)", relX: 110, relY: 20 },
|
||||
{ id: "NO", label: "NO (Normalde Açık)", relX: 110, relY: 45 },
|
||||
{ id: "NC", label: "NC (Normalde Kapalı)", relX: 110, relY: 70 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "relay",
|
||||
name: "5V Tekli Röle",
|
||||
relayState: false,
|
||||
digitalPin: 8,
|
||||
x: 520 + offset,
|
||||
y: 180 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
pushbutton: {
|
||||
kind: "pushbutton",
|
||||
name: "Pushbutton (Dokunmatik Buton)",
|
||||
category: "inputs",
|
||||
description: "Basıldığında devreyi tamamlayan yaylı basmalı buton.",
|
||||
width: 85,
|
||||
height: 80,
|
||||
pins: [
|
||||
{ id: "P1", label: "1A", relX: 18, relY: 68 },
|
||||
{ id: "P2", label: "2A", relX: 67, relY: 68 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "pushbutton",
|
||||
name: "Buton (D2)",
|
||||
digitalPin: 2,
|
||||
pressed: false,
|
||||
x: 510 + offset,
|
||||
y: 220 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
slide_switch: {
|
||||
kind: "slide_switch",
|
||||
name: "Sürgülü Anahtar (SPDT)",
|
||||
category: "inputs",
|
||||
description: "3 bacaklı tek kutuplu çift yönlü (SPDT) açma/kapama sürgülü anahtar.",
|
||||
width: 90,
|
||||
height: 70,
|
||||
pins: [
|
||||
{ id: "T1", label: "Terminal 1", relX: 18, relY: 58 },
|
||||
{ id: "COM", label: "Ortak (Common)", relX: 45, relY: 58 },
|
||||
{ id: "T2", label: "Terminal 2", relX: 72, relY: 58 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "slide_switch",
|
||||
name: "Sürgülü Anahtar",
|
||||
switchOn: false,
|
||||
x: 520 + offset,
|
||||
y: 240 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
potentiometer: {
|
||||
kind: "potentiometer",
|
||||
name: "Potansiyometre (10k Döner Ayarlı)",
|
||||
category: "inputs",
|
||||
description: "Döner mil ile 0 ile 1023 arasında analog voltaj bölen 10k ayarlı direnç.",
|
||||
width: 95,
|
||||
height: 95,
|
||||
pins: [
|
||||
{ id: "GND", label: "GND", relX: 18, relY: 84, direction: "ground" },
|
||||
{ id: "SIG", label: "Sinyal (A0)", relX: 48, relY: 84, direction: "output" },
|
||||
{ id: "VCC", label: "5V", relX: 78, relY: 84, direction: "power" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "potentiometer",
|
||||
name: "10k Potansiyometre (A0)",
|
||||
analogPin: "A0",
|
||||
potValue: 512,
|
||||
x: 370 + offset,
|
||||
y: 60 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
ultrasonic: {
|
||||
kind: "ultrasonic",
|
||||
name: "HC-SR04 Ultrasonik Mesafe Sensörü",
|
||||
category: "inputs",
|
||||
description: "40 kHz ses dalgası yayarak 2 cm ile 400 cm arası mesafe ölçen ultrasonik sonar sensörü.",
|
||||
width: 140,
|
||||
height: 95,
|
||||
pins: [
|
||||
{ id: "VCC", label: "VCC", relX: 28, relY: 84, direction: "power" },
|
||||
{ id: "TRIG", label: "TRIG (D10)", relX: 58, relY: 84, direction: "input" },
|
||||
{ id: "ECHO", label: "ECHO (D9)", relX: 88, relY: 84, direction: "output" },
|
||||
{ id: "GND", label: "GND", relX: 118, relY: 84, direction: "ground" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "ultrasonic",
|
||||
name: "HC-SR04 Mesafe Sensörü",
|
||||
distanceCm: 25,
|
||||
x: 375 + offset,
|
||||
y: 55 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
pir_sensor: {
|
||||
kind: "pir_sensor",
|
||||
name: "PIR Hareket Sensörü (HC-SR501)",
|
||||
category: "inputs",
|
||||
description: "Canlıların yaydığı kızılötesi ısı değişimini tespit eden Fresnel lensli pasif kızılötesi hareket sensörü.",
|
||||
width: 110,
|
||||
height: 100,
|
||||
pins: [
|
||||
{ id: "VCC", label: "VCC (5V)", relX: 25, relY: 88, direction: "power" },
|
||||
{ id: "OUT", label: "OUT (D7)", relX: 55, relY: 88, direction: "output" },
|
||||
{ id: "GND", label: "GND", relX: 85, relY: 88, direction: "ground" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "pir_sensor",
|
||||
name: "PIR Hareket Sensörü",
|
||||
pirMotion: false,
|
||||
digitalPin: 7,
|
||||
x: 410 + offset,
|
||||
y: 70 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
tmp36: {
|
||||
kind: "tmp36",
|
||||
name: "TMP36 Hassas Sıcaklık Sensörü",
|
||||
category: "inputs",
|
||||
description: "-40°C ile +125°C arası sıcaklığı 10 mV/°C hassasiyetle lineer analog voltaja çeviren sensör.",
|
||||
width: 95,
|
||||
height: 90,
|
||||
pins: [
|
||||
{ id: "VCC", label: "+Vs (5V)", relX: 18, relY: 82, direction: "power" },
|
||||
{ id: "VOUT", label: "Vout (A1)", relX: 48, relY: 82, direction: "output" },
|
||||
{ id: "GND", label: "GND", relX: 78, relY: 82, direction: "ground" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "tmp36",
|
||||
name: "TMP36 Sıcaklık (A1)",
|
||||
tempCelsius: 24,
|
||||
analogPin: "A1",
|
||||
x: 420 + offset,
|
||||
y: 75 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
ldr: {
|
||||
kind: "ldr",
|
||||
name: "LDR Foto-Direnç (Işık Sensörü)",
|
||||
category: "inputs",
|
||||
description: "Üzerine düşen ışık miktarı arttıkça direnci azalan kadmiyum sülfit (CdS) ışık sensörü.",
|
||||
width: 90,
|
||||
height: 90,
|
||||
pins: [
|
||||
{ id: "L1", label: "Terminal 1", relX: 24, relY: 82 },
|
||||
{ id: "L2", label: "Terminal 2 (A2)", relX: 66, relY: 82 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "ldr",
|
||||
name: "LDR Işık Sensörü (A2)",
|
||||
lightLux: 650,
|
||||
analogPin: "A2",
|
||||
x: 430 + offset,
|
||||
y: 80 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
gas_sensor: {
|
||||
kind: "gas_sensor",
|
||||
name: "MQ-2 Yanıcı Gaz & Duman Sensörü",
|
||||
category: "inputs",
|
||||
description: "LPG, propan, metan, hidrojen ve duman konsantrasyonunu tespit eden elektrokimyasal gaz sensörü.",
|
||||
width: 110,
|
||||
height: 100,
|
||||
pins: [
|
||||
{ id: "VCC", label: "VCC (5V)", relX: 18, relY: 88, direction: "power" },
|
||||
{ id: "GND", label: "GND", relX: 42, relY: 88, direction: "ground" },
|
||||
{ id: "DOUT", label: "D0 (D4)", relX: 68, relY: 88, direction: "output" },
|
||||
{ id: "AOUT", label: "A0 (A3)", relX: 92, relY: 88, direction: "output" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "gas_sensor",
|
||||
name: "MQ-2 Duman Sensörü",
|
||||
gasPpm: 120,
|
||||
analogPin: "A3",
|
||||
x: 450 + offset,
|
||||
y: 85 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
soil_moisture: {
|
||||
kind: "soil_moisture",
|
||||
name: "Toprak Nem Sensörü (Kapasitif)",
|
||||
category: "inputs",
|
||||
description: "Topraktaki veya bitki saksısındaki su ve nem oranını ölçen korozyona dayanıklı prob.",
|
||||
width: 100,
|
||||
height: 110,
|
||||
pins: [
|
||||
{ id: "VCC", label: "VCC (5V)", relX: 20, relY: 100, direction: "power" },
|
||||
{ id: "GND", label: "GND", relX: 50, relY: 100, direction: "ground" },
|
||||
{ id: "SIG", label: "SIG (A0)", relX: 80, relY: 100, direction: "output" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "soil_moisture",
|
||||
name: "Toprak Nem Sensörü",
|
||||
moisturePct: 45,
|
||||
analogPin: "A0",
|
||||
x: 460 + offset,
|
||||
y: 90 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
keypad4x4: {
|
||||
kind: "keypad4x4",
|
||||
name: "4x4 Matris Tuş Takımı (Keypad)",
|
||||
category: "inputs",
|
||||
description: "16 tuşlu (0-9, A-D, *, #) telefon tarzı matris buton takımı. Şifreli kilit ve menü sistemleri için.",
|
||||
width: 140,
|
||||
height: 150,
|
||||
pins: [
|
||||
{ id: "R1", label: "Satır 1 (D9)", relX: 18, relY: 140 },
|
||||
{ id: "R2", label: "Satır 2 (D8)", relX: 33, relY: 140 },
|
||||
{ id: "R3", label: "Satır 3 (D7)", relX: 48, relY: 140 },
|
||||
{ id: "R4", label: "Satır 4 (D6)", relX: 63, relY: 140 },
|
||||
{ id: "C1", label: "Sütun 1 (D5)", relX: 80, relY: 140 },
|
||||
{ id: "C2", label: "Sütun 2 (D4)", relX: 95, relY: 140 },
|
||||
{ id: "C3", label: "Sütun 3 (D3)", relX: 110, relY: 140 },
|
||||
{ id: "C4", label: "Sütun 4 (D2)", relX: 125, relY: 140 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "keypad4x4",
|
||||
name: "4x4 Keypad",
|
||||
lastKeyPressed: "None",
|
||||
x: 480 + offset,
|
||||
y: 100 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
ir_receiver: {
|
||||
kind: "ir_receiver",
|
||||
name: "Kızılötesi Alıcı & Kumanda (IR 1838)",
|
||||
category: "inputs",
|
||||
description: "38 kHz kızılötesi kumanda sinyallerini alan IR alıcı göz ve etkileşimli mini kumanda.",
|
||||
width: 105,
|
||||
height: 100,
|
||||
pins: [
|
||||
{ id: "OUT", label: "OUT (D7)", relX: 25, relY: 88, direction: "output" },
|
||||
{ id: "GND", label: "GND", relX: 52, relY: 88, direction: "ground" },
|
||||
{ id: "VCC", label: "VCC (5V)", relX: 80, relY: 88, direction: "power" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "ir_receiver",
|
||||
name: "IR Alıcı & Kumanda",
|
||||
irLastCode: "0xFF6897",
|
||||
digitalPin: 7,
|
||||
x: 490 + offset,
|
||||
y: 110 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
buzzer: {
|
||||
kind: "buzzer",
|
||||
name: "Piezo Buzzer (Sesli Uyarıcı)",
|
||||
category: "outputs",
|
||||
description: "Arduino tone() fonksiyonu ile farklı frekanslarda bip sesi ve melodiler çalan piezo hoparlör.",
|
||||
width: 85,
|
||||
height: 85,
|
||||
pins: [
|
||||
{ id: "POS", label: "Pozitif (+) (D8)", relX: 25, relY: 78, direction: "input" },
|
||||
{ id: "NEG", label: "Negatif (-) GND", relX: 60, relY: 78, direction: "ground" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "buzzer",
|
||||
name: "Piezo Buzzer (D8)",
|
||||
digitalPin: 8,
|
||||
x: 550 + offset,
|
||||
y: 60 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
servo: {
|
||||
kind: "servo",
|
||||
name: "SG90 Mikro Servo Motor",
|
||||
category: "outputs",
|
||||
description: "0° ile 180° arasında istenen açıya dönebilen mikro dişlili servo motor.",
|
||||
width: 100,
|
||||
height: 95,
|
||||
pins: [
|
||||
{ id: "GND", label: "GND (Kahve)", relX: 22, relY: 88, direction: "ground" },
|
||||
{ id: "VCC", label: "5V (Kırmızı)", relX: 50, relY: 88, direction: "power" },
|
||||
{ id: "SIG", label: "PWM (Turuncu D9)", relX: 78, relY: 88, direction: "input" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "servo",
|
||||
name: "SG90 Servo (D9)",
|
||||
digitalPin: 9,
|
||||
servoAngle: 90,
|
||||
x: 510 + offset,
|
||||
y: 60 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
dc_motor: {
|
||||
kind: "dc_motor",
|
||||
name: "DC Hobi Motoru & Pervane",
|
||||
category: "outputs",
|
||||
description: "PWM sinyali veya transistör ile hızı ayarlanabilen minyatür DC motor ve dönen pervane animasyonu.",
|
||||
width: 110,
|
||||
height: 100,
|
||||
pins: [
|
||||
{ id: "POS", label: "Pozitif (+) PWM", relX: 30, relY: 88 },
|
||||
{ id: "NEG", label: "Negatif (-) GND", relX: 80, relY: 88 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "dc_motor",
|
||||
name: "DC Fan Motoru",
|
||||
motorSpeed: 0,
|
||||
x: 530 + offset,
|
||||
y: 70 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
lcd16x2: {
|
||||
kind: "lcd16x2",
|
||||
name: "16x2 I2C Alfanümerik LCD Ekran",
|
||||
category: "outputs",
|
||||
description: "I2C modülü sayesinde sadece 2 hat (SDA/SCL) ile 2 satır 16 karakter metin gösteren arkadan aydınlatmalı LCD.",
|
||||
width: 180,
|
||||
height: 105,
|
||||
pins: [
|
||||
{ id: "GND", label: "GND", relX: 25, relY: 96, direction: "ground" },
|
||||
{ id: "VCC", label: "VCC (5V)", relX: 62, relY: 96, direction: "power" },
|
||||
{ id: "SDA", label: "SDA (A4)", relX: 100, relY: 96, direction: "bidirectional" },
|
||||
{ id: "SCL", label: "SCL (A5)", relX: 138, relY: 96, direction: "bidirectional" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "lcd16x2",
|
||||
name: "16x2 I2C LCD",
|
||||
lcdLine1: "SNAPCAD CIRCUITS",
|
||||
lcdLine2: "DURUM: HAZIR",
|
||||
x: 390 + offset,
|
||||
y: 70 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
oled128x64: {
|
||||
kind: "oled128x64",
|
||||
name: "0.96\" I2C OLED Ekran (128x64)",
|
||||
category: "outputs",
|
||||
description: "Grafik, simge ve metin çizebilen 128x64 piksel kontrastı yüksek SSD1306 OLED ekran.",
|
||||
width: 130,
|
||||
height: 105,
|
||||
pins: [
|
||||
{ id: "GND", label: "GND", relX: 22, relY: 96, direction: "ground" },
|
||||
{ id: "VCC", label: "VCC", relX: 48, relY: 96, direction: "power" },
|
||||
{ id: "SCL", label: "SCL (A5)", relX: 78, relY: 96, direction: "bidirectional" },
|
||||
{ id: "SDA", label: "SDA (A4)", relX: 108, relY: 96, direction: "bidirectional" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "oled128x64",
|
||||
name: "OLED 128x64 (I2C)",
|
||||
oledLines: ["SnapCAD OLED", "Piksel: 128x64", "Sensör: OK", "Durum: AKTIF"],
|
||||
x: 410 + offset,
|
||||
y: 80 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
neopixel_ring: {
|
||||
kind: "neopixel_ring",
|
||||
name: "8'li NeoPixel WS2812B RGB Halka",
|
||||
category: "outputs",
|
||||
description: "Tek bir dijital pin üzerinden bağımsız kontrol edilen 8 adet parlak adreslenebilir RGB LED halkası.",
|
||||
width: 110,
|
||||
height: 110,
|
||||
pins: [
|
||||
{ id: "GND", label: "GND", relX: 25, relY: 98, direction: "ground" },
|
||||
{ id: "VCC", label: "5V", relX: 55, relY: 98, direction: "power" },
|
||||
{ id: "DIN", label: "DIN (D6)", relX: 85, relY: 98, direction: "input" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "neopixel_ring",
|
||||
name: "NeoPixel Halka (8 LED)",
|
||||
neopixelColors: ["#ff0055", "#00d2ff", "#00ff88", "#ffe600", "#ff00bb", "#7000ff", "#00f0ff", "#ff7700"],
|
||||
digitalPin: 6,
|
||||
x: 430 + offset,
|
||||
y: 90 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
multimeter: {
|
||||
kind: "multimeter",
|
||||
name: "Dijital Multimetre (DMM)",
|
||||
category: "outputs",
|
||||
description: "Devredeki voltajı (DC Gerilim 0..5V / 0..9V), akımı ve direnci ölçmek için dijital ekranlı multimetre.",
|
||||
width: 120,
|
||||
height: 95,
|
||||
pins: [
|
||||
{ id: "V_POS", label: "V+ (Kırmızı Prob)", relX: 30, relY: 86 },
|
||||
{ id: "V_COM", label: "COM (Siyah Prob)", relX: 85, relY: 86 },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "multimeter",
|
||||
name: "Dijital Multimetre",
|
||||
x: 540 + offset,
|
||||
y: 290 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
arduino_nano: {
|
||||
kind: "arduino_nano",
|
||||
name: "Arduino Nano V3",
|
||||
category: "microcontroller",
|
||||
description: "ATmega328P tabanlı, breadboard uyumlu kompakt mikrodenetleyici kartı. 14 dijital I/O, 8 analog giriş.",
|
||||
width: 175,
|
||||
height: 70,
|
||||
pins: [
|
||||
{ id: "D13", label: "D13", relX: 20, relY: 8, direction: "bidirectional" },
|
||||
{ id: "3V3", label: "3.3V", relX: 31, relY: 8, direction: "power" },
|
||||
{ id: "REF", label: "REF", relX: 42, relY: 8, direction: "input" },
|
||||
{ id: "A0", label: "A0", relX: 53, relY: 8, direction: "input" },
|
||||
{ id: "A1", label: "A1", relX: 64, relY: 8, direction: "input" },
|
||||
{ id: "A2", label: "A2", relX: 75, relY: 8, direction: "input" },
|
||||
{ id: "A3", label: "A3", relX: 86, relY: 8, direction: "input" },
|
||||
{ id: "A4", label: "A4(SDA)", relX: 97, relY: 8, direction: "bidirectional" },
|
||||
{ id: "A5", label: "A5(SCL)", relX: 108, relY: 8, direction: "bidirectional" },
|
||||
{ id: "A6", label: "A6", relX: 119, relY: 8, direction: "input" },
|
||||
{ id: "A7", label: "A7", relX: 130, relY: 8, direction: "input" },
|
||||
{ id: "5V", label: "5V", relX: 141, relY: 8, direction: "power" },
|
||||
{ id: "RST_T", label: "RST", relX: 152, relY: 8, direction: "input" },
|
||||
{ id: "GND_T", label: "GND", relX: 163, relY: 8, direction: "ground" },
|
||||
{ id: "D12", label: "D12", relX: 20, relY: 62, direction: "bidirectional" },
|
||||
{ id: "D11", label: "D11~", relX: 31, relY: 62, direction: "bidirectional" },
|
||||
{ id: "D10", label: "D10~", relX: 42, relY: 62, direction: "bidirectional" },
|
||||
{ id: "D9", label: "D9~", relX: 53, relY: 62, direction: "bidirectional" },
|
||||
{ id: "D8", label: "D8", relX: 64, relY: 62, direction: "bidirectional" },
|
||||
{ id: "D7", label: "D7", relX: 75, relY: 62, direction: "bidirectional" },
|
||||
{ id: "D6", label: "D6~", relX: 86, relY: 62, direction: "bidirectional" },
|
||||
{ id: "D5", label: "D5~", relX: 97, relY: 62, direction: "bidirectional" },
|
||||
{ id: "D4", label: "D4", relX: 108, relY: 62, direction: "bidirectional" },
|
||||
{ id: "D3", label: "D3~", relX: 119, relY: 62, direction: "bidirectional" },
|
||||
{ id: "D2", label: "D2", relX: 130, relY: 62, direction: "bidirectional" },
|
||||
{ id: "GND_B", label: "GND", relX: 141, relY: 62, direction: "ground" },
|
||||
{ id: "RX0", label: "RX", relX: 152, relY: 62, direction: "bidirectional" },
|
||||
{ id: "TX1", label: "TX", relX: 163, relY: 62, direction: "bidirectional" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "arduino_nano",
|
||||
name: "Arduino Nano",
|
||||
x: 80 + offset,
|
||||
y: 120 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
esp32: {
|
||||
kind: "esp32",
|
||||
name: "ESP32 NodeMCU Wi-Fi & BT",
|
||||
category: "microcontroller",
|
||||
description: "Çift çekirdekli 240MHz Xtensa LX6 işlemci, dahili Wi-Fi ve Bluetooth IoT geliştirme kartı.",
|
||||
width: 200,
|
||||
height: 90,
|
||||
pins: [
|
||||
{ id: "3V3", label: "3V3", relX: 20, relY: 8, direction: "power" },
|
||||
{ id: "EN", label: "EN", relX: 32, relY: 8, direction: "input" },
|
||||
{ id: "VP", label: "VP(36)", relX: 44, relY: 8, direction: "input" },
|
||||
{ id: "VN", label: "VN(39)", relX: 56, relY: 8, direction: "input" },
|
||||
{ id: "D34", label: "D34", relX: 68, relY: 8, direction: "input" },
|
||||
{ id: "D35", label: "D35", relX: 80, relY: 8, direction: "input" },
|
||||
{ id: "D32", label: "D32", relX: 92, relY: 8, direction: "bidirectional" },
|
||||
{ id: "D33", label: "D33", relX: 104, relY: 8, direction: "bidirectional" },
|
||||
{ id: "D25", label: "D25(DAC1)", relX: 116, relY: 8, direction: "bidirectional" },
|
||||
{ id: "D26", label: "D26(DAC2)", relX: 128, relY: 8, direction: "bidirectional" },
|
||||
{ id: "D27", label: "D27", relX: 140, relY: 8, direction: "bidirectional" },
|
||||
{ id: "D14", label: "D14", relX: 152, relY: 8, direction: "bidirectional" },
|
||||
{ id: "D12", label: "D12", relX: 164, relY: 8, direction: "bidirectional" },
|
||||
{ id: "GND_T", label: "GND", relX: 176, relY: 8, direction: "ground" },
|
||||
{ id: "D13", label: "D13", relX: 188, relY: 8, direction: "bidirectional" },
|
||||
{ id: "D23", label: "D23(MOSI)", relX: 20, relY: 82, direction: "bidirectional" },
|
||||
{ id: "D22", label: "D22(SCL)", relX: 32, relY: 82, direction: "bidirectional" },
|
||||
{ id: "TX0", label: "TX0", relX: 44, relY: 82, direction: "bidirectional" },
|
||||
{ id: "RX0", label: "RX0", relX: 56, relY: 82, direction: "bidirectional" },
|
||||
{ id: "D21", label: "D21(SDA)", relX: 68, relY: 82, direction: "bidirectional" },
|
||||
{ id: "D19", label: "D19(MISO)", relX: 80, relY: 82, direction: "bidirectional" },
|
||||
{ id: "D18", label: "D18(SCK)", relX: 92, relY: 82, direction: "bidirectional" },
|
||||
{ id: "D5", label: "D5", relX: 104, relY: 82, direction: "bidirectional" },
|
||||
{ id: "TX2", label: "TX2", relX: 116, relY: 82, direction: "bidirectional" },
|
||||
{ id: "RX2", label: "RX2", relX: 128, relY: 82, direction: "bidirectional" },
|
||||
{ id: "D4", label: "D4", relX: 140, relY: 82, direction: "bidirectional" },
|
||||
{ id: "D2", label: "D2", relX: 152, relY: 82, direction: "bidirectional" },
|
||||
{ id: "D15", label: "D15", relX: 164, relY: 82, direction: "bidirectional" },
|
||||
{ id: "GND_B", label: "GND", relX: 176, relY: 82, direction: "ground" },
|
||||
{ id: "VIN", label: "5V/VIN", relX: 188, relY: 82, direction: "power" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "esp32",
|
||||
name: "ESP32 NodeMCU",
|
||||
x: 60 + offset,
|
||||
y: 90 + offset,
|
||||
}),
|
||||
},
|
||||
|
||||
stepper_motor: {
|
||||
kind: "stepper_motor",
|
||||
name: "28BYJ-48 Step Motor + ULN2003",
|
||||
category: "outputs",
|
||||
description: "4 fazlı redüktörlü step motor ve ULN2003 Darlington sürücü modülü. Adım açısı hassas kontrol edilir.",
|
||||
width: 200,
|
||||
height: 125,
|
||||
pins: [
|
||||
{ id: "IN1", label: "IN1", relX: 155, relY: 30, direction: "input" },
|
||||
{ id: "IN2", label: "IN2", relX: 155, relY: 48, direction: "input" },
|
||||
{ id: "IN3", label: "IN3", relX: 155, relY: 66, direction: "input" },
|
||||
{ id: "IN4", label: "IN4", relX: 155, relY: 84, direction: "input" },
|
||||
{ id: "GND", label: "GND (-)", relX: 155, relY: 104, direction: "ground" },
|
||||
{ id: "VCC", label: "+5V (VCC)", relX: 175, relY: 104, direction: "power" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "stepper_motor",
|
||||
name: "Step Motor & ULN2003",
|
||||
x: 440 + offset,
|
||||
y: 110 + offset,
|
||||
stepperAngle: 0,
|
||||
stepperCoils: [false, false, false, false],
|
||||
}),
|
||||
},
|
||||
|
||||
dht11: {
|
||||
kind: "dht11",
|
||||
name: "DHT11 Sıcaklık & Nem Sensörü",
|
||||
category: "inputs",
|
||||
description: "Tek dijital veri hattı üzerinden ortam sıcaklığını (0-50°C) ve bağıl nemi (%20-90) ölçen dijital sensör.",
|
||||
width: 80,
|
||||
height: 90,
|
||||
pins: [
|
||||
{ id: "VCC", label: "VCC (+)", relX: 20, relY: 82, direction: "power" },
|
||||
{ id: "DATA", label: "DATA (Sinyal)", relX: 40, relY: 82, direction: "bidirectional" },
|
||||
{ id: "GND", label: "GND (-)", relX: 60, relY: 82, direction: "ground" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "dht11",
|
||||
name: "DHT11 Sensör",
|
||||
x: 360 + offset,
|
||||
y: 200 + offset,
|
||||
dhtTemp: 24,
|
||||
dhtHumidity: 45,
|
||||
}),
|
||||
},
|
||||
|
||||
joystick: {
|
||||
kind: "joystick",
|
||||
name: "2 Eksenli Analog Joystick + Buton",
|
||||
category: "inputs",
|
||||
description: "X ve Y eksenlerinde çift potansiyometre (0..1023 analog) ve entegre Z basma butonu barındıran joystick modülü.",
|
||||
width: 110,
|
||||
height: 110,
|
||||
pins: [
|
||||
{ id: "GND", label: "GND", relX: 18, relY: 102, direction: "ground" },
|
||||
{ id: "5V", label: "+5V", relX: 36, relY: 102, direction: "power" },
|
||||
{ id: "VRX", label: "VRx (X Ekseni)", relX: 54, relY: 102, direction: "output" },
|
||||
{ id: "VRY", label: "VRy (Y Ekseni)", relX: 72, relY: 102, direction: "output" },
|
||||
{ id: "SW", label: "SW (Buton)", relX: 90, relY: 102, direction: "output" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "joystick",
|
||||
name: "Analog Joystick",
|
||||
x: 340 + offset,
|
||||
y: 190 + offset,
|
||||
joystickX: 512,
|
||||
joystickY: 512,
|
||||
joystickPressed: false,
|
||||
}),
|
||||
},
|
||||
|
||||
oscilloscope: {
|
||||
kind: "oscilloscope",
|
||||
name: "Dijital Osiloskop (2 Kanal)",
|
||||
category: "outputs",
|
||||
description: "Devre sinyallerini, PWM dalga formlarını ve analog frekansları canlı görselleştiren dijital ekranlı osiloskop.",
|
||||
width: 190,
|
||||
height: 130,
|
||||
pins: [
|
||||
{ id: "CH1", label: "CH1 (Kanal 1 Prob)", relX: 45, relY: 120, direction: "input" },
|
||||
{ id: "GND", label: "GND (Toprak Timsah)", relX: 145, relY: 120, direction: "ground" },
|
||||
],
|
||||
createDefault: (id, offset = 0) => ({
|
||||
id,
|
||||
kind: "oscilloscope",
|
||||
name: "Dijital Osiloskop",
|
||||
x: 520 + offset,
|
||||
y: 80 + offset,
|
||||
scopeScale: 1.0,
|
||||
scopeTimebase: 2.0,
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
export function getPinsForComponent(comp: CircuitComponent): CircuitPin[] {
|
||||
const meta = COMPONENTS_CATALOG[comp.kind];
|
||||
if (!meta) return [];
|
||||
// Return pins with applied rotation if any
|
||||
const rot = comp.rotation ?? 0;
|
||||
if (!rot) return meta.pins;
|
||||
|
||||
const w = meta.width;
|
||||
const h = meta.height;
|
||||
return meta.pins.map((p) => {
|
||||
let rx = p.relX;
|
||||
let ry = p.relY;
|
||||
if (rot === 90) {
|
||||
rx = h - p.relY;
|
||||
ry = p.relX;
|
||||
} else if (rot === 180) {
|
||||
rx = w - p.relX;
|
||||
ry = h - p.relY;
|
||||
} else if (rot === 270) {
|
||||
rx = p.relY;
|
||||
ry = w - p.relX;
|
||||
}
|
||||
return { ...p, relX: rx, relY: ry };
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
import type { ArduinoLibrary } from "./types";
|
||||
|
||||
export const ARDUINO_LIBRARIES: ArduinoLibrary[] = [
|
||||
{
|
||||
id: "servo",
|
||||
name: "Servo",
|
||||
header: "<Servo.h>",
|
||||
version: "1.2.2",
|
||||
author: "Michael Margolis, Arduino",
|
||||
category: "Actuators",
|
||||
description: "RC Servo motorları (SG90, MG995 vb.) 0° ile 180° arasında hassas PWM ile kontrol etmek için standart kütüphane.",
|
||||
exampleCode: `#include <Servo.h>
|
||||
|
||||
Servo myServo;
|
||||
|
||||
void setup() {
|
||||
myServo.attach(9); // Servo sinyal pini D9
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// 0 dereceden 180 dereceye tara
|
||||
for (int pos = 0; pos <= 180; pos += 15) {
|
||||
myServo.write(pos);
|
||||
delay(100);
|
||||
}
|
||||
for (int pos = 180; pos >= 0; pos -= 15) {
|
||||
myServo.write(pos);
|
||||
delay(100);
|
||||
}
|
||||
}`,
|
||||
},
|
||||
{
|
||||
id: "liquidcrystal_i2c",
|
||||
name: "LiquidCrystal_I2C",
|
||||
header: "<LiquidCrystal_I2C.h>",
|
||||
version: "1.1.2",
|
||||
author: "Frank de Brabander / Marco Schwartz",
|
||||
category: "Display",
|
||||
description: "SDA (A4) ve SCL (A5) pinleri üzerinden yalnızca 2 hat ile 16x2 veya 20x4 LCD ekranları süren I2C LCD kütüphanesi.",
|
||||
exampleCode: `#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void setup() {
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print("SnapCAD Circuits");
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print("Arduino & Sim");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Canlı sayaç
|
||||
lcd.setCursor(11, 1);
|
||||
lcd.print(millis() / 1000);
|
||||
delay(500);
|
||||
}`,
|
||||
},
|
||||
{
|
||||
id: "adafruit_neopixel",
|
||||
name: "Adafruit_NeoPixel",
|
||||
header: "<Adafruit_NeoPixel.h>",
|
||||
version: "1.12.0",
|
||||
author: "Adafruit Industries",
|
||||
category: "LED",
|
||||
description: "WS2812, WS2811 ve SK6812 tabanlı adreslenebilir akıllı tek hatlı RGB ve RGBW LED şerit / halka kütüphanesi.",
|
||||
exampleCode: `#include <Adafruit_NeoPixel.h>
|
||||
|
||||
#define PIN 6
|
||||
#define NUMPIXELS 8
|
||||
|
||||
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
void setup() {
|
||||
pixels.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
pixels.clear();
|
||||
for(int i = 0; i < NUMPIXELS; i++) {
|
||||
pixels.setPixelColor(i, pixels.Color(0, 150, 255));
|
||||
pixels.show();
|
||||
delay(100);
|
||||
}
|
||||
delay(500);
|
||||
}`,
|
||||
},
|
||||
{
|
||||
id: "dht",
|
||||
name: "DHT Sensor Library",
|
||||
header: "<DHT.h>",
|
||||
version: "1.4.6",
|
||||
author: "Adafruit",
|
||||
category: "Sensors",
|
||||
description: "DHT11, DHT22 ve AM2302 dijital sıcaklık ve bağıl nem sensörlerinden veri okumak için kütüphane.",
|
||||
exampleCode: `#include <DHT.h>
|
||||
|
||||
#define DHTPIN 2
|
||||
#define DHTTYPE DHT11
|
||||
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
dht.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
float h = dht.readHumidity();
|
||||
float t = dht.readTemperature();
|
||||
Serial.print("Nem: %");
|
||||
Serial.print(h);
|
||||
Serial.print(" | Sicaklik: ");
|
||||
Serial.print(t);
|
||||
Serial.println(" *C");
|
||||
delay(1000);
|
||||
}`,
|
||||
},
|
||||
{
|
||||
id: "irremote",
|
||||
name: "IRremote",
|
||||
header: "<IRremote.h>",
|
||||
version: "4.3.1",
|
||||
author: "shirriff, z3t0, ArminJo",
|
||||
category: "Communication",
|
||||
description: "Kızılötesi uzaktan kumanda (IR Remote) sinyallerini alma, şifresini çözme ve NEC protokolüyle komut işleme.",
|
||||
exampleCode: `#include <IRremote.h>
|
||||
|
||||
const int RECV_PIN = 7;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (IrReceiver.decode()) {
|
||||
Serial.print("Kizilotesi Kod: 0x");
|
||||
Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
|
||||
IrReceiver.resume();
|
||||
}
|
||||
}`,
|
||||
},
|
||||
{
|
||||
id: "ssd1306",
|
||||
name: "Adafruit_SSD1306",
|
||||
header: "<Adafruit_SSD1306.h>",
|
||||
version: "2.5.9",
|
||||
author: "Adafruit",
|
||||
category: "Display",
|
||||
description: "0.96 inç 128x64 piksel I2C SSD1306 tek renkli OLED ekran sürücüsü ve grafik çizim kütüphanesi.",
|
||||
exampleCode: `#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 64
|
||||
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
|
||||
|
||||
void setup() {
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.setCursor(0, 10);
|
||||
display.println("SnapCAD OLED 128x64");
|
||||
display.println("Online Simulator");
|
||||
display.display();
|
||||
}
|
||||
|
||||
void loop() {}`,
|
||||
},
|
||||
{
|
||||
id: "keypad",
|
||||
name: "Keypad",
|
||||
header: "<Keypad.h>",
|
||||
version: "3.1.1",
|
||||
author: "Mark Stanley, Alexander Brevig",
|
||||
category: "Sensors",
|
||||
description: "4x4 veya 3x4 matris telefon tuş takımlarını kolayca matris tarama ile okuma kütüphanesi.",
|
||||
exampleCode: `#include <Keypad.h>
|
||||
|
||||
const byte ROWS = 4;
|
||||
const byte COLS = 4;
|
||||
char keys[ROWS][COLS] = {
|
||||
{'1','2','3','A'},
|
||||
{'4','5','6','B'},
|
||||
{'7','8','9','C'},
|
||||
{'*','0','#','D'}
|
||||
};
|
||||
byte rowPins[ROWS] = {9, 8, 7, 6};
|
||||
byte colPins[COLS] = {5, 4, 3, 2};
|
||||
|
||||
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
char key = keypad.getKey();
|
||||
if (key) {
|
||||
Serial.print("Basilan Tus: ");
|
||||
Serial.println(key);
|
||||
}
|
||||
}`,
|
||||
},
|
||||
{
|
||||
id: "stepper",
|
||||
name: "Stepper",
|
||||
header: "<Stepper.h>",
|
||||
version: "1.1.4",
|
||||
author: "Arduino",
|
||||
category: "Actuators",
|
||||
description: "28BYJ-48 veya NEMA 17 iki fazlı / dört fazlı adım motorlarının adım hassasiyetiyle sürülmesi.",
|
||||
exampleCode: `#include <Stepper.h>
|
||||
|
||||
const int stepsPerRevolution = 2048; // 28BYJ-48
|
||||
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
|
||||
|
||||
void setup() {
|
||||
myStepper.setSpeed(10);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println("Saat yonunde donuyor");
|
||||
myStepper.step(stepsPerRevolution);
|
||||
delay(500);
|
||||
}`,
|
||||
},
|
||||
{
|
||||
id: "wire",
|
||||
name: "Wire",
|
||||
header: "<Wire.h>",
|
||||
version: "1.0.0",
|
||||
author: "Arduino",
|
||||
category: "Communication",
|
||||
description: "İki telli I2C (Inter-Integrated Circuit) veri yolu üzerinden sensör ve ekranlarla haberleşme.",
|
||||
exampleCode: `#include <Wire.h>
|
||||
|
||||
void setup() {
|
||||
Wire.begin();
|
||||
Serial.begin(9600);
|
||||
Serial.println("I2C Tarayici Hazir");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// I2C cihaz tarama
|
||||
delay(1000);
|
||||
}`,
|
||||
},
|
||||
{
|
||||
id: "wifi",
|
||||
name: "WiFi",
|
||||
header: "<WiFi.h>",
|
||||
version: "2.0.0",
|
||||
author: "Espressif Systems",
|
||||
category: "Communication",
|
||||
description: "ESP32 için dahili 802.11 b/g/n Wi-Fi istemci, erişim noktası (AP) ve HTTP istemci bağlantı kütüphanesi.",
|
||||
exampleCode: `#include <WiFi.h>
|
||||
|
||||
const char* ssid = "SnapCAD_Guest";
|
||||
const char* password = "maker_password";
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
WiFi.begin(ssid, password);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("\nWi-Fi Baglandi! IP:");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void loop() {}`,
|
||||
},
|
||||
{
|
||||
id: "spi",
|
||||
name: "SPI",
|
||||
header: "<SPI.h>",
|
||||
version: "1.0.0",
|
||||
author: "Arduino",
|
||||
category: "Communication",
|
||||
description: "Yüksek hızlı 4 telli SPI (Serial Peripheral Interface) protokolü ile SD kart, TFT ekran ve RF modülleriyle haberleşme.",
|
||||
exampleCode: `#include <SPI.h>
|
||||
|
||||
void setup() {
|
||||
SPI.begin();
|
||||
Serial.begin(9600);
|
||||
Serial.println("SPI Veri Yolu Baslatildi");
|
||||
}
|
||||
|
||||
void loop() {}`,
|
||||
},
|
||||
{
|
||||
id: "accelstepper",
|
||||
name: "AccelStepper",
|
||||
header: "<AccelStepper.h>",
|
||||
version: "1.64.0",
|
||||
author: "Mike McCauley",
|
||||
category: "Actuators",
|
||||
description: "İvmelenme, yavaşlama ve çoklu motor senkronizasyonu destekleyen profesyonel step motor kontrol kütüphanesi.",
|
||||
exampleCode: `#include <AccelStepper.h>
|
||||
|
||||
#define MotorInterfaceType 4
|
||||
AccelStepper stepper = AccelStepper(MotorInterfaceType, 8, 10, 9, 11);
|
||||
|
||||
void setup() {
|
||||
stepper.setMaxSpeed(1000);
|
||||
stepper.setAcceleration(500);
|
||||
stepper.moveTo(2048);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (stepper.distanceToGo() == 0)
|
||||
stepper.moveTo(-stepper.currentPosition());
|
||||
stepper.run();
|
||||
}`,
|
||||
},
|
||||
{
|
||||
id: "pubsubclient",
|
||||
name: "PubSubClient (MQTT)",
|
||||
header: "<PubSubClient.h>",
|
||||
version: "2.8.0",
|
||||
author: "Nick O'Leary",
|
||||
category: "Communication",
|
||||
description: "ESP32 ve Arduino için hafif MQTT protokolü kütüphanesi. Bulut IoT telemetrisi ve sensör yayını.",
|
||||
exampleCode: `#include <WiFi.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
WiFiClient espClient;
|
||||
PubSubClient client(espClient);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
client.setServer("mqtt.yakhub.com.tr", 1883);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (client.connect("ESP32_Client")) {
|
||||
client.publish("snapcad/sensors/temp", "24.5");
|
||||
}
|
||||
delay(5000);
|
||||
}`,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,351 @@
|
||||
import type { CircuitComponent } from "./types";
|
||||
|
||||
export type PinState = {
|
||||
digital: boolean;
|
||||
pwm: number; // 0..255
|
||||
voltage: number; // 0..5.0
|
||||
};
|
||||
|
||||
export type SimulationTickResult = {
|
||||
activePins: Record<number, PinState>;
|
||||
buzzerActive: boolean;
|
||||
buzzerFrequency: number;
|
||||
logLines: string[];
|
||||
componentsPatch: Record<string, Partial<CircuitComponent>>;
|
||||
plotterValues: Record<string, number>;
|
||||
shortCircuit?: boolean;
|
||||
shortCircuitReason?: string;
|
||||
explodedComponentId?: string;
|
||||
};
|
||||
|
||||
const SEVEN_SEG_DIGITS: Record<number, Record<"a" | "b" | "c" | "d" | "e" | "f" | "g" | "dp", boolean>> = {
|
||||
0: { a: true, b: true, c: true, d: true, e: true, f: true, g: false, dp: false },
|
||||
1: { a: false, b: true, c: true, d: false, e: false, f: false, g: false, dp: false },
|
||||
2: { a: true, b: true, c: false, d: true, e: true, f: false, g: true, dp: false },
|
||||
3: { a: true, b: true, c: true, d: true, e: false, f: false, g: true, dp: false },
|
||||
4: { a: false, b: true, c: true, d: false, e: false, f: true, g: true, dp: false },
|
||||
5: { a: true, b: false, c: true, d: true, e: false, f: true, g: true, dp: false },
|
||||
6: { a: true, b: false, c: true, d: true, e: true, f: true, g: true, dp: false },
|
||||
7: { a: true, b: true, c: true, d: false, e: false, f: false, g: false, dp: false },
|
||||
8: { a: true, b: true, c: true, d: true, e: true, f: true, g: true, dp: false },
|
||||
9: { a: true, b: true, c: true, d: true, e: false, f: true, g: true, dp: false },
|
||||
};
|
||||
|
||||
export function executeSimulationTick(
|
||||
step: number,
|
||||
code: string,
|
||||
components: CircuitComponent[],
|
||||
): SimulationTickResult {
|
||||
const activePins: Record<number, PinState> = {};
|
||||
let buzzerActive = false;
|
||||
let buzzerFrequency = 880;
|
||||
const logLines: string[] = [];
|
||||
const componentsPatch: Record<string, Partial<CircuitComponent>> = {};
|
||||
const plotterValues: Record<string, number> = {};
|
||||
|
||||
const timeStamp = new Date().toLocaleTimeString();
|
||||
|
||||
// 1. Gather sensor inputs
|
||||
const potComp = components.find((c) => c.kind === "potentiometer");
|
||||
const ultComp = components.find((c) => c.kind === "ultrasonic");
|
||||
const btnComp = components.find((c) => c.kind === "pushbutton");
|
||||
const swComp = components.find((c) => c.kind === "slide_switch");
|
||||
const pirComp = components.find((c) => c.kind === "pir_sensor");
|
||||
const tmpComp = components.find((c) => c.kind === "tmp36");
|
||||
const ldrComp = components.find((c) => c.kind === "ldr");
|
||||
const batComp = components.find((c) => c.kind === "battery_9v" || c.kind === "coin_cell");
|
||||
|
||||
const potVal = potComp?.potValue ?? 512;
|
||||
const distCm = ultComp?.distanceCm ?? 30;
|
||||
const btnPressed = Boolean(btnComp?.pressed);
|
||||
const switchOn = swComp?.switchOn ?? true;
|
||||
const pirMotion = Boolean(pirComp?.pirMotion);
|
||||
const tempC = tmpComp?.tempCelsius ?? 24;
|
||||
const lightLux = ldrComp?.lightLux ?? 600;
|
||||
|
||||
plotterValues["Pot_A0"] = potVal;
|
||||
plotterValues["Mesafe_cm"] = distCm;
|
||||
plotterValues["Sicaklik_C"] = tempC;
|
||||
plotterValues["Isik_Lux"] = lightLux;
|
||||
|
||||
// Check if this is a pure battery circuit without Arduino / Microcontroller
|
||||
const hasArduino = components.some(
|
||||
(c) => c.kind === "arduino_uno" || c.kind === "arduino_nano" || c.kind === "esp32",
|
||||
);
|
||||
|
||||
// Short Circuit & Over-current Check
|
||||
const hasResistor = components.some((c) => c.kind === "resistor");
|
||||
const ledComp = components.find((c) => c.kind === "led" || c.kind === "rgb_led");
|
||||
const isExplicitShortTest = code.includes("KISA_DEVRE") || code.includes("SHORT_CIRCUIT");
|
||||
|
||||
if (!hasArduino && batComp) {
|
||||
const isPowered = switchOn;
|
||||
const v = isPowered ? (batComp.batteryVoltage ?? 9) : 0;
|
||||
activePins[13] = { digital: isPowered, pwm: isPowered ? 255 : 0, voltage: v };
|
||||
plotterValues["V_Bat"] = v;
|
||||
|
||||
const isDirectLedWithoutResistor = isPowered && v >= 4 && ledComp && !hasResistor;
|
||||
let shortCircuit = false;
|
||||
let shortCircuitReason = "";
|
||||
let explodedComponentId: string | undefined = undefined;
|
||||
|
||||
if (isDirectLedWithoutResistor || isExplicitShortTest) {
|
||||
shortCircuit = true;
|
||||
explodedComponentId = isDirectLedWithoutResistor ? ledComp?.id : batComp.id;
|
||||
shortCircuitReason = isDirectLedWithoutResistor
|
||||
? `Aşırı Akım: ${v}V pile akım sınırlayıcı direnç (220Ω) olmadan LED bağlandı. LED patladı!`
|
||||
: "Kısa Devre Testi: VCC ve GND doğrudan temas etti.";
|
||||
logLines.push(`[${timeStamp}] 💥 KRİTİK ALARM: ${shortCircuitReason}`);
|
||||
}
|
||||
|
||||
logLines.push(`[${timeStamp}] Harici Pil Devresi: ${isPowered ? `${v}.0V AKIM AKIYOR (Açık)` : "0.0V (Kapalı)"}`);
|
||||
return {
|
||||
activePins,
|
||||
buzzerActive: false,
|
||||
buzzerFrequency: 0,
|
||||
logLines,
|
||||
componentsPatch,
|
||||
plotterValues,
|
||||
shortCircuit,
|
||||
shortCircuitReason,
|
||||
explodedComponentId,
|
||||
};
|
||||
}
|
||||
|
||||
// Microcontroller short-circuit or over-current inspection
|
||||
let shortCircuit = false;
|
||||
let shortCircuitReason = "";
|
||||
let explodedComponentId: string | undefined = undefined;
|
||||
|
||||
if (isExplicitShortTest) {
|
||||
shortCircuit = true;
|
||||
shortCircuitReason = "Mikrodenetleyici Kısa Devre: D13 / 5V pimi GND ile köprülendi! Aşırı akım algılandı.";
|
||||
logLines.push(`[${timeStamp}] 💥 GÜVENLİK KORUMASI: ${shortCircuitReason}`);
|
||||
}
|
||||
|
||||
// 2. Intelligent Arduino Code Analysis
|
||||
// Ultrasonic / Radar detection
|
||||
if (code.includes("distanceCm") || code.includes("mesafe") || ultComp) {
|
||||
const isDanger = distCm < 25 || btnPressed;
|
||||
activePins[13] = { digital: isDanger, pwm: isDanger ? 255 : 0, voltage: isDanger ? 5 : 0 };
|
||||
activePins[12] = { digital: !isDanger, pwm: !isDanger ? 255 : 0, voltage: !isDanger ? 5 : 0 };
|
||||
activePins[8] = { digital: isDanger, pwm: isDanger ? 255 : 0, voltage: isDanger ? 5 : 0 };
|
||||
buzzerActive = isDanger;
|
||||
buzzerFrequency = isDanger ? Math.max(400, Math.min(1600, Math.round(2000 - distCm * 40))) : 0;
|
||||
plotterValues["Buzzer"] = isDanger ? 1 : 0;
|
||||
|
||||
logLines.push(
|
||||
isDanger
|
||||
? `[${timeStamp}] DIKKAT! Engel Cok Yakin: ${distCm} cm | Buzzer ALARM (${buzzerFrequency} Hz)`
|
||||
: `[${timeStamp}] Mesafe Guvenli: ${distCm} cm | Guvenli LED Aktif`,
|
||||
);
|
||||
}
|
||||
// Servo & Potentiometer control
|
||||
else if (code.includes("Servo") || code.includes("myServo")) {
|
||||
const angle = btnPressed ? 180 : Math.round((potVal / 1023) * 180);
|
||||
activePins[9] = { digital: true, pwm: Math.round((angle / 180) * 255), voltage: 5 };
|
||||
activePins[13] = { digital: potVal > 512 || btnPressed, pwm: 255, voltage: 5 };
|
||||
plotterValues["Servo_Aci"] = angle;
|
||||
|
||||
for (const c of components) {
|
||||
if (c.kind === "servo") {
|
||||
componentsPatch[c.id] = { servoAngle: angle };
|
||||
}
|
||||
}
|
||||
logLines.push(
|
||||
`[${timeStamp}] A0 Analog: ${potVal} (${((potVal / 1023) * 5).toFixed(2)}V) -> Servo Acisi: ${angle}° ${btnPressed ? "[TURBO]" : ""}`,
|
||||
);
|
||||
}
|
||||
// RGB LED Mixer (PWM D11, D10, D9)
|
||||
else if (code.includes("redPin") || code.includes("RGB") || components.some((c) => c.kind === "rgb_led")) {
|
||||
const rVal = Math.round((potVal / 1023) * 255);
|
||||
const gVal = Math.round(((1023 - potVal) / 1023) * 255);
|
||||
const bVal = btnPressed ? 255 : 128;
|
||||
|
||||
activePins[11] = { digital: rVal > 0, pwm: rVal, voltage: (rVal / 255) * 5 };
|
||||
activePins[10] = { digital: gVal > 0, pwm: gVal, voltage: (gVal / 255) * 5 };
|
||||
activePins[9] = { digital: bVal > 0, pwm: bVal, voltage: (bVal / 255) * 5 };
|
||||
|
||||
plotterValues["RGB_R"] = rVal;
|
||||
plotterValues["RGB_G"] = gVal;
|
||||
plotterValues["RGB_B"] = bVal;
|
||||
|
||||
for (const c of components) {
|
||||
if (c.kind === "rgb_led") {
|
||||
componentsPatch[c.id] = { rgbColor: { r: rVal, g: gVal, b: bVal } };
|
||||
}
|
||||
}
|
||||
logLines.push(`[${timeStamp}] RGB PWM -> R: ${rVal} | G: ${gVal} | B: ${bVal} (Hex: #${rVal.toString(16).padStart(2, "0")}${gVal.toString(16).padStart(2, "0")}${bVal.toString(16).padStart(2, "0")})`);
|
||||
}
|
||||
// PIR Security Alarm
|
||||
else if (code.includes("pirPin") || code.includes("hareket") || pirComp) {
|
||||
const isMotion = pirMotion || btnPressed;
|
||||
activePins[13] = { digital: isMotion, pwm: isMotion ? 255 : 0, voltage: isMotion ? 5 : 0 };
|
||||
activePins[8] = { digital: isMotion, pwm: isMotion ? 255 : 0, voltage: isMotion ? 5 : 0 };
|
||||
activePins[4] = { digital: isMotion, pwm: isMotion ? 255 : 0, voltage: isMotion ? 5 : 0 };
|
||||
buzzerActive = isMotion;
|
||||
buzzerFrequency = 1000;
|
||||
plotterValues["PIR_Alarm"] = isMotion ? 1 : 0;
|
||||
|
||||
for (const c of components) {
|
||||
if (c.kind === "relay") {
|
||||
componentsPatch[c.id] = { relayState: isMotion };
|
||||
}
|
||||
}
|
||||
logLines.push(
|
||||
isMotion
|
||||
? `[${timeStamp}] ALARM! HAREKET TESPIT EDILDI (PIR=HIGH) -> Role & Siren Aktif!`
|
||||
: `[${timeStamp}] PIR Guvenlik Devrede: Ortam guvenli (PIR=LOW)`,
|
||||
);
|
||||
}
|
||||
// LDR Light Sensor Nightlight
|
||||
else if (code.includes("ldrPin") || code.includes("esikDeger") || ldrComp) {
|
||||
const isDark = lightLux < 350 || btnPressed;
|
||||
activePins[13] = { digital: isDark, pwm: isDark ? 255 : 0, voltage: isDark ? 5 : 0 };
|
||||
plotterValues["Lamba"] = isDark ? 1 : 0;
|
||||
logLines.push(
|
||||
`[${timeStamp}] LDR Isik: ${lightLux} Lux -> ${isDark ? "KARANLIK: Sokak Lambasi Yandi (D13=5V)" : "AYDINLIK: Lamba Sondu (D13=0V)"}`,
|
||||
);
|
||||
}
|
||||
// 7-Segment Counter
|
||||
else if (code.includes("sayac") || components.some((c) => c.kind === "seven_segment")) {
|
||||
const digit = step % 10;
|
||||
const segMap = SEVEN_SEG_DIGITS[digit];
|
||||
for (const c of components) {
|
||||
if (c.kind === "seven_segment") {
|
||||
componentsPatch[c.id] = {
|
||||
sevenSegmentValue: String(digit),
|
||||
sevenSegmentSegments: segMap,
|
||||
};
|
||||
}
|
||||
}
|
||||
plotterValues["Sayac"] = digit;
|
||||
logLines.push(`[${timeStamp}] 7-Segment Ekran: Sayac = ${digit}`);
|
||||
}
|
||||
// LCD Thermometer & Humidity
|
||||
else if (code.includes("LiquidCrystal") || code.includes("sicaklik") || (tmpComp && components.some((c) => c.kind === "lcd16x2"))) {
|
||||
const isHot = tempC > 30 || btnPressed;
|
||||
activePins[13] = { digital: isHot, pwm: isHot ? 255 : 0, voltage: isHot ? 5 : 0 };
|
||||
plotterValues["Fan_LED"] = isHot ? 1 : 0;
|
||||
|
||||
for (const c of components) {
|
||||
if (c.kind === "lcd16x2") {
|
||||
componentsPatch[c.id] = {
|
||||
lcdLine1: `SICAKLIK: ${tempC.toFixed(1)} C`,
|
||||
lcdLine2: isHot ? "FAN: AKTIF (HOT)" : "DURUM: NORMAL",
|
||||
};
|
||||
}
|
||||
}
|
||||
logLines.push(`[${timeStamp}] LCD Termometre -> Sicaklik: ${tempC.toFixed(1)}°C | Fan: ${isHot ? "CALISIYOR" : "KAPALI"}`);
|
||||
}
|
||||
// DC Motor Speed Control
|
||||
else if (code.includes("motorHiz") || code.includes("motorPin") || components.some((c) => c.kind === "dc_motor")) {
|
||||
const pwmVal = Math.round((potVal / 1023) * 255);
|
||||
activePins[9] = { digital: pwmVal > 10, pwm: pwmVal, voltage: (pwmVal / 255) * 5 };
|
||||
const rpm = Math.round(pwmVal * 12);
|
||||
plotterValues["Motor_RPM"] = rpm;
|
||||
|
||||
for (const c of components) {
|
||||
if (c.kind === "dc_motor") {
|
||||
componentsPatch[c.id] = { motorSpeed: pwmVal };
|
||||
}
|
||||
}
|
||||
logLines.push(`[${timeStamp}] DC Motor PWM: ${pwmVal} / 255 -> Donus Hizi: ${rpm} RPM`);
|
||||
}
|
||||
// Stepper Motor (28BYJ-48 + ULN2003)
|
||||
else if (code.includes("Stepper") || code.includes("myStepper") || components.some((c) => c.kind === "stepper_motor")) {
|
||||
const coilIndex = step % 4;
|
||||
const activeCoils: [boolean, boolean, boolean, boolean] = [
|
||||
coilIndex === 0,
|
||||
coilIndex === 1,
|
||||
coilIndex === 2,
|
||||
coilIndex === 3,
|
||||
];
|
||||
const newAngle = (step * 22.5) % 360;
|
||||
activePins[8] = { digital: activeCoils[0], pwm: activeCoils[0] ? 255 : 0, voltage: activeCoils[0] ? 5 : 0 };
|
||||
activePins[9] = { digital: activeCoils[1], pwm: activeCoils[1] ? 255 : 0, voltage: activeCoils[1] ? 5 : 0 };
|
||||
activePins[10] = { digital: activeCoils[2], pwm: activeCoils[2] ? 255 : 0, voltage: activeCoils[2] ? 5 : 0 };
|
||||
activePins[11] = { digital: activeCoils[3], pwm: activeCoils[3] ? 255 : 0, voltage: activeCoils[3] ? 5 : 0 };
|
||||
|
||||
plotterValues["Step_Aci"] = newAngle;
|
||||
plotterValues["Bobin_IN"] = coilIndex + 1;
|
||||
|
||||
for (const c of components) {
|
||||
if (c.kind === "stepper_motor") {
|
||||
componentsPatch[c.id] = {
|
||||
stepperAngle: newAngle,
|
||||
stepperCoils: activeCoils,
|
||||
};
|
||||
}
|
||||
}
|
||||
logLines.push(`[${timeStamp}] 28BYJ-48 Step Motor -> Açı: ${newAngle.toFixed(1)}° | Aktif Faz: IN${coilIndex + 1}`);
|
||||
}
|
||||
// DHT11 Digital Weather Sensor
|
||||
else if (code.includes("dht") || code.includes("DHT") || components.some((c) => c.kind === "dht11")) {
|
||||
const dhtComp = components.find((c) => c.kind === "dht11");
|
||||
const dTemp = dhtComp?.dhtTemp ?? 24;
|
||||
const dHum = dhtComp?.dhtHumidity ?? 45;
|
||||
|
||||
plotterValues["DHT_Sicaklik"] = dTemp;
|
||||
plotterValues["DHT_Nem"] = dHum;
|
||||
|
||||
for (const c of components) {
|
||||
if (c.kind === "lcd16x2") {
|
||||
componentsPatch[c.id] = {
|
||||
lcdLine1: `T: ${dTemp}C | H: %${dHum}`,
|
||||
lcdLine2: dTemp > 30 ? "UYARI: SICAK!" : "HAVA: NORMAL",
|
||||
};
|
||||
}
|
||||
}
|
||||
logLines.push(`[${timeStamp}] DHT11 Okundu: Sıcaklık = ${dTemp}°C, Nem = %${dHum}`);
|
||||
}
|
||||
// 2-Axis Joystick Control
|
||||
else if (code.includes("joy") || code.includes("VRx") || components.some((c) => c.kind === "joystick")) {
|
||||
const joyComp = components.find((c) => c.kind === "joystick");
|
||||
const jX = joyComp?.joystickX ?? 512;
|
||||
const jY = joyComp?.joystickY ?? 512;
|
||||
const jPressed = Boolean(joyComp?.joystickPressed);
|
||||
|
||||
const mappedAngle = Math.round((jX / 1023) * 180);
|
||||
plotterValues["Joy_X"] = jX;
|
||||
plotterValues["Joy_Y"] = jY;
|
||||
|
||||
for (const c of components) {
|
||||
if (c.kind === "servo") {
|
||||
componentsPatch[c.id] = { servoAngle: mappedAngle };
|
||||
}
|
||||
}
|
||||
activePins[13] = { digital: jPressed, pwm: jPressed ? 255 : 0, voltage: jPressed ? 5 : 0 };
|
||||
logLines.push(`[${timeStamp}] Joystick: X=${jX}, Y=${jY}, Buton=${jPressed ? "BASILI" : "SERBEST"} -> Servo: ${mappedAngle}°`);
|
||||
}
|
||||
// Default: Traffic light / general cyclic pins (D13, D12, D11)
|
||||
else {
|
||||
const phase = step % 3;
|
||||
activePins[13] = { digital: phase === 0 || btnPressed, pwm: phase === 0 ? 255 : 0, voltage: phase === 0 ? 5 : 0 };
|
||||
activePins[12] = { digital: phase === 1, pwm: phase === 1 ? 255 : 0, voltage: phase === 1 ? 5 : 0 };
|
||||
activePins[11] = { digital: phase === 2, pwm: phase === 2 ? 255 : 0, voltage: phase === 2 ? 5 : 0 };
|
||||
|
||||
plotterValues["D13_Kirmizi"] = phase === 0 ? 5 : 0;
|
||||
plotterValues["D12_Sari"] = phase === 1 ? 5 : 0;
|
||||
plotterValues["D11_Yesil"] = phase === 2 ? 5 : 0;
|
||||
|
||||
const labels = [
|
||||
"DUR: Kirmizi Isik Yanıyor (D13=5.00V)",
|
||||
"HAZIRLAN: Sari Isik Yanıyor (D12=5.00V)",
|
||||
"GEC: Yesil Isik Yanıyor (D11=5.00V)",
|
||||
];
|
||||
logLines.push(`[${timeStamp}] ${labels[phase]}`);
|
||||
}
|
||||
|
||||
return {
|
||||
activePins,
|
||||
buzzerActive,
|
||||
buzzerFrequency,
|
||||
logLines,
|
||||
componentsPatch,
|
||||
plotterValues,
|
||||
shortCircuit,
|
||||
shortCircuitReason,
|
||||
explodedComponentId,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,700 @@
|
||||
import type { CircuitTemplate } from "./types";
|
||||
|
||||
export const CIRCUIT_TEMPLATES: CircuitTemplate[] = [
|
||||
{
|
||||
id: "traffic-light",
|
||||
title: "Akıllı Trafik Lambası (3x LED + Arduino Uno)",
|
||||
badge: "Başlangıç",
|
||||
category: "Temel",
|
||||
description: "Kırmızı, sarı ve yeşil LED'lerin zamanlamalı sıralı çalışması ve seri port bildirimleri.",
|
||||
libraryIds: [],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "bb1", kind: "breadboard", name: "Breadboard (400 Pin)", x: 330, y: 130 },
|
||||
{ id: "led_r", kind: "led", name: "Kırmızı LED (D13)", x: 350, y: 20, ledColor: "red", digitalPin: 13 },
|
||||
{ id: "led_y", kind: "led", name: "Sarı LED (D12)", x: 440, y: 20, ledColor: "yellow", digitalPin: 12 },
|
||||
{ id: "led_g", kind: "led", name: "Yeşil LED (D11)", x: 530, y: 20, ledColor: "green", digitalPin: 11 },
|
||||
{ id: "res1", kind: "resistor", name: "220Ω Direnç", x: 360, y: 310, resistanceOhms: 220 },
|
||||
{ id: "mm1", kind: "multimeter", name: "Dijital Multimetre", x: 510, y: 300 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "w1", fromCompId: "uno1", fromPinId: "D13", toCompId: "led_r", toPinId: "ANODE", color: "#ef4444" },
|
||||
{ id: "w2", fromCompId: "uno1", fromPinId: "D12", toCompId: "led_y", toPinId: "ANODE", color: "#eab308" },
|
||||
{ id: "w3", fromCompId: "uno1", fromPinId: "D11", toCompId: "led_g", toPinId: "ANODE", color: "#10b981" },
|
||||
{ id: "w4", fromCompId: "uno1", fromPinId: "GND", toCompId: "bb1", toPinId: "GND_TOP", color: "#1e293b" },
|
||||
{ id: "w5", fromCompId: "led_r", fromPinId: "CATHODE", toCompId: "res1", toPinId: "T1", color: "#1e293b" },
|
||||
{ id: "w6", fromCompId: "res1", fromPinId: "T2", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "w7", fromCompId: "uno1", fromPinId: "D13", toCompId: "mm1", toPinId: "V_POS", color: "#ef4444" },
|
||||
{ id: "w8", fromCompId: "uno1", fromPinId: "GND", toCompId: "mm1", toPinId: "V_COM", color: "#1e293b" },
|
||||
],
|
||||
code: `// SnapCAD Arduino Uno - Akıllı Trafik Lambası
|
||||
void setup() {
|
||||
pinMode(13, OUTPUT); // Kırmızı LED
|
||||
pinMode(12, OUTPUT); // Sarı LED
|
||||
pinMode(11, OUTPUT); // Yeşil LED
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// 1. Kırmızı Işık (DUR)
|
||||
digitalWrite(13, HIGH);
|
||||
digitalWrite(12, LOW);
|
||||
digitalWrite(11, LOW);
|
||||
Serial.println("DUR: Kirmizi Isik Yanıyor (D13=5V)");
|
||||
delay(1200);
|
||||
|
||||
// 2. Sarı Işık (HAZIRLAN)
|
||||
digitalWrite(13, LOW);
|
||||
digitalWrite(12, HIGH);
|
||||
digitalWrite(11, LOW);
|
||||
Serial.println("HAZIRLAN: Sari Isik Yanıyor (D12=5V)");
|
||||
delay(600);
|
||||
|
||||
// 3. Yeşil Işık (GEÇ)
|
||||
digitalWrite(13, LOW);
|
||||
digitalWrite(12, LOW);
|
||||
digitalWrite(11, HIGH);
|
||||
Serial.println("GEC: Yesil Isik Yanıyor (D11=5V)");
|
||||
delay(1200);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "servo-pot",
|
||||
title: "Potansiyometre İle Servo Motor Açı Kontrolü",
|
||||
badge: "Analog & PWM",
|
||||
category: "Motor & Hareket",
|
||||
description: "Analog A0 girişinden okunan potansiyometre değeriyle SG90 mikro servo motorun açısını 0°-180° arası ayarlama.",
|
||||
libraryIds: ["servo"],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "pot1", kind: "potentiometer", name: "Potansiyometre (A0)", x: 360, y: 50, analogPin: "A0", potValue: 512 },
|
||||
{ id: "srv1", kind: "servo", name: "SG90 Servo (D9)", x: 500, y: 50, digitalPin: 9, servoAngle: 90 },
|
||||
{ id: "led_b", kind: "led", name: "Durum LED (D13)", x: 380, y: 220, ledColor: "cyan", digitalPin: 13 },
|
||||
{ id: "btn1", kind: "pushbutton", name: "Turbo Butonu (D2)", x: 500, y: 220, digitalPin: 2, pressed: false },
|
||||
],
|
||||
wires: [
|
||||
{ id: "sw1", fromCompId: "pot1", fromPinId: "SIG", toCompId: "uno1", toPinId: "A0", color: "#a855f7" },
|
||||
{ id: "sw2", fromCompId: "pot1", fromPinId: "VCC", toCompId: "uno1", toPinId: "5V", color: "#ef4444" },
|
||||
{ id: "sw3", fromCompId: "pot1", fromPinId: "GND", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "sw4", fromCompId: "uno1", fromPinId: "D9", toCompId: "srv1", toPinId: "SIG", color: "#f97316" },
|
||||
{ id: "sw5", fromCompId: "uno1", fromPinId: "5V", toCompId: "srv1", toPinId: "VCC", color: "#ef4444" },
|
||||
{ id: "sw6", fromCompId: "uno1", fromPinId: "GND", toCompId: "srv1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "sw7", fromCompId: "uno1", fromPinId: "D13", toCompId: "led_b", toPinId: "ANODE", color: "#3b82f6" },
|
||||
{ id: "sw8", fromCompId: "btn1", fromPinId: "P1", toCompId: "uno1", toPinId: "D2", color: "#10b981" },
|
||||
],
|
||||
code: `// SnapCAD Potansiyometre -> SG90 Servo Açı Kontrolü
|
||||
#include <Servo.h>
|
||||
|
||||
Servo myServo;
|
||||
|
||||
void setup() {
|
||||
myServo.attach(9); // Servo D9 pinine bağlı
|
||||
pinMode(13, OUTPUT);
|
||||
pinMode(2, INPUT_PULLUP);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int potDeger = analogRead(A0);
|
||||
int aci = map(potDeger, 0, 1023, 0, 180);
|
||||
|
||||
// Butona basıldığında tam 180 dereceye fırla
|
||||
if (digitalRead(2) == LOW) {
|
||||
aci = 180;
|
||||
}
|
||||
|
||||
myServo.write(aci);
|
||||
digitalWrite(13, potDeger > 512 ? HIGH : LOW);
|
||||
|
||||
Serial.print("Potansiyometre: ");
|
||||
Serial.print(potDeger);
|
||||
Serial.print(" -> Servo Acisi: ");
|
||||
Serial.print(aci);
|
||||
Serial.println(" derece");
|
||||
delay(400);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "ultrasonic-radar",
|
||||
title: "HC-SR04 Ultrasonik Park Radarı & Buzzer Alarmı",
|
||||
badge: "Sensör & Ses",
|
||||
category: "Sensörler",
|
||||
description: "Mesafe sensörü ile engel algılama, kritik mesafede piezo buzzer ile değişken frekansta alarm çalma.",
|
||||
libraryIds: [],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "ult1", kind: "ultrasonic", name: "HC-SR04 Mesafe Sensörü", x: 370, y: 50, distanceCm: 18 },
|
||||
{ id: "buz1", kind: "buzzer", name: "Piezo Buzzer (D8)", x: 550, y: 55, digitalPin: 8 },
|
||||
{ id: "led_warn", kind: "led", name: "Tehlike LED (D13)", x: 390, y: 220, ledColor: "red", digitalPin: 13 },
|
||||
{ id: "led_ok", kind: "led", name: "Güvenli LED (D12)", x: 510, y: 220, ledColor: "green", digitalPin: 12 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "uw1", fromCompId: "ult1", fromPinId: "VCC", toCompId: "uno1", toPinId: "5V", color: "#ef4444" },
|
||||
{ id: "uw2", fromCompId: "ult1", fromPinId: "GND", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "uw3", fromCompId: "ult1", fromPinId: "TRIG", toCompId: "uno1", toPinId: "D10", color: "#3b82f6" },
|
||||
{ id: "uw4", fromCompId: "ult1", fromPinId: "ECHO", toCompId: "uno1", toPinId: "D9", color: "#a855f7" },
|
||||
{ id: "uw5", fromCompId: "uno1", fromPinId: "D8", toCompId: "buz1", toPinId: "POS", color: "#f97316" },
|
||||
{ id: "uw6", fromCompId: "buz1", fromPinId: "NEG", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "uw7", fromCompId: "uno1", fromPinId: "D13", toCompId: "led_warn", toPinId: "ANODE", color: "#ef4444" },
|
||||
{ id: "uw8", fromCompId: "uno1", fromPinId: "D12", toCompId: "led_ok", toPinId: "ANODE", color: "#10b981" },
|
||||
],
|
||||
code: `// SnapCAD HC-SR04 Ultrasonik Park Radarı
|
||||
const int trigPin = 10;
|
||||
const int echoPin = 9;
|
||||
const int buzzerPin = 8;
|
||||
const int tehlikeLed = 13;
|
||||
const int guvenliLed = 12;
|
||||
|
||||
void setup() {
|
||||
pinMode(trigPin, OUTPUT);
|
||||
pinMode(echoPin, INPUT);
|
||||
pinMode(buzzerPin, OUTPUT);
|
||||
pinMode(tehlikeLed, OUTPUT);
|
||||
pinMode(guvenliLed, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Simülasyonda distanceCm değeri dinamik okunur
|
||||
if (distanceCm < 25) {
|
||||
digitalWrite(tehlikeLed, HIGH);
|
||||
digitalWrite(guvenliLed, LOW);
|
||||
tone(buzzerPin, 880);
|
||||
Serial.println("DIKKAT! Engel Cok Yakin: " + String(distanceCm) + " cm | ALARM");
|
||||
} else {
|
||||
digitalWrite(tehlikeLed, LOW);
|
||||
digitalWrite(guvenliLed, HIGH);
|
||||
noTone(buzzerPin);
|
||||
Serial.println("Mesafe Guvenli: " + String(distanceCm) + " cm");
|
||||
}
|
||||
delay(400);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "rgb-mixer",
|
||||
title: "RGB LED Renk Paleti Mikseri (3x PWM)",
|
||||
badge: "PWM Renk",
|
||||
category: "Göstergeler",
|
||||
description: "4 bacaklı RGB LED'in Kırmızı (D11), Yeşil (D10) ve Mavi (D9) PWM kanallarını sürerek 16 milyon renk sentezi.",
|
||||
libraryIds: [],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "rgb1", kind: "rgb_led", name: "RGB LED (Ortak Katot)", x: 380, y: 50, rgbColor: { r: 255, g: 0, b: 128 } },
|
||||
{ id: "pot_r", kind: "potentiometer", name: "Kırmızı Pot (A0)", x: 340, y: 210, analogPin: "A0", potValue: 900 },
|
||||
{ id: "pot_g", kind: "potentiometer", name: "Yeşil Pot (A1)", x: 450, y: 210, analogPin: "A1", potValue: 200 },
|
||||
{ id: "pot_b", kind: "potentiometer", name: "Mavi Pot (A2)", x: 560, y: 210, analogPin: "A2", potValue: 800 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "rw1", fromCompId: "uno1", fromPinId: "D11", toCompId: "rgb1", toPinId: "RED", color: "#ef4444" },
|
||||
{ id: "rw2", fromCompId: "rgb1", fromPinId: "CATHODE", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "rw3", fromCompId: "uno1", fromPinId: "D10", toCompId: "rgb1", toPinId: "GREEN", color: "#10b981" },
|
||||
{ id: "rw4", fromCompId: "uno1", fromPinId: "D9", toCompId: "rgb1", toPinId: "BLUE", color: "#3b82f6" },
|
||||
{ id: "rw5", fromCompId: "pot_r", fromPinId: "SIG", toCompId: "uno1", toPinId: "A0", color: "#ef4444" },
|
||||
{ id: "rw6", fromCompId: "pot_g", fromPinId: "SIG", toCompId: "uno1", toPinId: "A1", color: "#10b981" },
|
||||
{ id: "rw7", fromCompId: "pot_b", fromPinId: "SIG", toCompId: "uno1", toPinId: "A2", color: "#3b82f6" },
|
||||
],
|
||||
code: `// SnapCAD RGB LED Renk Mikseri (PWM ile 16 Milyon Renk)
|
||||
const int redPin = 11;
|
||||
const int greenPin = 10;
|
||||
const int bluePin = 9;
|
||||
|
||||
void setup() {
|
||||
pinMode(redPin, OUTPUT);
|
||||
pinMode(greenPin, OUTPUT);
|
||||
pinMode(bluePin, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int rVal = map(analogRead(A0), 0, 1023, 0, 255);
|
||||
int gVal = map(analogRead(A1), 0, 1023, 0, 255);
|
||||
int bVal = map(analogRead(A2), 0, 1023, 0, 255);
|
||||
|
||||
analogWrite(redPin, rVal);
|
||||
analogWrite(greenPin, gVal);
|
||||
analogWrite(bluePin, bVal);
|
||||
|
||||
Serial.println("RGB Renk -> R: " + String(rVal) + " G: " + String(gVal) + " B: " + String(bVal));
|
||||
delay(500);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "seven-segment-counter",
|
||||
title: "7-Segment Dijital Sayıcı & Buton Sayacı",
|
||||
badge: "Dijital Ekran",
|
||||
category: "Göstergeler",
|
||||
description: "Ortak katot 7 segmentli gösterge üzerinde 0-9 rakamlarını buton tetiklemeli saydırma.",
|
||||
libraryIds: [],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "seg1", kind: "seven_segment", name: "7-Segment Ekran", x: 410, y: 40, sevenSegmentValue: "0" },
|
||||
{ id: "btn_inc", kind: "pushbutton", name: "Sayı Arttır (D2)", x: 380, y: 220, digitalPin: 2, pressed: false },
|
||||
{ id: "res1", kind: "resistor", name: "330Ω Direnç", x: 500, y: 220, resistanceOhms: 330 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "seg_w1", fromCompId: "uno1", fromPinId: "D7", toCompId: "seg1", toPinId: "A", color: "#3b82f6" },
|
||||
{ id: "seg_w2", fromCompId: "uno1", fromPinId: "D8", toCompId: "seg1", toPinId: "B", color: "#3b82f6" },
|
||||
{ id: "seg_w3", fromCompId: "uno1", fromPinId: "D2", toCompId: "seg1", toPinId: "C", color: "#3b82f6" },
|
||||
{ id: "seg_w4", fromCompId: "uno1", fromPinId: "D3", toCompId: "seg1", toPinId: "D", color: "#3b82f6" },
|
||||
{ id: "seg_w5", fromCompId: "uno1", fromPinId: "D4", toCompId: "seg1", toPinId: "E", color: "#3b82f6" },
|
||||
{ id: "seg_w6", fromCompId: "uno1", fromPinId: "D9", toCompId: "seg1", toPinId: "F", color: "#3b82f6" },
|
||||
{ id: "seg_w7", fromCompId: "seg1", fromPinId: "COM", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "seg_w8", fromCompId: "btn_inc", fromPinId: "P1", toCompId: "uno1", toPinId: "D2", color: "#10b981" },
|
||||
],
|
||||
code: `// SnapCAD 7-Segment Dijital Sayıcı
|
||||
int sayac = 0;
|
||||
|
||||
void setup() {
|
||||
for (int pin = 2; pin <= 9; pin++) {
|
||||
pinMode(pin, OUTPUT);
|
||||
}
|
||||
pinMode(2, INPUT_PULLUP);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
sayac = (sayac + 1) % 10;
|
||||
Serial.println("Sayac Degeri: " + String(sayac));
|
||||
delay(1000);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "pir-alarm",
|
||||
title: "PIR Hareket Sensörlü Ev Güvenlik Alarmı",
|
||||
badge: "Güvenlik & PIR",
|
||||
category: "Sensörler",
|
||||
description: "HC-SR501 PIR hareket sensörü ortamda canlı hareketi algıladığında röle ve buzzer ile alarm çalar.",
|
||||
libraryIds: [],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "pir1", kind: "pir_sensor", name: "HC-SR501 PIR Sensör", x: 370, y: 50, pirMotion: false, digitalPin: 7 },
|
||||
{ id: "buz1", kind: "buzzer", name: "Siren Buzzer (D8)", x: 520, y: 50, digitalPin: 8 },
|
||||
{ id: "led_alert", kind: "led", name: "Alarm LED (D13)", x: 390, y: 220, ledColor: "red", digitalPin: 13 },
|
||||
{ id: "relay1", kind: "relay", name: "Işık Rölesi (D4)", x: 500, y: 210, relayState: false, digitalPin: 4 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "pw1", fromCompId: "pir1", fromPinId: "VCC", toCompId: "uno1", toPinId: "5V", color: "#ef4444" },
|
||||
{ id: "pw2", fromCompId: "pir1", fromPinId: "GND", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "pw3", fromCompId: "pir1", fromPinId: "OUT", toCompId: "uno1", toPinId: "D7", color: "#f97316" },
|
||||
{ id: "pw4", fromCompId: "uno1", fromPinId: "D8", toCompId: "buz1", toPinId: "POS", color: "#ef4444" },
|
||||
{ id: "pw5", fromCompId: "buz1", fromPinId: "NEG", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "pw6", fromCompId: "uno1", fromPinId: "D13", toCompId: "led_alert", toPinId: "ANODE", color: "#ef4444" },
|
||||
{ id: "pw7", fromCompId: "uno1", fromPinId: "D4", toCompId: "relay1", toPinId: "IN", color: "#a855f7" },
|
||||
],
|
||||
code: `// SnapCAD PIR Hareket Sensörlü Güvenlik Alarmı
|
||||
const int pirPin = 7;
|
||||
const int buzzerPin = 8;
|
||||
const int ledPin = 13;
|
||||
const int relayPin = 4;
|
||||
|
||||
void setup() {
|
||||
pinMode(pirPin, INPUT);
|
||||
pinMode(buzzerPin, OUTPUT);
|
||||
pinMode(ledPin, OUTPUT);
|
||||
pinMode(relayPin, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int hareket = digitalRead(pirPin);
|
||||
if (hareket == HIGH || pirMotion) {
|
||||
digitalWrite(ledPin, HIGH);
|
||||
digitalWrite(relayPin, HIGH);
|
||||
tone(buzzerPin, 1000);
|
||||
Serial.println("ALARM! HAREKET TESPIT EDILDI! Projektor Role Aktif");
|
||||
} else {
|
||||
digitalWrite(ledPin, LOW);
|
||||
digitalWrite(relayPin, LOW);
|
||||
noTone(buzzerPin);
|
||||
Serial.println("Guvenlik Devrede: Ortam Sakin");
|
||||
}
|
||||
delay(500);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "ldr-nightlight",
|
||||
title: "LDR Işık Sensörlü Otomatik Gece Lambası",
|
||||
badge: "Foto-Direnç",
|
||||
category: "Sensörler",
|
||||
description: "Güneş battığında veya ortam karardığında otomatik yanan akıllı sokak aydınlatma sistemi.",
|
||||
libraryIds: [],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "ldr1", kind: "ldr", name: "LDR Işık Sensörü (A2)", x: 370, y: 50, lightLux: 400, analogPin: "A2" },
|
||||
{ id: "led_lamp", kind: "led", name: "Sokak Lambası LED (D13)", x: 500, y: 50, ledColor: "yellow", digitalPin: 13 },
|
||||
{ id: "res_div", kind: "resistor", name: "10kΩ Gerilim Bölücü", x: 390, y: 220, resistanceOhms: 10000 },
|
||||
{ id: "mm1", kind: "multimeter", name: "Işık Voltajı Ölçer", x: 510, y: 220 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "lw1", fromCompId: "uno1", fromPinId: "5V", toCompId: "ldr1", toPinId: "L1", color: "#ef4444" },
|
||||
{ id: "lw2", fromCompId: "ldr1", fromPinId: "L2", toCompId: "uno1", toPinId: "A2", color: "#a855f7" },
|
||||
{ id: "lw3", fromCompId: "ldr1", fromPinId: "L2", toCompId: "res_div", toPinId: "T1", color: "#a855f7" },
|
||||
{ id: "lw4", fromCompId: "res_div", fromPinId: "T2", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "lw5", fromCompId: "uno1", fromPinId: "D13", toCompId: "led_lamp", toPinId: "ANODE", color: "#eab308" },
|
||||
{ id: "lw6", fromCompId: "led_lamp", fromPinId: "CATHODE", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
],
|
||||
code: `// SnapCAD LDR Otomatik Sokak & Gece Lambası
|
||||
const int ldrPin = A2;
|
||||
const int lambaPin = 13;
|
||||
const int esikDeger = 500; // Karanlık eşiği
|
||||
|
||||
void setup() {
|
||||
pinMode(lambaPin, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int isikSeviyesi = analogRead(ldrPin);
|
||||
Serial.print("Isik Sensöru (A2): ");
|
||||
Serial.print(isikSeviyesi);
|
||||
|
||||
if (isikSeviyesi < esikDeger || lightLux < 300) {
|
||||
digitalWrite(lambaPin, HIGH);
|
||||
Serial.println(" -> KARANLIK: Lamba Yandi (ON)");
|
||||
} else {
|
||||
digitalWrite(lambaPin, LOW);
|
||||
Serial.println(" -> AYDINLIK: Lamba Sondu (OFF)");
|
||||
}
|
||||
delay(500);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "lcd-thermometer",
|
||||
title: "16x2 I2C LCD Ekranlı Akıllı Dijital Termometre",
|
||||
badge: "I2C & LCD",
|
||||
category: "Göstergeler",
|
||||
description: "TMP36 analog sensöründen ortam sıcaklığını okuyup I2C LiquidCrystal kütüphanesiyle ekrana yazdırma.",
|
||||
libraryIds: ["liquidcrystal_i2c", "wire"],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "lcd1", kind: "lcd16x2", name: "16x2 I2C LCD", x: 360, y: 50, lcdLine1: "SICAKLIK: 24.5 C", lcdLine2: "DURUM: NORMAL" },
|
||||
{ id: "tmp1", kind: "tmp36", name: "TMP36 Sensör (A1)", x: 550, y: 50, tempCelsius: 24, analogPin: "A1" },
|
||||
{ id: "led_fan", kind: "led", name: "Klima Aktif LED (D13)", x: 450, y: 220, ledColor: "blue", digitalPin: 13 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "lcdw1", fromCompId: "lcd1", fromPinId: "GND", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "lcdw2", fromCompId: "lcd1", fromPinId: "VCC", toCompId: "uno1", toPinId: "5V", color: "#ef4444" },
|
||||
{ id: "lcdw3", fromCompId: "lcd1", fromPinId: "SDA", toCompId: "uno1", toPinId: "A4", color: "#3b82f6" },
|
||||
{ id: "lcdw4", fromCompId: "lcd1", fromPinId: "SCL", toCompId: "uno1", toPinId: "A5", color: "#10b981" },
|
||||
{ id: "lcdw5", fromCompId: "tmp1", fromPinId: "VOUT", toCompId: "uno1", toPinId: "A1", color: "#f97316" },
|
||||
{ id: "lcdw6", fromCompId: "tmp1", fromPinId: "VCC", toCompId: "uno1", toPinId: "5V", color: "#ef4444" },
|
||||
{ id: "lcdw7", fromCompId: "tmp1", fromPinId: "GND", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
],
|
||||
code: `// SnapCAD 16x2 I2C LCD Ekranlı Termometre
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void setup() {
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
pinMode(13, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int ham = analogRead(A1);
|
||||
float gerilim = ham * (5.0 / 1024.0);
|
||||
float sicaklik = (gerilim - 0.5) * 100.0;
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print("Sicaklik: ");
|
||||
lcd.print(sicaklik, 1);
|
||||
lcd.print(" C");
|
||||
|
||||
lcd.setCursor(0, 1);
|
||||
if (sicaklik > 30.0 || tempCelsius > 30) {
|
||||
lcd.print("FAN: AKTIF (HOT)");
|
||||
digitalWrite(13, HIGH);
|
||||
} else {
|
||||
lcd.print("DURUM: NORMAL ");
|
||||
digitalWrite(13, LOW);
|
||||
}
|
||||
|
||||
Serial.println("Sicaklik: " + String(sicaklik) + " C");
|
||||
delay(600);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "dc-motor-transistor",
|
||||
title: "DC Motor Hız Kontrolü & Transistör Sürücü",
|
||||
badge: "Motor & Transistör",
|
||||
category: "Motor & Hareket",
|
||||
description: "2N2222 NPN transistör, 1N4007 ters EMK diyotu ve PWM ile yüksek akımlı DC motor sürüşü.",
|
||||
libraryIds: [],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "dcm1", kind: "dc_motor", name: "DC Fan Motoru", x: 380, y: 50, motorSpeed: 180 },
|
||||
{ id: "trn1", kind: "transistor", name: "2N2222 Transistör", x: 530, y: 50 },
|
||||
{ id: "dio1", kind: "diode", name: "1N4007 Diyot", x: 400, y: 210 },
|
||||
{ id: "pot1", kind: "potentiometer", name: "Hız Potu (A0)", x: 520, y: 210, analogPin: "A0", potValue: 768 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "mw1", fromCompId: "uno1", fromPinId: "D9", toCompId: "trn1", toPinId: "B", color: "#f97316" },
|
||||
{ id: "mw2", fromCompId: "trn1", fromPinId: "C", toCompId: "dcm1", toPinId: "NEG", color: "#3b82f6" },
|
||||
{ id: "mw3", fromCompId: "trn1", fromPinId: "E", toCompId: "uno1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "mw4", fromCompId: "uno1", fromPinId: "5V", toCompId: "dcm1", toPinId: "POS", color: "#ef4444" },
|
||||
{ id: "mw5", fromCompId: "pot1", fromPinId: "SIG", toCompId: "uno1", toPinId: "A0", color: "#a855f7" },
|
||||
],
|
||||
code: `// SnapCAD NPN Transistör ile DC Motor PWM Hız Kontrolü
|
||||
const int motorPin = 9; // PWM D9
|
||||
|
||||
void setup() {
|
||||
pinMode(motorPin, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int pot = analogRead(A0);
|
||||
int motorHiz = map(pot, 0, 1023, 0, 255);
|
||||
analogWrite(motorPin, motorHiz);
|
||||
|
||||
Serial.print("Hiz Pot: ");
|
||||
Serial.print(pot);
|
||||
Serial.print(" -> PWM Cikisi: ");
|
||||
Serial.print(motorHiz);
|
||||
Serial.println(" (RPM: " + String(motorHiz * 12) + ")");
|
||||
delay(400);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "battery-switch-led",
|
||||
title: "9V Pil & Sürgülü Anahtar ile Temel LED Devresi",
|
||||
badge: "Temel Elektronik",
|
||||
category: "Temel",
|
||||
description: "Mikrodenetleyici gerektirmeyen bağımsız DC güç, anahtar ve dirençli temel elektronik devresi.",
|
||||
libraryIds: [],
|
||||
components: [
|
||||
{ id: "bat1", kind: "battery_9v", name: "9V Blok Pil", x: 60, y: 120, batteryVoltage: 9 },
|
||||
{ id: "sw1", kind: "slide_switch", name: "Sürgülü Anahtar", x: 280, y: 120, switchOn: true },
|
||||
{ id: "res1", kind: "resistor", name: "470Ω Direnç", x: 440, y: 120, resistanceOhms: 470 },
|
||||
{ id: "led1", kind: "led", name: "Parlak Kırmızı LED", x: 580, y: 110, ledColor: "red" },
|
||||
{ id: "mm1", kind: "multimeter", name: "Voltmetre", x: 380, y: 260 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "bw1", fromCompId: "bat1", fromPinId: "POS", toCompId: "sw1", toPinId: "COM", color: "#ef4444" },
|
||||
{ id: "bw2", fromCompId: "sw1", fromPinId: "T1", toCompId: "res1", toPinId: "T1", color: "#ef4444" },
|
||||
{ id: "bw3", fromCompId: "res1", fromPinId: "T2", toCompId: "led1", toPinId: "ANODE", color: "#ef4444" },
|
||||
{ id: "bw4", fromCompId: "led1", fromPinId: "CATHODE", toCompId: "bat1", toPinId: "NEG", color: "#1e293b" },
|
||||
{ id: "bw5", fromCompId: "sw1", fromPinId: "T1", toCompId: "mm1", toPinId: "V_POS", color: "#ef4444" },
|
||||
{ id: "bw6", fromCompId: "bat1", fromPinId: "NEG", toCompId: "mm1", toPinId: "V_COM", color: "#1e293b" },
|
||||
],
|
||||
code: `// SnapCAD 9V Pil & Temel LED Devresi
|
||||
// Bu devre harici 9V pil ile dogrudan calismaktadir.
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("[9V DC Pil Devresi] Anahtari acip kapatarak akimi gozlemleyin.");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println("Devre Gerilimi: 9.00V | Akim: ~15mA");
|
||||
delay(1000);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "stepper-motor-uln2003",
|
||||
title: "28BYJ-48 Step Motor & ULN2003 Sürücü Kartı",
|
||||
badge: "Mekanizma & Robotik",
|
||||
category: "Motor & Hareket",
|
||||
description: "4 fazlı step motorun ULN2003 sürücü kartı üzerinden adım adım hassas açı ve devir kontrolü.",
|
||||
libraryIds: ["stepper", "accelstepper"],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "step1", kind: "stepper_motor", name: "28BYJ-48 Step Motor & ULN2003", x: 420, y: 110, stepperAngle: 0 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "sw1", fromCompId: "uno1", fromPinId: "D8", toCompId: "step1", toPinId: "IN1", color: "#3b82f6" },
|
||||
{ id: "sw2", fromCompId: "uno1", fromPinId: "D9", toCompId: "step1", toPinId: "IN2", color: "#10b981" },
|
||||
{ id: "sw3", fromCompId: "uno1", fromPinId: "D10", toCompId: "step1", toPinId: "IN3", color: "#eab308" },
|
||||
{ id: "sw4", fromCompId: "uno1", fromPinId: "D11", toCompId: "step1", toPinId: "IN4", color: "#f97316" },
|
||||
{ id: "sw5", fromCompId: "uno1", fromPinId: "5V", toCompId: "step1", toPinId: "VCC", color: "#ef4444" },
|
||||
{ id: "sw6", fromCompId: "uno1", fromPinId: "GND", toCompId: "step1", toPinId: "GND", color: "#1e293b" },
|
||||
],
|
||||
code: `// SnapCAD 28BYJ-48 Step Motor & ULN2003 Kontrolü
|
||||
#include <Stepper.h>
|
||||
|
||||
const int stepsPerRevolution = 2048; // 28BYJ-48 tam tur adım sayısı
|
||||
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
|
||||
|
||||
void setup() {
|
||||
myStepper.setSpeed(12); // 12 RPM
|
||||
Serial.begin(9600);
|
||||
Serial.println("Step Motor Baslatildi (2048 Adim/Tur)");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.println("Saat yonunde donuyor...");
|
||||
myStepper.step(stepsPerRevolution / 4); // 90 derece dön
|
||||
delay(1000);
|
||||
|
||||
Serial.println("Saat yonunun tersine donuyor...");
|
||||
myStepper.step(-stepsPerRevolution / 4); // 90 derece geri dön
|
||||
delay(1000);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "dht11-weather-station",
|
||||
title: "DHT11 Dijital Hava İstasyonu & I2C LCD Ekran",
|
||||
badge: "Sensör & Ekran",
|
||||
category: "Sensörler",
|
||||
description: "DHT11 ile ortam sıcaklığı ve nemini okuyup 16x2 I2C LCD ekranda canlı görüntüleme.",
|
||||
libraryIds: ["dht", "liquidcrystal_i2c", "wire"],
|
||||
components: [
|
||||
{ id: "uno1", kind: "arduino_uno", name: "Arduino Uno R3", x: 40, y: 120 },
|
||||
{ id: "dht1", kind: "dht11", name: "DHT11 Sensör", x: 380, y: 70, dhtTemp: 24, dhtHumidity: 45 },
|
||||
{ id: "lcd1", kind: "lcd16x2", name: "16x2 I2C LCD Ekran", x: 350, y: 220, lcdLine1: "T: 24.0C H: %45", lcdLine2: "HAVA: NORMAL" },
|
||||
],
|
||||
wires: [
|
||||
{ id: "dw1", fromCompId: "uno1", fromPinId: "D2", toCompId: "dht1", toPinId: "DATA", color: "#10b981" },
|
||||
{ id: "dw2", fromCompId: "uno1", fromPinId: "5V", toCompId: "dht1", toPinId: "VCC", color: "#ef4444" },
|
||||
{ id: "dw3", fromCompId: "uno1", fromPinId: "GND", toCompId: "dht1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "lw1", fromCompId: "uno1", fromPinId: "A4", toCompId: "lcd1", toPinId: "SDA", color: "#a855f7" },
|
||||
{ id: "lw2", fromCompId: "uno1", fromPinId: "A5", toCompId: "lcd1", toPinId: "SCL", color: "#f97316" },
|
||||
{ id: "lw3", fromCompId: "uno1", fromPinId: "5V", toCompId: "lcd1", toPinId: "VCC", color: "#ef4444" },
|
||||
{ id: "lw4", fromCompId: "uno1", fromPinId: "GND", toCompId: "lcd1", toPinId: "GND", color: "#1e293b" },
|
||||
],
|
||||
code: `// SnapCAD DHT11 & I2C LCD Hava İstasyonu
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
#include <DHT.h>
|
||||
|
||||
#define DHTPIN 2
|
||||
#define DHTTYPE DHT11
|
||||
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
LiquidCrystal_I2C lcd(0x27, 16, 2);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
dht.begin();
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print("SnapCAD Weather");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
float h = dht.readHumidity();
|
||||
float t = dht.readTemperature();
|
||||
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print("T: " + String(t, 1) + "C H: %" + String((int)h));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(t > 30 ? "UYARI: SICAK! " : "HAVA: NORMAL ");
|
||||
|
||||
Serial.println("Sicaklik: " + String(t) + " C | Nem: %" + String(h));
|
||||
delay(1200);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "joystick-servo-control",
|
||||
title: "2 Eksenli Joystick ile Servo & Buton Kontrolü",
|
||||
badge: "Robotik & Giriş",
|
||||
category: "Giriş & Butonlar",
|
||||
description: "Analog joystick'in X ekseniyle SG90 servo motorun açısını 0-180° yönlendirme ve basma butonunu algılama.",
|
||||
libraryIds: ["servo"],
|
||||
components: [
|
||||
{ id: "nano1", kind: "arduino_nano", name: "Arduino Nano V3", x: 60, y: 130 },
|
||||
{ id: "joy1", kind: "joystick", name: "2 Eksenli Analog Joystick", x: 330, y: 110, joystickX: 512, joystickY: 512 },
|
||||
{ id: "srv1", kind: "servo", name: "SG90 Mikro Servo", x: 520, y: 120, servoAngle: 90 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "jw1", fromCompId: "nano1", fromPinId: "A0", toCompId: "joy1", toPinId: "VRX", color: "#3b82f6" },
|
||||
{ id: "jw2", fromCompId: "nano1", fromPinId: "A1", toCompId: "joy1", toPinId: "VRY", color: "#10b981" },
|
||||
{ id: "jw3", fromCompId: "nano1", fromPinId: "D2", toCompId: "joy1", toPinId: "SW", color: "#eab308" },
|
||||
{ id: "jw4", fromCompId: "nano1", fromPinId: "5V", toCompId: "joy1", toPinId: "5V", color: "#ef4444" },
|
||||
{ id: "jw5", fromCompId: "nano1", fromPinId: "GND_B", toCompId: "joy1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "sw_sig", fromCompId: "nano1", fromPinId: "D9", toCompId: "srv1", toPinId: "SIGNAL", color: "#f97316" },
|
||||
{ id: "sw_vcc", fromCompId: "nano1", fromPinId: "5V", toCompId: "srv1", toPinId: "VCC", color: "#ef4444" },
|
||||
{ id: "sw_gnd", fromCompId: "nano1", fromPinId: "GND_T", toCompId: "srv1", toPinId: "GND", color: "#1e293b" },
|
||||
],
|
||||
code: `// SnapCAD Arduino Nano - Joystick ile Servo Kontrolü
|
||||
#include <Servo.h>
|
||||
|
||||
Servo myServo;
|
||||
const int joyXPin = A0;
|
||||
const int buttonPin = 2;
|
||||
|
||||
void setup() {
|
||||
myServo.attach(9);
|
||||
pinMode(buttonPin, INPUT_PULLUP);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int xVal = analogRead(joyXPin);
|
||||
int angle = map(xVal, 0, 1023, 0, 180);
|
||||
myServo.write(angle);
|
||||
|
||||
int btnState = digitalRead(buttonPin);
|
||||
Serial.print("Joy X: ");
|
||||
Serial.print(xVal);
|
||||
Serial.print(" -> Servo: ");
|
||||
Serial.print(angle);
|
||||
Serial.println(btnState == LOW ? " | BUTON BASILI!" : "");
|
||||
delay(100);
|
||||
}`,
|
||||
},
|
||||
|
||||
{
|
||||
id: "esp32-iot-smart-device",
|
||||
title: "ESP32 Wi-Fi & OLED IoT Akıllı Cihaz",
|
||||
badge: "IoT & Kablosuz",
|
||||
category: "Geliştirme Kartları",
|
||||
description: "ESP32 mikrodenetleyici, I2C OLED ekran ve sıcaklık telemetrisi ile bulut IoT başlangıcı.",
|
||||
libraryIds: ["wifi", "ssd1306", "wire", "pubsubclient"],
|
||||
components: [
|
||||
{ id: "esp1", kind: "esp32", name: "ESP32 NodeMCU", x: 50, y: 110 },
|
||||
{ id: "oled1", kind: "oled128x64", name: "SSD1306 OLED Ekran", x: 380, y: 110, oledLines: ["ESP32 IoT Node", "Wi-Fi: Connected", "IP: 192.168.1.42", "Cloud: ONLINE"] },
|
||||
{ id: "osc1", kind: "oscilloscope", name: "Dijital Osiloskop", x: 550, y: 100 },
|
||||
],
|
||||
wires: [
|
||||
{ id: "ew1", fromCompId: "esp1", fromPinId: "D21", toCompId: "oled1", toPinId: "SDA", color: "#a855f7" },
|
||||
{ id: "ew2", fromCompId: "esp1", fromPinId: "D22", toCompId: "oled1", toPinId: "SCL", color: "#f97316" },
|
||||
{ id: "ew3", fromCompId: "esp1", fromPinId: "3V3", toCompId: "oled1", toPinId: "VCC", color: "#ef4444" },
|
||||
{ id: "ew4", fromCompId: "esp1", fromPinId: "GND_T", toCompId: "oled1", toPinId: "GND", color: "#1e293b" },
|
||||
{ id: "ow1", fromCompId: "esp1", fromPinId: "D2", toCompId: "osc1", toPinId: "CH1", color: "#34d399" },
|
||||
{ id: "ow2", fromCompId: "esp1", fromPinId: "GND_B", toCompId: "osc1", toPinId: "GND", color: "#1e293b" },
|
||||
],
|
||||
code: `// SnapCAD ESP32 Wi-Fi & OLED IoT Başlangıç
|
||||
#include <WiFi.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
|
||||
#define SCREEN_WIDTH 128
|
||||
#define SCREEN_HEIGHT 64
|
||||
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(SSD1306_WHITE);
|
||||
display.setCursor(0, 4);
|
||||
display.println("SnapCAD ESP32 IoT");
|
||||
display.println("Wi-Fi Baglaniyor...");
|
||||
display.display();
|
||||
Serial.println("ESP32 Hazir. Wi-Fi IP: 192.168.1.42");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Canlı telemetri yayını
|
||||
delay(1000);
|
||||
}`,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,141 @@
|
||||
export type CircuitComponentCategory =
|
||||
| "all"
|
||||
| "microcontroller"
|
||||
| "basic"
|
||||
| "inputs"
|
||||
| "outputs"
|
||||
| "power"
|
||||
| "ics";
|
||||
|
||||
export type CircuitComponentKind =
|
||||
| "arduino_uno"
|
||||
| "breadboard"
|
||||
| "breadboard_mini"
|
||||
| "battery_9v"
|
||||
| "coin_cell"
|
||||
| "led"
|
||||
| "rgb_led"
|
||||
| "resistor"
|
||||
| "capacitor"
|
||||
| "diode"
|
||||
| "transistor"
|
||||
| "relay"
|
||||
| "pushbutton"
|
||||
| "slide_switch"
|
||||
| "potentiometer"
|
||||
| "ultrasonic"
|
||||
| "pir_sensor"
|
||||
| "tmp36"
|
||||
| "ldr"
|
||||
| "gas_sensor"
|
||||
| "soil_moisture"
|
||||
| "keypad4x4"
|
||||
| "ir_receiver"
|
||||
| "seven_segment"
|
||||
| "buzzer"
|
||||
| "servo"
|
||||
| "dc_motor"
|
||||
| "lcd16x2"
|
||||
| "oled128x64"
|
||||
| "neopixel_ring"
|
||||
| "multimeter"
|
||||
| "arduino_nano"
|
||||
| "esp32"
|
||||
| "stepper_motor"
|
||||
| "dht11"
|
||||
| "joystick"
|
||||
| "oscilloscope";
|
||||
|
||||
export type CircuitPin = {
|
||||
id: string;
|
||||
label: string;
|
||||
relX: number;
|
||||
relY: number;
|
||||
direction?: "input" | "output" | "power" | "ground" | "bidirectional";
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export type CircuitComponent = {
|
||||
id: string;
|
||||
kind: CircuitComponentKind;
|
||||
name: string;
|
||||
x: number;
|
||||
y: number;
|
||||
rotation?: number; // 0, 90, 180, 270
|
||||
ledColor?: "red" | "green" | "yellow" | "blue" | "cyan" | "orange" | "white";
|
||||
rgbColor?: { r: number; g: number; b: number };
|
||||
resistanceOhms?: number;
|
||||
capacitanceUf?: number;
|
||||
digitalPin?: number;
|
||||
analogPin?: string;
|
||||
pressed?: boolean;
|
||||
switchOn?: boolean;
|
||||
potValue?: number; // 0..1023
|
||||
distanceCm?: number; // 2..400
|
||||
servoAngle?: number; // 0..180
|
||||
tempCelsius?: number; // -40..125
|
||||
lightLux?: number; // 0..1000
|
||||
gasPpm?: number; // 0..1000
|
||||
moisturePct?: number; // 0..100
|
||||
pirMotion?: boolean;
|
||||
relayState?: boolean;
|
||||
motorSpeed?: number; // 0..255 RPM
|
||||
stepperAngle?: number; // 0..360 derece
|
||||
stepperCoils?: [boolean, boolean, boolean, boolean]; // IN1, IN2, IN3, IN4
|
||||
dhtTemp?: number; // -40..80 C
|
||||
dhtHumidity?: number; // 0..100 %
|
||||
joystickX?: number; // 0..1023
|
||||
joystickY?: number; // 0..1023
|
||||
joystickPressed?: boolean;
|
||||
scopeScale?: number;
|
||||
scopeTimebase?: number;
|
||||
sevenSegmentValue?: string; // "0".."9", "A"-"F", etc.
|
||||
sevenSegmentSegments?: Record<"a" | "b" | "c" | "d" | "e" | "f" | "g" | "dp", boolean>;
|
||||
lcdLine1?: string;
|
||||
lcdLine2?: string;
|
||||
oledLines?: string[];
|
||||
neopixelColors?: string[];
|
||||
lastKeyPressed?: string;
|
||||
irLastCode?: string;
|
||||
batteryVoltage?: number;
|
||||
};
|
||||
|
||||
export type CircuitWire = {
|
||||
id: string;
|
||||
fromCompId: string;
|
||||
fromPinId: string;
|
||||
toCompId: string;
|
||||
toPinId: string;
|
||||
color: string;
|
||||
style?: "curved" | "orthogonal";
|
||||
};
|
||||
|
||||
export type CircuitTemplate = {
|
||||
id: string;
|
||||
title: string;
|
||||
badge: string;
|
||||
category: string;
|
||||
description: string;
|
||||
components: CircuitComponent[];
|
||||
wires: CircuitWire[];
|
||||
code: string;
|
||||
libraryIds?: string[];
|
||||
};
|
||||
|
||||
export type ArduinoLibrary = {
|
||||
id: string;
|
||||
name: string;
|
||||
header: string;
|
||||
version: string;
|
||||
author: string;
|
||||
description: string;
|
||||
category: "Display" | "Sensors" | "Actuators" | "LED" | "Communication" | "Signal" | "Robotics" | "IoT";
|
||||
exampleCode: string;
|
||||
};
|
||||
|
||||
export type SerialPlotterPoint = {
|
||||
time: number;
|
||||
values: Record<string, number>;
|
||||
};
|
||||
|
||||
export type CodeEditorMode = "text" | "blocks" | "blocks_and_text";
|
||||
@@ -1,8 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { ChevronDown, ChevronUp, LockKeyhole, LockKeyholeOpen, Split } from "lucide-react";
|
||||
import { ChevronDown, ChevronUp, LockKeyhole, LockKeyholeOpen, Split, Image as ImageIcon, ArrowUpToLine, MoveRight, MoveUp, Layers, Scissors } from "lucide-react";
|
||||
import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type Dispatch, type SetStateAction } from "react";
|
||||
import { ToolbarHideSelectedIcon } from "@/components/icons";
|
||||
import { calculateSmartPlacementPoint, calculateTopSurfaceElevation } from "@/lib/smartPlacement";
|
||||
import {
|
||||
DEFAULT_GEAR_HELIX_ANGLE,
|
||||
DEFAULT_GEAR_HELIX_QUALITY,
|
||||
@@ -25,6 +26,7 @@ import { displayStepFromMillimeters, displayToMillimeters, formatMeasurementNumb
|
||||
import { resizedShapeSize, shapeDepth, shapeHasTaper, shapeOverallFootprintDimensions, shapeTaperDimensions, shapeWidth } from "@/lib/workplaneShapes";
|
||||
import { normalizeSketchRevolveSettings } from "@/lib/sketchRevolve";
|
||||
import { MAX_HIGH_RESOLUTION_SIDES } from "@/lib/workplaneSettings";
|
||||
import { ARCHITECTURAL_TEXTURES, getTextureDefinition } from "@/lib/architecturalTextures";
|
||||
import type { GearType, GridSize, MeasurementAccuracy, WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
|
||||
|
||||
const GRID_SIZES: GridSize[] = ["Off", "0.1 mm", "0.25 mm", "0.5 mm", "1.0 mm", "2.0 mm", "5.0 mm", "Brick"];
|
||||
@@ -61,11 +63,42 @@ const SOLID_COLORS = [
|
||||
];
|
||||
const TEXT_FONT_OPTIONS = ["Multilanguage", "Sans", "Serif", "Script", "Monospace", "Rounded", "Stencil"];
|
||||
const GEAR_TYPE_OPTIONS: Array<{ value: GearType; label: string }> = [
|
||||
{ value: "spur", label: "Spur gear" },
|
||||
{ value: "helical", label: "Helical gear" },
|
||||
{ value: "bevel", label: "Bevel gear" },
|
||||
{ value: "spur", label: "Düz Dişli" },
|
||||
{ value: "helical", label: "Helisel Dişli" },
|
||||
{ value: "bevel", label: "Konik Dişli" },
|
||||
];
|
||||
|
||||
const PROPERTY_LABELS_TR: Record<string, string> = {
|
||||
"Length": "Uzunluk (Boy)",
|
||||
"Width": "Genişlik (En)",
|
||||
"Height": "Yükseklik",
|
||||
"Sides": "Kenar Sayısı",
|
||||
"Steps": "Adım Sayısı",
|
||||
"Top Radius": "Üst Yarıçap",
|
||||
"Base Radius": "Taban Yarıçapı",
|
||||
"Thickness": "Et Kalınlığı",
|
||||
"Teeth": "Diş Sayısı",
|
||||
"Tooth Size": "Diş Boyutu",
|
||||
"Tooth Width": "Diş Genişliği",
|
||||
"Center Hole": "Merkez Delik",
|
||||
"Helix Angle": "Helis Açısı",
|
||||
"Quality": "Kalite",
|
||||
"Text": "Metin",
|
||||
"Font": "Yazı Tipi",
|
||||
"Bevel": "Pah (Bevel)",
|
||||
"Segments": "Segment",
|
||||
"Start Angle": "Başlangıç Açısı",
|
||||
"Sweep": "Dönüş Açısı",
|
||||
"Top Length": "Üst Uzunluk",
|
||||
"Top Width": "Üst Genişlik",
|
||||
"Bottom Length": "Alt Uzunluk",
|
||||
"Bottom Width": "Alt Genişlik",
|
||||
};
|
||||
|
||||
function displayPropertyLabel(label: string) {
|
||||
return PROPERTY_LABELS_TR[label] ?? label;
|
||||
}
|
||||
|
||||
type RangePropertyConfig = {
|
||||
type?: "range";
|
||||
label: string;
|
||||
@@ -376,6 +409,8 @@ export function ShapeInspector({
|
||||
canSeparateParts = false,
|
||||
onSeparateParts,
|
||||
onInteractionActiveChange,
|
||||
allShapes,
|
||||
onSelectShape,
|
||||
}: {
|
||||
shape: WorkplaneShape;
|
||||
snap: GridSize;
|
||||
@@ -388,6 +423,8 @@ export function ShapeInspector({
|
||||
canSeparateParts?: boolean;
|
||||
onSeparateParts?: () => void;
|
||||
onInteractionActiveChange?: (active: boolean) => void;
|
||||
allShapes?: WorkplaneShape[];
|
||||
onSelectShape?: (id: string) => void;
|
||||
}) {
|
||||
const solidColor = shape.color;
|
||||
const locked = Boolean(shape.locked);
|
||||
@@ -488,6 +525,55 @@ export function ShapeInspector({
|
||||
|
||||
{!minimized ? (
|
||||
<>
|
||||
{shape.imagePlate ? (
|
||||
<div className="p-3 mx-2 my-2 rounded-xl bg-sky-50/90 dark:bg-sky-950/40 border border-sky-200 dark:border-sky-800 space-y-2.5 text-xs">
|
||||
<div className="flex items-center justify-between font-bold text-sky-800 dark:text-sky-300">
|
||||
<span className="flex items-center gap-1.5">
|
||||
<ImageIcon size={15} /> Mimari Kat Planı / Altlık
|
||||
</span>
|
||||
<span className="text-[10px] font-mono px-1.5 py-0.5 rounded bg-sky-100 dark:bg-sky-900 text-sky-700 dark:text-sky-300">
|
||||
{shape.imagePlate.pixelWidth}x{shape.imagePlate.pixelHeight} px
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
<img
|
||||
src={shape.imagePlate.dataUrl}
|
||||
alt="Kat Planı Önizleme"
|
||||
className="w-14 h-14 object-cover rounded-lg border border-sky-300 dark:border-sky-700 shadow-sm"
|
||||
/>
|
||||
<div className="flex-1 space-y-1">
|
||||
<div className="flex items-center justify-between text-[11px] text-slate-600 dark:text-slate-300">
|
||||
<span>Saydamlık (Opaklık):</span>
|
||||
<span className="font-bold font-mono">
|
||||
{Math.round((shape.imagePlate.opacity ?? 0.85) * 100)}%
|
||||
</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
min={10}
|
||||
max={100}
|
||||
step={5}
|
||||
value={Math.round((shape.imagePlate.opacity ?? 0.85) * 100)}
|
||||
onChange={(e) => {
|
||||
const opacity = Number(e.target.value) / 100;
|
||||
onUpdate({
|
||||
imagePlate: {
|
||||
...shape.imagePlate!,
|
||||
opacity,
|
||||
},
|
||||
});
|
||||
}}
|
||||
className="w-full accent-sky-600 h-1.5 bg-sky-200 dark:bg-sky-800 rounded-lg cursor-pointer"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="text-[11px] text-slate-500 dark:text-slate-400">
|
||||
Bu görseli altlık olarak kullanarak üzerine <strong>Çizgi (L)</strong> ve <strong>İt/Çek (P)</strong> ile duvarları modelleyebilirsiniz.
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="shape-state-card" role="group" aria-label="Shape mode">
|
||||
<button
|
||||
className={!shape.hole ? "active solid-choice" : "solid-choice"}
|
||||
@@ -501,7 +587,7 @@ export function ShapeInspector({
|
||||
aria-expanded={colorOpen}
|
||||
>
|
||||
<span className="large-solid-swatch" style={{ "--swatch": solidColor } as CSSProperties} />
|
||||
<span>Solid</span>
|
||||
<span>Katı</span>
|
||||
</button>
|
||||
<button
|
||||
className={shape.hole ? "active hole-choice" : "hole-choice"}
|
||||
@@ -513,14 +599,14 @@ export function ShapeInspector({
|
||||
aria-pressed={shape.hole}
|
||||
>
|
||||
<span className="large-hole-swatch" />
|
||||
<span>Hole</span>
|
||||
<span>Delik</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{colorOpen ? (
|
||||
<div className="color-card" aria-label="Shape color">
|
||||
<div className="color-card-header">
|
||||
<span>Color</span>
|
||||
<span>Renk</span>
|
||||
<span className="color-value">{solidColor.toUpperCase()}</span>
|
||||
</div>
|
||||
<div className="color-grid">
|
||||
@@ -539,7 +625,7 @@ export function ShapeInspector({
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
<label className={locked ? "custom-color disabled" : "custom-color"} title="Custom color">
|
||||
<label className={locked ? "custom-color disabled" : "custom-color"} title="Özel renk">
|
||||
<input
|
||||
key={`${shape.id}-${solidColor}`}
|
||||
ref={customColorInputRef}
|
||||
@@ -549,25 +635,200 @@ export function ShapeInspector({
|
||||
onFocus={() => onInteractionActiveChange?.(true)}
|
||||
onBlur={() => onInteractionActiveChange?.(false)}
|
||||
/>
|
||||
<span>Custom</span>
|
||||
<span>Özel</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* Mimari Malzeme & Doku Seçici */}
|
||||
<div className="pt-2.5 border-t border-slate-200 dark:border-slate-700/60 mt-2.5 space-y-1.5">
|
||||
<div className="flex items-center justify-between text-xs font-bold text-slate-700 dark:text-slate-300">
|
||||
<span>Mimari Malzeme & Doku</span>
|
||||
<span className="text-[11px] font-semibold text-sky-600 dark:text-sky-400">
|
||||
{getTextureDefinition(shape.texture).name}
|
||||
</span>
|
||||
</div>
|
||||
<div className="grid grid-cols-3 gap-1.5 pt-0.5">
|
||||
{ARCHITECTURAL_TEXTURES.map((tex) => (
|
||||
<button
|
||||
key={tex.id}
|
||||
type="button"
|
||||
disabled={locked}
|
||||
onClick={() => onUpdate({ texture: tex.id })}
|
||||
className={`p-1.5 rounded-lg text-[10px] font-medium text-left transition border flex flex-col gap-1 ${
|
||||
(shape.texture || "none") === tex.id
|
||||
? "border-sky-500 bg-sky-50 dark:bg-sky-950/50 text-sky-700 dark:text-sky-300 ring-1 ring-sky-500 font-bold"
|
||||
: "border-slate-200 dark:border-slate-700 hover:bg-slate-50 dark:hover:bg-slate-800 text-slate-700 dark:text-slate-300"
|
||||
}`}
|
||||
title={tex.description}
|
||||
aria-label={`Mimari Malzeme: ${tex.name}`}
|
||||
>
|
||||
<span className="w-full h-3 rounded" style={{ cssText: tex.previewCss } as any} />
|
||||
<span className="truncate">{tex.name}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{shape.sketchProfile && onEditSketch ? (
|
||||
<button className="edit-sketch-button" type="button" disabled={locked} onClick={onEditSketch}>
|
||||
Edit sketch
|
||||
2B Çizimi Düzenle
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
{canSeparateParts && onSeparateParts ? (
|
||||
<button className="inspector-action-button" type="button" disabled={locked} onClick={onSeparateParts}>
|
||||
<Split size={17} strokeWidth={2.5} />
|
||||
<span>Separate Parts</span>
|
||||
<span>Parçaları Ayır</span>
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
{!shape.hole && (shape.kind === "box" || Boolean(shape.groupedShapes?.length)) ? (
|
||||
<div style={{ margin: "0 10px 8px" }}>
|
||||
<button
|
||||
className="inspector-action-button"
|
||||
type="button"
|
||||
disabled={locked}
|
||||
style={{
|
||||
width: "100%",
|
||||
fontSize: "12px",
|
||||
padding: "8px 12px",
|
||||
justifyContent: "flex-start",
|
||||
background: "linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(239, 68, 68, 0.2))",
|
||||
borderColor: "rgba(245, 158, 11, 0.4)",
|
||||
color: "#fef08a",
|
||||
boxShadow: "0 2px 6px rgba(245, 158, 11, 0.15)",
|
||||
}}
|
||||
title="Duvarın ortasını kesip pencere veya kapı boşluğu açar"
|
||||
onClick={() => {
|
||||
window.dispatchEvent(new CustomEvent("snapcad:open-wall-cutout", { detail: { shapeId: shape.id } }));
|
||||
}}
|
||||
>
|
||||
<Scissors size={15} className="text-amber-400" />
|
||||
<span style={{ fontWeight: 700 }}>Duvara Pencere / Kapı Boşluğu Aç</span>
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{allShapes && allShapes.length > 1 ? (
|
||||
<div className="property-card" style={{ padding: "12px", background: "rgba(15, 23, 42, 0.4)", borderRadius: "8px", border: "1px solid rgba(56, 189, 248, 0.25)", margin: "0 10px 10px" }}>
|
||||
<div style={{ fontSize: "12px", fontWeight: 700, color: "#38bdf8", marginBottom: "8px", display: "flex", alignItems: "center", gap: "6px" }}>
|
||||
<MoveUp size={14} />
|
||||
<span>Akıllı Konumlandırma & Kurtarma</span>
|
||||
</div>
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: "6px" }}>
|
||||
<button
|
||||
className="inspector-action-button"
|
||||
type="button"
|
||||
disabled={locked}
|
||||
style={{ width: "100%", fontSize: "12px", padding: "7px 10px", justifyContent: "flex-start" }}
|
||||
title="Nesneyi alttaki binanın/çatının en üst yüzeyine taşır"
|
||||
onClick={() => {
|
||||
const topElev = calculateTopSurfaceElevation(shape, allShapes);
|
||||
onUpdate({ elevation: topElev });
|
||||
}}
|
||||
>
|
||||
<ArrowUpToLine size={14} className="text-amber-400" />
|
||||
<span>Çatıya / Üst Yüzeye Çıkar</span>
|
||||
</button>
|
||||
<button
|
||||
className="inspector-action-button"
|
||||
type="button"
|
||||
disabled={locked}
|
||||
style={{ width: "100%", fontSize: "12px", padding: "7px 10px", justifyContent: "flex-start" }}
|
||||
title="Nesneyi çakışan modelin dışına, yanındaki boş alana taşır"
|
||||
onClick={() => {
|
||||
const freePoint = calculateSmartPlacementPoint(allShapes, { width: shape.width, depth: shape.depth });
|
||||
onUpdate({ x: freePoint.x, z: freePoint.z, elevation: 0 });
|
||||
}}
|
||||
>
|
||||
<MoveRight size={14} className="text-emerald-400" />
|
||||
<span>Modele Çarpmadan Dışarı Al</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{allShapes && allShapes.length > 1 && onSelectShape ? (
|
||||
<div style={{ margin: "0 10px 10px", padding: "8px 10px", background: "rgba(30, 41, 59, 0.5)", borderRadius: "6px", border: "1px solid rgba(148, 163, 184, 0.15)", fontSize: "11px" }}>
|
||||
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: "4px", color: "#94a3b8" }}>
|
||||
<span style={{ display: "flex", alignItems: "center", gap: "4px" }}><Layers size={12} /> Sahne Nesneleri ({allShapes.length})</span>
|
||||
</div>
|
||||
<select
|
||||
value={shape.id}
|
||||
onChange={(e) => onSelectShape(e.target.value)}
|
||||
style={{ width: "100%", padding: "4px 8px", background: "#0f172a", color: "#f8fafc", border: "1px solid #334155", borderRadius: "4px", fontSize: "12px", cursor: "pointer" }}
|
||||
aria-label="Sahnedeki nesneyi seç"
|
||||
>
|
||||
{allShapes.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.name || s.kind} {s.id === shape.id ? "(Seçili)" : ""}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div style={{ margin: "0 10px 10px", padding: "8px 10px", background: "rgba(30, 41, 59, 0.5)", borderRadius: "6px", border: "1px solid rgba(148, 163, 184, 0.15)", fontSize: "11px" }}>
|
||||
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: "4px", color: "#a78bfa", fontWeight: 700 }}>
|
||||
<span style={{ display: "flex", alignItems: "center", gap: "4px" }}><Layers size={12} /> Mimari Katman (Etiket)</span>
|
||||
</div>
|
||||
<select
|
||||
value={shape.tag || "Katman 0 (Genel)"}
|
||||
onChange={(e) => onUpdate({ tag: e.target.value === "Katman 0 (Genel)" ? "" : e.target.value })}
|
||||
style={{ width: "100%", padding: "4px 8px", background: "#0f172a", color: "#f8fafc", border: "1px solid #334155", borderRadius: "4px", fontSize: "12px", cursor: "pointer" }}
|
||||
aria-label="Mimari katman seç"
|
||||
disabled={locked}
|
||||
>
|
||||
<option value="Katman 0 (Genel)">Katman 0 (Genel)</option>
|
||||
<option value="Duvarlar">Duvarlar</option>
|
||||
<option value="Çatı">Çatı</option>
|
||||
<option value="Zemin">Zemin</option>
|
||||
<option value="Pencereler">Pencereler</option>
|
||||
<option value="Kapı & Boşluklar">Kapı & Boşluklar</option>
|
||||
<option value="Mobilyalar">Mobilyalar</option>
|
||||
<option value="Merdiven">Merdiven</option>
|
||||
{shape.tag && !["Duvarlar", "Çatı", "Zemin", "Pencereler", "Kapı & Boşluklar", "Mobilyalar", "Merdiven", "Katman 0 (Genel)"].includes(shape.tag) && (
|
||||
<option value={shape.tag}>{shape.tag}</option>
|
||||
)}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div style={{ margin: "0 10px 10px", padding: "8px 10px", background: "rgba(30, 41, 59, 0.5)", borderRadius: "6px", border: "1px solid rgba(148, 163, 184, 0.15)", fontSize: "11px" }}>
|
||||
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: "6px", color: "#38bdf8", fontWeight: 700 }}>
|
||||
<span style={{ display: "flex", alignItems: "center", gap: "4px" }}>🧩 Akıllı Bileşen (Component)</span>
|
||||
</div>
|
||||
{shape.componentDefId ? (
|
||||
<div>
|
||||
<div style={{ color: "#38bdf8", fontSize: "11px", marginBottom: "6px", padding: "4px 8px", background: "rgba(56, 189, 248, 0.12)", borderRadius: "4px", border: "1px solid rgba(56, 189, 248, 0.25)" }}>
|
||||
✓ <strong>{shape.componentName || shape.name}</strong> ({allShapes ? allShapes.filter((s) => s.componentDefId === shape.componentDefId).length : 1} kopya bağlı)
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="inspector-action-button"
|
||||
disabled={locked}
|
||||
style={{ width: "100%", fontSize: "11px", padding: "5px 8px" }}
|
||||
title="Bu kopyayı bileşen grubundan ayırıp bağımsız yap"
|
||||
onClick={() => onUpdate({ componentDefId: "", componentName: "" })}
|
||||
>
|
||||
<span>Özgünleştir (Make Unique)</span>
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
className="inspector-action-button"
|
||||
disabled={locked}
|
||||
style={{ width: "100%", fontSize: "11px", padding: "5px 8px" }}
|
||||
title="Bu nesneyi bileşene dönüştür. Kopyaları aynı anda güncellenir."
|
||||
onClick={() => onUpdate({ componentDefId: `comp-${shape.id}`, componentName: shape.name || shape.kind })}
|
||||
>
|
||||
<span>Bileşen Yap (Make Component - G)</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className={`property-card ${propertiesOpen ? "" : "collapsed"}`}>
|
||||
<button
|
||||
className="property-card-header"
|
||||
@@ -576,7 +837,7 @@ export function ShapeInspector({
|
||||
aria-controls={`properties-${shape.id}`}
|
||||
onClick={() => setPropertiesOpen((open) => !open)}
|
||||
>
|
||||
<span>Properties</span>
|
||||
<span>Özellikler</span>
|
||||
<ChevronUp className={propertiesOpen ? "" : "collapsed"} size={25} strokeWidth={2.8} />
|
||||
</button>
|
||||
{propertiesOpen ? (
|
||||
@@ -601,7 +862,7 @@ export function ShapeInspector({
|
||||
aria-controls={`taper-${shape.id}`}
|
||||
onClick={() => setTaperOpen((open) => !open)}
|
||||
>
|
||||
<span>Taper</span>
|
||||
<span>Eğim (Taper)</span>
|
||||
<ChevronUp className={taperOpen ? "" : "collapsed"} size={25} strokeWidth={2.8} />
|
||||
</button>
|
||||
{taperOpen ? (
|
||||
@@ -620,7 +881,7 @@ export function ShapeInspector({
|
||||
aria-controls={`gear-teeth-${shape.id}`}
|
||||
onClick={() => setGearTeethOpen((open) => !open)}
|
||||
>
|
||||
<span>Teeth</span>
|
||||
<span>Diş Ayarları</span>
|
||||
<ChevronUp className={gearTeethOpen ? "" : "collapsed"} size={25} strokeWidth={2.8} />
|
||||
</button>
|
||||
{gearTeethOpen ? (
|
||||
@@ -639,7 +900,7 @@ export function ShapeInspector({
|
||||
aria-controls={`gear-helix-${shape.id}`}
|
||||
onClick={() => setGearHelixOpen((open) => !open)}
|
||||
>
|
||||
<span>Helix</span>
|
||||
<span>Helis Ayarları</span>
|
||||
<ChevronUp className={gearHelixOpen ? "" : "collapsed"} size={25} strokeWidth={2.8} />
|
||||
</button>
|
||||
{gearHelixOpen ? (
|
||||
@@ -693,7 +954,7 @@ export function SnapGridControl({
|
||||
}) {
|
||||
return (
|
||||
<div className="snap-row">
|
||||
<span>Snap Grid</span>
|
||||
<span>Izgara Yakalama (Snap)</span>
|
||||
<button className="snap-select" onClick={() => onSnapOpenChange((value) => !value)}>
|
||||
{snap}
|
||||
<ChevronDown size={12} fill="currentColor" />
|
||||
@@ -759,7 +1020,7 @@ function RangeProperty({
|
||||
return (
|
||||
<label className="range-property" style={{ "--slider-pos": `${position}%` } as CSSProperties}>
|
||||
<span className="range-property-header">
|
||||
<span className="range-property-name">{label}</span>
|
||||
<span className="range-property-name">{displayPropertyLabel(label)}</span>
|
||||
<span className="range-value-control">
|
||||
<input
|
||||
type="text"
|
||||
@@ -808,7 +1069,7 @@ function RangeProperty({
|
||||
function TextProperty({ label, value, disabled, onChange, onInteractionActiveChange }: TextPropertyConfig & { disabled?: boolean; onInteractionActiveChange?: (active: boolean) => void }) {
|
||||
return (
|
||||
<label className="text-property">
|
||||
<span>{label}</span>
|
||||
<span>{displayPropertyLabel(label)}</span>
|
||||
<input
|
||||
type="text"
|
||||
value={value}
|
||||
@@ -826,7 +1087,7 @@ function TextProperty({ label, value, disabled, onChange, onInteractionActiveCha
|
||||
function SelectProperty({ label, value, options, disabled, onChange }: SelectPropertyConfig & { disabled?: boolean }) {
|
||||
return (
|
||||
<label className="select-property">
|
||||
<span>{label}</span>
|
||||
<span>{displayPropertyLabel(label)}</span>
|
||||
<select value={value} disabled={disabled} onChange={(event) => onChange(event.currentTarget.value)}>
|
||||
{options.map((option) => (
|
||||
<option key={option} value={option}>
|
||||
@@ -845,7 +1106,7 @@ function GearTypePreview({ type }: { type: GearType }) {
|
||||
function GearTypeSelector({ value, disabled, onChange }: { value: GearType; disabled?: boolean; onChange: (value: GearType) => void }) {
|
||||
return (
|
||||
<div className="gear-type-property" role="group" aria-label="Gear type">
|
||||
<span>Gear Type</span>
|
||||
<span>Dişli Türü</span>
|
||||
<div className="gear-type-options">
|
||||
{GEAR_TYPE_OPTIONS.map((option) => (
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user