import { DeesElement, customElement, html, css, cssManager, property, type TemplateResult, } from '@design.estate/dees-element'; declare global { interface HTMLElementTagNameMap { 'sz-tokens-view': SzTokensView; } } export interface IToken { id: string; name: string; type: 'global' | 'ci'; service?: string; createdAt: string; lastUsed?: string; } @customElement('sz-tokens-view') export class SzTokensView extends DeesElement { public static demo = () => html`
`; public static demoGroups = ['Auth & Settings']; @property({ type: Array }) public accessor globalTokens: IToken[] = []; @property({ type: Array }) public accessor ciTokens: IToken[] = []; public static styles = [ cssManager.defaultStyles, css` :host { display: block; } dees-tile { display: block; margin-bottom: 24px; } .section-header { height: 36px; display: flex; align-items: center; padding: 0 16px; width: 100%; box-sizing: border-box; } .section-heading { flex: 1; display: flex; align-items: baseline; gap: 8px; min-width: 0; } .section-title { font-weight: 500; font-size: 13px; letter-spacing: -0.01em; color: var(--dees-color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .section-subtitle { font-size: 12px; color: var(--dees-color-text-muted); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .section-footer { display: flex; flex-direction: row; justify-content: flex-end; align-items: center; gap: 0; height: 36px; width: 100%; box-sizing: border-box; } .tile-button { padding: 0 16px; height: 100%; text-align: center; font-size: 12px; font-weight: 500; cursor: pointer; user-select: none; transition: all 0.15s ease; background: transparent; border: none; border-left: 1px solid var(--dees-color-border-subtle); color: var(--dees-color-text-muted); white-space: nowrap; display: flex; align-items: center; gap: 6px; } .tile-button:first-child { border-left: none; } .tile-button:hover { background: var(--dees-color-hover); color: var(--dees-color-text-primary); } .tile-button.primary { color: ${cssManager.bdTheme('hsl(217.2 91.2% 59.8%)', 'hsl(213.1 93.9% 67.8%)')}; font-weight: 600; } .tile-button.primary:hover { background: ${cssManager.bdTheme('hsl(217.2 91.2% 59.8% / 0.08)', 'hsl(213.1 93.9% 67.8% / 0.08)')}; color: ${cssManager.bdTheme('hsl(217.2 91.2% 50%)', 'hsl(213.1 93.9% 75%)')}; } .token-list { padding: 16px; } .token-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: ${cssManager.bdTheme('#f4f4f5', '#18181b')}; border-radius: 6px; margin-bottom: 8px; } .token-item:last-child { margin-bottom: 0; } .token-info { display: flex; flex-direction: column; gap: 4px; } .token-name { font-size: 14px; font-weight: 500; color: ${cssManager.bdTheme('#18181b', '#fafafa')}; } .token-meta { font-size: 12px; color: ${cssManager.bdTheme('#71717a', '#a1a1aa')}; } .token-service { display: inline-flex; align-items: center; padding: 2px 8px; background: ${cssManager.bdTheme('#dbeafe', 'rgba(59, 130, 246, 0.2)')}; color: ${cssManager.bdTheme('#2563eb', '#60a5fa')}; border-radius: 4px; font-size: 12px; font-weight: 500; margin-right: 8px; } .token-actions { display: flex; gap: 8px; } .action-button { padding: 6px 12px; background: transparent; border: 1px solid ${cssManager.bdTheme('#e4e4e7', '#27272a')}; border-radius: 4px; font-size: 12px; color: ${cssManager.bdTheme('#71717a', '#a1a1aa')}; cursor: pointer; transition: all 200ms ease; } .action-button:hover { background: ${cssManager.bdTheme('#ffffff', '#09090b')}; color: ${cssManager.bdTheme('#18181b', '#fafafa')}; } .action-button.delete { color: ${cssManager.bdTheme('#dc2626', '#ef4444')}; border-color: ${cssManager.bdTheme('#fee2e2', 'rgba(239, 68, 68, 0.3)')}; } .action-button.delete:hover { background: ${cssManager.bdTheme('#fee2e2', 'rgba(239, 68, 68, 0.2)')}; } .empty-state { padding: 32px 16px; text-align: center; } .empty-text { font-size: 14px; color: ${cssManager.bdTheme('#71717a', '#a1a1aa')}; } `, ]; public render(): TemplateResult { return html`
Global Tokens Tokens that can push images to multiple services
${this.globalTokens.length > 0 ? html`
${this.globalTokens.map(token => this.renderToken(token))}
` : html`
No global tokens created
`}
CI Tokens (Service-specific) Tokens tied to individual services for CI/CD pipelines
${this.ciTokens.length > 0 ? html`
${this.ciTokens.map(token => this.renderToken(token))}
` : html`
No CI tokens created
`}
`; } private renderToken(token: IToken): TemplateResult { return html`
${token.name}
${token.service ? html`${token.service}` : ''} Created ${token.createdAt} ${token.lastUsed ? html` ยท Last used ${token.lastUsed}` : ''}
`; } private handleCreate(type: 'global' | 'ci') { this.dispatchEvent(new CustomEvent('create', { detail: { type }, bubbles: true, composed: true })); } private handleCopy(token: IToken) { this.dispatchEvent(new CustomEvent('copy', { detail: token, bubbles: true, composed: true })); } private handleRegenerate(token: IToken) { this.dispatchEvent(new CustomEvent('regenerate', { detail: token, bubbles: true, composed: true })); } private handleDelete(token: IToken) { this.dispatchEvent(new CustomEvent('delete', { detail: token, bubbles: true, composed: true })); } }