import { FolkShape } from "./folk-shape"; import { css, html } from "./tags"; const styles = css` :host { background: white; border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); min-width: 380px; min-height: 460px; } .header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: linear-gradient(135deg, #059669, #34d399); color: white; border-radius: 8px 8px 0 0; font-size: 12px; font-weight: 600; cursor: move; } .header-title { display: flex; align-items: center; gap: 6px; } .header-actions { display: flex; gap: 4px; } .header-actions button { background: transparent; border: none; color: white; cursor: pointer; padding: 2px 6px; border-radius: 4px; font-size: 14px; } .header-actions button:hover { background: rgba(255, 255, 255, 0.2); } .content { display: flex; flex-direction: column; height: calc(100% - 36px); overflow: hidden; } .prompt-area { padding: 12px; border-bottom: 1px solid #e2e8f0; } .prompt-input { width: 100%; padding: 10px 12px; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 13px; resize: none; outline: none; font-family: inherit; } .prompt-input:focus { border-color: #059669; } .component-input { width: 100%; padding: 8px 10px; border: 2px solid #e2e8f0; border-radius: 6px; font-size: 12px; outline: none; margin-top: 8px; font-family: inherit; } .component-input:focus { border-color: #059669; } .controls { display: flex; gap: 8px; margin-top: 8px; } .generate-btn { flex: 1; padding: 8px 16px; background: linear-gradient(135deg, #059669, #34d399); color: white; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity 0.2s; } .generate-btn:hover { opacity: 0.9; } .generate-btn:disabled { opacity: 0.5; cursor: not-allowed; } .tabs { display: flex; border-bottom: 1px solid #e2e8f0; } .tab { flex: 1; padding: 8px; text-align: center; font-size: 12px; font-weight: 600; color: #64748b; border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s; } .tab:hover { color: #059669; } .tab.active { color: #059669; border-bottom-color: #059669; } .preview-area { flex: 1; overflow: auto; padding: 12px; } .preview-area img { max-width: 100%; border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); } .drc-results { font-size: 12px; color: #334155; } .drc-results .pass { color: #059669; font-weight: 600; } .drc-results .fail { color: #ef4444; font-weight: 600; } .export-row { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid #e2e8f0; flex-wrap: wrap; } .export-btn { padding: 6px 12px; background: #334155; color: white; border: none; border-radius: 6px; font-size: 12px; cursor: pointer; text-decoration: none; } .export-btn:hover { background: #475569; } .export-btn.primary { background: #059669; } .export-btn.primary:hover { background: #047857; } .placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #94a3b8; text-align: center; gap: 8px; } .placeholder-icon { font-size: 48px; opacity: 0.5; } .loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 12px; } .spinner { width: 32px; height: 32px; border: 3px solid #e2e8f0; border-top-color: #059669; border-radius: 50%; animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } } .error { color: #ef4444; padding: 12px; background: #fef2f2; border-radius: 6px; font-size: 13px; } `; declare global { interface HTMLElementTagNameMap { "folk-kicad": FolkKiCAD; } } export class FolkKiCAD extends FolkShape { static override tagName = "folk-kicad"; static { const sheet = new CSSStyleSheet(); const parentRules = Array.from(FolkShape.styles.cssRules) .map((r) => r.cssText) .join("\n"); const childRules = Array.from(styles.cssRules) .map((r) => r.cssText) .join("\n"); sheet.replaceSync(`${parentRules}\n${childRules}`); this.styles = sheet; } #isLoading = false; #error: string | null = null; #schematicSvg: string | null = null; #boardSvg: string | null = null; #gerberUrl: string | null = null; #bomUrl: string | null = null; #pdfUrl: string | null = null; #drcResults: any = null; #activeTab: "schematic" | "board" | "drc" = "schematic"; #promptInput: HTMLTextAreaElement | null = null; #componentInput: HTMLInputElement | null = null; #generateBtn: HTMLButtonElement | null = null; #previewArea: HTMLElement | null = null; #exportRow: HTMLElement | null = null; override createRenderRoot() { const root = super.createRenderRoot(); const wrapper = document.createElement("div"); wrapper.innerHTML = html`
\u2022 ${this.#escapeHtml(v.message || v)}
`).join("")}