import React, { useState } from 'react'; import { motion, AnimatePresence } from 'motion/react'; import { Download, Sliders, Palette, Lightbulb, Type, Layers, CheckCircle2, Star, Sparkles, AlertCircle } from 'lucide-react'; import { KeycapCustomization, KeycapModel } from '../types'; import DragonMascot from './DragonMascot'; export default function KeycapGallery() { const [custom, setCustom] = useState({ baseColor: '#0E7490', // Cyan 700 stemColor: '#10B981', // Emerald 500 dragonColor: '#3B82F6', // Blue 500 material: 'resin_clear', ledColor: '#06B6D4', // Cyan 500 ledIntensity: 75, selectedLetter: 'đ', showStem: true }); const [downloadingId, setDownloadingId] = useState(null); const [downloadProgress, setDownloadProgress] = useState(0); const [showSuccessToast, setShowSuccessToast] = useState(false); const [toastMessage, setToastMessage] = useState(''); const lettersList = ['ă', 'â', 'đ', 'ê', 'ô', 'ơ', 'ư', 's (́)', 'f (̀)', 'r (̉)', 'x (̃)', 'j (̣)']; const colorPresets = [ { name: 'Rồng Biển Trầm', value: '#0E7490', text: 'text-cyan-400' }, { name: 'Ngọc Lục Bảo', value: '#047857', text: 'text-emerald-400' }, { name: 'Hồng Anh Đào', value: '#BE185D', text: 'text-pink-400' }, { name: 'Hổ Phách Sáng', value: '#B45309', text: 'text-amber-400' }, { name: 'Thạch Anh Tím', value: '#6D28D9', text: 'text-violet-400' }, { name: 'Khói Obsidian', value: '#374151', text: 'text-slate-400' } ]; const ledPresets = [ { name: 'Cyan Neon', value: '#06B6D4' }, { name: 'Toxic Green', value: '#10B981' }, { name: 'Sunset Orange', value: '#F97316' }, { name: 'Sakura Pink', value: '#EC4899' }, { name: 'Chroma RGB', value: '#8B5CF6' } ]; const keycapModels: KeycapModel[] = [ { id: 'dragon_keycap_oem', name: 'Rồng Con OEM Esc Keycap', letter: 'ESC', desc: 'Mẫu phím cơ Esc chứa rồng con dễ thương ở trung tâm, đúc khuôn resin thủ công siêu chi tiết.', rarity: 'Legendary', stlUrl: 'vietc_dragon_esc_oem.stl' }, { id: 'vietnamese_diacritic_caps', name: 'Bộ Ký Tự Nguyên Âm Tiếng Việt', letter: 'ă/â/đ/ê/ô/ơ/ư', desc: 'Trọn bộ keycap các chữ cái đặc trưng và bộ thanh dấu trong tiếng Việt dành cho hàng phím Alpha.', rarity: 'Epic', stlUrl: 'vietc_vietnamese_alphas.zip' }, { id: 'numlock_dragon_plate', name: 'Tấm Ốp Phím Numlock 3D', letter: 'NUM', desc: 'Bản thiết kế ốp bàn phím số cơ phong cách Rồng Con đan xen các vảy rồng bảo vệ cực chất.', rarity: 'Rare', stlUrl: 'vietc_numlock_plate.stl' }, { id: 'dragon_spacebar_625u', name: 'Thanh Spacebar Thủy Cung Rồng Con 6.25u', letter: 'SPACE', desc: 'Thanh phím dài uốn lượn phong cách rồng con bay lượn dưới đáy đại dương resin trong suốt.', rarity: 'Legendary', stlUrl: 'vietc_spacebar_dragon.stl' } ]; const startDownload = (model: KeycapModel) => { if (downloadingId) return; setDownloadingId(model.id); setDownloadProgress(0); const interval = setInterval(() => { setDownloadProgress(p => { if (p >= 100) { clearInterval(interval); setTimeout(() => { setDownloadingId(null); setToastMessage(`Đã tải về thành công tệp thiết kế 3D: ${model.stlUrl}! Sẵn sàng để in 3D FDM/SLA.`); setShowSuccessToast(true); setTimeout(() => setShowSuccessToast(false), 4500); }, 400); return 100; } return p + 5 + Math.floor(Math.random() * 8); }); }, 120); }; // Compute CSS styles based on material const getMaterialStyles = () => { switch (custom.material) { case 'resin_frosted': return { backdropFilter: 'blur(8px)', background: `rgba(${hexToRgb(custom.baseColor)}, 0.45)`, border: '1px solid rgba(255, 255, 255, 0.25)', boxShadow: `inset 0 0 15px rgba(255, 255, 255, 0.3), 0 0 25px ${custom.ledColor}${Math.floor(custom.ledIntensity / 100 * 255).toString(16)}` }; case 'glass': return { backdropFilter: 'blur(3px)', background: `rgba(${hexToRgb(custom.baseColor)}, 0.25)`, border: '1px solid rgba(255, 255, 255, 0.4)', boxShadow: `inset 0 0 20px rgba(255, 255, 255, 0.4), 0 0 35px ${custom.ledColor}${Math.floor(custom.ledIntensity / 100 * 255).toString(16)}` }; case 'matte': return { background: custom.baseColor, border: '1px solid rgba(0, 0, 0, 0.3)', boxShadow: 'inset 0 4px 6px rgba(255, 255, 255, 0.1), inset 0 -4px 6px rgba(0, 0, 0, 0.2)' }; default: // resin_clear return { backdropFilter: 'blur(1px)', background: `rgba(${hexToRgb(custom.baseColor)}, 0.65)`, border: '1px solid rgba(255, 255, 255, 0.35)', boxShadow: `inset 0 0 10px rgba(255, 255, 255, 0.4), 0 0 25px ${custom.ledColor}${Math.floor(custom.ledIntensity / 100 * 255).toString(16)}` }; } }; // Helper to convert hex to rgb function hexToRgb(hex: string): string { const bigint = parseInt(hex.replace('#', ''), 16); const r = (bigint >> 16) & 255; const g = (bigint >> 8) & 255; const b = bigint & 255; return `${r}, ${g}, ${b}`; } return (
{/* Section Header */}
ARTISAN 3D KEYCAPS

Trang Trí Phím Cơ VietC Resin 3D

Như công bố chính thức, VietC không chỉ là phần mềm gõ phím, chúng tôi chia sẻ bản vẽ thiết kế 3D hoàn toàn miễn phí của Mascot Rồng Con Resin trong suốt và bộ ký tự dấu mũ tiếng Việt để bạn tự in 3D cá nhân hóa bàn phím cơ của mình!

{/* WORKSPACE: Customizer on the left, interactive keycap on the right */}
{/* Controls Panel (6 cols) */}

Bảng Điều Khiển Tùy Biến 3D

{/* Vải Màu Resin */}
{colorPresets.map((preset) => ( ))}
{/* Chất liệu Resin */}
{[ { id: 'resin_clear', name: 'Trong Suốt' }, { id: 'resin_frosted', name: 'Nhám Mờ' }, { id: 'glass', name: 'Thạch Anh' }, { id: 'matte', name: 'Nhựa Đục' } ].map((mat) => ( ))}
{/* Ký Tự Tiếng Việt */}
{lettersList.map((letItem) => ( ))}
{/* Đèn LED gầm (Underglow) */}
{custom.ledIntensity}% Độ sáng
{ledPresets.map((preset) => (
setCustom(prev => ({ ...prev, ledIntensity: parseInt(e.target.value) }))} className="w-full h-1 bg-[#0d0e12] rounded-lg appearance-none cursor-pointer accent-emerald-500" />
{/* Interactive 3D Render Viewer (6 cols) */}
{/* Grid background effect */}
{/* Floating glowing indicator */}
3D RENDER PREVIEW
{/* Rotating 3D Keycap Stage Container */}
{/* LED Underglow radial halo */}
{/* The Keycap Body Wrapper (3D effect) */} {/* 1. KEYCAP BASE / STEM (Inner structure visible through clear resin) */} {custom.material !== 'matte' && (
{/* The mechanical switch cross stem (+) inside */}
)} {/* 2. CUTE MASCOT DRAGON RESTING INSIDE */}
{/* 3. TRANSPARENT RESIN OUTER SHELL (Styled with standard custom glassmorphism) */}
{/* Vietnamese Letter Engraving on top facet */}
{custom.selectedLetter.split(' ')[0]}
{/* Aesthetic detail: micro-bubbles or text inside */}
VIETC 3D OEM-R1
{/* Bottom Base rim */}
{/* Customizer Instructions */}
Góc xoay 3D giả lập trực quan 360°
{/* 3D PRINTING FILES DOWNLOAD SECTION */}

Tải Về File Thiết Kế 3D Miễn Phí (STL/OBJ)

{keycapModels.map((model) => (
{/* Rarity and Rating info */}
{model.rarity} Design

{model.name}

{model.desc}

Định dạng: STL / STEP FREE
{downloadingId === model.id ? (
Đang tải... {downloadProgress}%
) : ( )}
))}
{/* Global Action Toast Notification */} {showSuccessToast && (

Bắt đầu tải file 3D

{toastMessage}

)}
); }