DEV Community· Digital Ghost·· 8 天前AI 評分41
為何我打造 Code Ghost,讓元件原型製作即時完成
From Prompt to Production: Why I Built Code Ghost for Instant Component Prototyping
AI 導讀
開發者打造 Code Ghost,讓用戶透過提示詞生成 UI 元件原型,並即時檢視和修改程式碼。這款流動優先的 PWA 提供設計滑桿、不同預覽背景及本機儲存,亦可匯出獨立 .html 檔案或完整 .zip。AI 整合透過伺服器端 OpenRouter API 路由,預設使用 Claude,並在必要時自動切換至免費備用模型。
正文
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Introducing Code Ghost: Instant UI Prototyping</title>
<meta name="description" content="Code Ghost is a mobile-first HTML, CSS, Tailwind CSS, and JavaScript component workbench engineered for rapid UI prototyping, visual token tuning, and zero-friction static export." />
<meta name="keywords" content="Code Ghost, UI prototyping, frontend workbench, Tailwind CSS, HTML component builder, AI code generator, live preview, web development, Digital Ghost" />
<meta name="author" content="Digital Ghost" />
<meta name="robots" content="index, follow" />
<link rel="canonical" href="https://www.codeghost.site" />
<!-- Open Graph / Social SEO -->
<meta property="og:type" content="article" />
<meta property="og:site_name" content="Code Ghost" />
<meta property="og:title" content="Introducing Code Ghost: Instant UI Prototyping" />
<meta property="og:description" content="Build, test, and export responsive web components anywhere with live design token sliders, AI prompt workflows, and offline PWA support." />
<meta property="og:url" content="https://www.codeghost.site" />
<meta property="og:image" content="https://i.ibb.co/G3W2TsF7/1794591058599.jpg" />
<!-- Twitter Card SEO -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Introducing Code Ghost: Instant UI Prototyping" />
<meta name="twitter:description" content="A mobile-first HTML, CSS, Tailwind CSS, and JavaScript component workbench for rapid UI prototyping and static export." />
<meta name="twitter:image" content="https://i.ibb.co/G3W2TsF7/1794591058599.jpg" />
<style>
/* Clean, Dev.to-inspired editorial typography & layout */
:root {
--bg-page: #f8fafc;
--bg-card: #ffffff;
--text-primary: #0f172a;
--text-body: #334155;
--text-muted: #64748b;
--accent: #2563eb;
--border-light: #e2e8f0;
--bg-tag: #f1f5f9;
}
@media (prefers-color-scheme: dark) {
:root {
--bg-page: #0b0f19;
--bg-card: #111827;
--text-primary: #f8fafc;
--text-body: #cbd5e1;
--text-muted: #94a3b8;
--accent: #60a5fa;
--border-light: #1e293b;
--bg-tag: #1e293b;
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 1.5rem 1rem;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background-color: var(--bg-page);
color: var(--text-body);
line-height: 1.7;
font-size: 16px;
}
.article-container {
max-width: 720px;
margin: 0 auto;
background-color: var(--bg-card);
border: 1px solid var(--border-light);
border-radius: 14px;
padding: 2rem 1.75rem;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}
.header-logo {
text-align: center;
margin-bottom: 1.25rem;
}
.header-logo img {
width: 105px;
height: auto;
border-radius: 12px;
}
h1 {
font-size: 1.85rem;
line-height: 1.25;
color: var(--text-primary);
margin: 0 0 1.25rem 0;
font-weight: 800;
letter-spacing: -0.02em;
}
.tags {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-bottom: 1.75rem;
}
.tag {
font-size: 0.85rem;
color: var(--text-muted);
background-color: var(--bg-tag);
padding: 0.2rem 0.65rem;
border-radius: 6px;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
h2 {
font-size: 1.35rem;
color: var(--text-primary);
margin: 2rem 0 0.75rem 0;
padding-bottom: 0.35rem;
border-bottom: 1px solid var(--border-light);
font-weight: 700;
}
p {
margin: 0 0 1.15rem 0;
}
ul {
margin: 0 0 1.25rem 0;
padding-left: 1.35rem;
}
li {
margin-bottom: 0.6rem;
}
li strong {
color: var(--text-primary);
}
code {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
font-size: 0.88em;
background-color: var(--bg-tag);
padding: 0.15rem 0.4rem;
border-radius: 4px;
color: var(--text-primary);
}
a {
color: var(--accent);
text-decoration: none;
font-weight: 500;
}
a:hover {
text-decoration: underline;
}
hr {
border: 0;
border-top: 1px solid var(--border-light);
margin: 2rem 0 1.5rem 0;
}
.author-footer {
text-align: center;
padding-top: 0.5rem;
}
.author-footer img {
width: 60px;
height: 60px;
object-fit: cover;
border-radius: 50%;
margin-bottom: 0.5rem;
border: 2px solid var(--border-light);
}
.author-footer .author-name {
display: block;
font-size: 1.05rem;
font-weight: 700;
color: var(--text-primary);
margin-bottom: 0.2rem;
}
.author-footer .author-meta {
display: block;
font-size: 0.88rem;
color: var(--text-muted);
line-height: 1.6;
}
</style>
</head>
<body>
<article class="article-container">
<!-- Header Logo -->
<div class="header-logo">
<img src="https://i.ibb.co/G3W2TsF7/1794591058599.jpg" alt="Code Ghost Logo" />
</div>
<!-- Main Title -->
<h1>Introducing Code Ghost: Instant UI Prototyping</h1>
<!-- Dev.to Topic Tags -->
<div class="tags">
<span class="tag">#webdev</span>
<span class="tag">#frontend</span>
<span class="tag">#tailwindcss</span>
<span class="tag">#javascript</span>
</div>
<!-- Article Body -->
<h2>Introduction</h2>
<p>
As developers, we often run into a frustrating bottleneck when testing quick UI ideas. Traditional online sandboxes require heavy setups or lack AI iteration, while cloud-based AI builders lock your code behind proprietary walls and complex framework boilerplate.
</p>
<p>
I wanted something different: a lightning-fast, mobile-friendly workbench where I could prompt a component, inspect the raw markup, tweak spacing and colors live with visual sliders, and export clean code instantly without signing up for an account. That is why I built <strong>Code Ghost</strong>.
</p>
<h2>What Makes It Different</h2>
<p>
Code Ghost is built to give you total control over your code while accelerating your workflow:
</p>
<ul>
<li><strong>Mobile-First Progressive Web App:</strong> Fully responsive and touch-optimized, allowing you to build and preview components smoothly on desktops, tablets, and phones.</li>
<li><strong>AI Plus Full Code Control:</strong> Generate starting components via natural language prompts, then seamlessly switch between modifying current code or replacing the canvas while maintaining full access to raw HTML, CSS, Tailwind, and JavaScript tabs.</li>
<li><strong>Live Design Token Sliders:</strong> Automatically parses <code>:root</code> CSS variables, spacing, and Tailwind classes into instant visual sliders so you can adjust colors and padding in real time.</li>
<li><strong>Local-First & Zero Lock-In:</strong> Save projects locally via <code>localStorage</code> and download your work instantly as a standalone <code>.html</code> file or a complete <code>.zip</code> bundle.</li>
<li><strong>Glassmorphism & Theme Testing:</strong> One-click Dark, Light, and Checkerboard preview backdrops with live drag-resize dimensions.</li>
</ul>
<h2>Core Architecture</h2>
<p>
Under the hood, Code Ghost is powered by:
</p>
<ul>
<li><strong>Frontend:</strong> React 19, TypeScript, Vite, Tailwind CSS v4, and Lucide Icons.</li>
<li><strong>PWA & Offline:</strong> <code>vite-plugin-pwa</code> with Workbox service worker caching.</li>
<li><strong>AI Integration:</strong> Server-side OpenRouter API routing defaulting to Claude with automatic failover to free fallback models.</li>
</ul>
<h2>Check It Out & Connect</h2>
<p>
You can explore the live application and start prototyping your next component right now:
</p>
<ul>
<li><strong>Live App:</strong> <a href="https://www.codeghost.site" target="_blank" rel="noopener noreferrer">www.codeghost.site</a></li>
<li><strong>For Suggestions and Collaboration:</strong> Contact me at <a href="mailto:xx404GGx@proton.me">xx404GGx@proton.me</a></li>
</ul>
<hr />
<!-- Developer Credit Footer -->
<footer class="author-footer">
<img src="https://i.ibb.co/CpX7jHSS/1794451750503.jpg" alt="Digital Ghost Logo" />
<span class="author-name">Digital Ghost</span>
<span class="author-meta">
Website: <a href="https://www.digitalghost.blog" target="_blank" rel="noopener noreferrer">www.digitalghost.blog</a>
</span>
</footer>
</article>
</body>
</html>
來源:DEV Community · dev.to