/* ============================================================= * @whynot/design — chrome.js * ------------------------------------------------------------ * , / / * , , , * * ============================================================= */ import { LitElement, html, nothing } from "lit"; import { WnBase } from "./atoms.js"; /* ---------- ---------- */ export class WnTopNav extends WnBase { static properties = { logoSrc: { type: String, attribute: "logo-src" }, brand: { type: String }, slug: { type: String }, }; constructor() { super(); this.brand = "whynot"; this.slug = "control"; } render() { return html` `; } } /* ---------- ---------- */ export class WnSidebar extends WnBase { static properties = { activation: { type: String } }; render() { return html` `; } } export class WnSidebarGroup extends WnBase { static properties = { label: { type: String } }; render() { return html`
${this.label ? html`${this.label}` : nothing}
`; } } export class WnSidebarItem extends WnBase { static properties = { href: { type: String }, icon: { type: String }, active: { type: Boolean, reflect: true }, count: { type: String }, variant: { type: String, reflect: true }, }; render() { const cls = ["wn-sidebar__item", this.active ? "wn-sidebar__item--active" : "", this.variant === "doc" ? "wn-sidebar__item--doc" : "", ].filter(Boolean).join(" "); const inner = html` ${this.icon ? html`` : nothing} ${this.count ? html`${this.count}` : nothing} `; return this.href ? html`${inner}` : html`
${inner}
`; } } /* ---------- ---------- */ export class WnPageHeader extends WnBase { static properties = { eyebrow: { type: String }, title: { type: String }, lede: { type: String }, hasActions: { state: true }, }; constructor() { super(); this.hasActions = false; } _onSlot() { this.hasActions = !!this.querySelector('[slot="actions"]'); } render() { return html`
${this.eyebrow ? html`${this.eyebrow}` : nothing}

${this.title}

${this.lede ? html`

${this.lede}

` : nothing}
`; } } /* ---------- ---------- */ export class WnPipeline extends WnBase { static properties = { stages: { type: Array }, activeIdx: { type: Number, attribute: "active-idx" }, }; constructor() { super(); this.stages = [ { num: "Stage 0", name: "Raw idea", meta: "inbox/" }, { num: "Stage 1", name: "Triage", meta: "" }, { num: "Stage 2", name: "Prototype card", meta: "prototypes/" }, { num: "Stage 3", name: "Experiment", meta: "" }, { num: "Stage 4", name: "Signal review", meta: "" }, ]; this.activeIdx = 0; } render() { return html`
${this.stages.map((s, i) => { const state = i < this.activeIdx ? "done" : i === this.activeIdx ? "active" : "pending"; const cls = `wn-pipeline__stage wn-pipeline__stage--${state}`; return html`
${s.num} ${s.name} ${s.meta ? html`${s.meta}` : nothing} ${i > 0 ? html`` : nothing}
`; })}
`; } } /* ---------- ---------- */ export class WnPrototypeCard extends WnBase { static properties = { cardId: { type: String, attribute: "card-id", reflect: true }, signal: { type: String, reflect: true }, stageLabel: { type: String, attribute: "stage-label" }, href: { type: String }, }; constructor() { super(); this.signal = "S1"; } _onClick() { if (this.href) window.location.href = this.href; this.dispatchEvent(new CustomEvent("wn-open", { detail: { id: this.cardId }, bubbles: true, composed: true })); } render() { const clickable = !!this.href; const cls = "wn-card wn-prototype-card" + (clickable ? " wn-card--clickable" : ""); return html`
${this.cardId ? this.cardId + " · " : ""}Prototype ${this.stageLabel || this.signal}

Learning q. Smallest test
`; } } export function defineChrome() { if (!customElements.get("wn-top-nav")) customElements.define("wn-top-nav", WnTopNav); if (!customElements.get("wn-sidebar")) customElements.define("wn-sidebar", WnSidebar); if (!customElements.get("wn-sidebar-group")) customElements.define("wn-sidebar-group", WnSidebarGroup); if (!customElements.get("wn-sidebar-item")) customElements.define("wn-sidebar-item", WnSidebarItem); if (!customElements.get("wn-page-header")) customElements.define("wn-page-header", WnPageHeader); if (!customElements.get("wn-pipeline")) customElements.define("wn-pipeline", WnPipeline); if (!customElements.get("wn-prototype-card")) customElements.define("wn-prototype-card", WnPrototypeCard); }