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: 280px; min-height: 200px; } .header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; 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-title .icon { font-size: 16px; } .header-title .symbol { opacity: 0.8; font-weight: 400; font-size: 11px; } .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); } .mint-body { padding: 12px; } .desc { font-size: 11px; color: #64748b; margin-bottom: 10px; line-height: 1.4; } .supply-row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; } .supply-row .label { color: #64748b; } .supply-row .value { font-weight: 600; color: #1e293b; } .progress-bar { width: 100%; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; margin: 8px 0 12px; } .progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; } .edit-form { padding: 8px 12px; border-top: 1px solid #e2e8f0; display: flex; flex-direction: column; gap: 4px; } .edit-row { display: flex; gap: 4px; } .edit-form input { flex: 1; padding: 5px 8px; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 11px; outline: none; } .edit-form input:focus { border-color: #8b5cf6; } .edit-form input.short { width: 70px; flex: 0; } .edit-form input.color-input { width: 36px; flex: 0; padding: 2px; cursor: pointer; } `; declare global { interface HTMLElementTagNameMap { "folk-token-mint": FolkTokenMint; } } export class FolkTokenMint extends FolkShape { static override tagName = "folk-token-mint"; 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; } #tokenName = "New Token"; #tokenSymbol = "TKN"; #description = ""; #totalSupply = 1000; #issuedSupply = 0; #tokenColor = "#8b5cf6"; #tokenIcon = "\uD83E\uDE99"; #createdBy = ""; #createdAt = new Date().toISOString(); #headerEl: HTMLElement | null = null; #summaryEl: HTMLElement | null = null; #progressEl: HTMLElement | null = null; #descEl: HTMLElement | null = null; get tokenName() { return this.#tokenName; } set tokenName(v: string) { this.#tokenName = v; this.#render(); this.dispatchEvent(new CustomEvent("content-change")); } get tokenSymbol() { return this.#tokenSymbol; } set tokenSymbol(v: string) { this.#tokenSymbol = v; this.#render(); this.dispatchEvent(new CustomEvent("content-change")); } get description() { return this.#description; } set description(v: string) { this.#description = v; this.#render(); this.dispatchEvent(new CustomEvent("content-change")); } get totalSupply() { return this.#totalSupply; } set totalSupply(v: number) { this.#totalSupply = v; this.#render(); this.dispatchEvent(new CustomEvent("content-change")); } get issuedSupply() { return this.#issuedSupply; } set issuedSupply(v: number) { this.#issuedSupply = v; this.#render(); } get tokenColor() { return this.#tokenColor; } set tokenColor(v: string) { this.#tokenColor = v; this.#render(); this.dispatchEvent(new CustomEvent("content-change")); } get tokenIcon() { return this.#tokenIcon; } set tokenIcon(v: string) { this.#tokenIcon = v; this.#render(); this.dispatchEvent(new CustomEvent("content-change")); } get createdBy() { return this.#createdBy; } set createdBy(v: string) { this.#createdBy = v; } get createdAt() { return this.#createdAt; } set createdAt(v: string) { this.#createdAt = v; } get remaining() { return this.#totalSupply - this.#issuedSupply; } override createRenderRoot() { const root = super.createRenderRoot(); const wrapper = document.createElement("div"); wrapper.innerHTML = html`