/** * ds-component-list.js * Component listing and management interface * Shows all components with links to Storybook and adoption stats */ import URLBuilder from '../../utils/url-builder.js'; export default class ComponentList extends HTMLElement { constructor() { super(); this.components = [ { id: 'button', name: 'Button', category: 'Inputs', adoption: 95, variants: 12 }, { id: 'input', name: 'Input Field', category: 'Inputs', adoption: 88, variants: 8 }, { id: 'card', name: 'Card', category: 'Containers', adoption: 92, variants: 5 }, { id: 'modal', name: 'Modal', category: 'Containers', adoption: 78, variants: 3 }, { id: 'badge', name: 'Badge', category: 'Status', adoption: 85, variants: 6 }, { id: 'tooltip', name: 'Tooltip', category: 'Helpers', adoption: 72, variants: 4 }, { id: 'dropdown', name: 'Dropdown', category: 'Inputs', adoption: 81, variants: 4 }, { id: 'pagination', name: 'Pagination', category: 'Navigation', adoption: 65, variants: 2 }, ]; this.selectedCategory = 'All'; } connectedCallback() { this.render(); this.setupEventListeners(); } render() { this.innerHTML = `

Design System Components

Browse, preview, and track component adoption

${['Inputs', 'Containers', 'Status', 'Helpers', 'Navigation'].map(cat => ` `).join('')}
${this.renderComponents()}
`; } renderComponents() { const filtered = this.selectedCategory === 'All' ? this.components : this.components.filter(c => c.category === this.selectedCategory); return filtered.map(component => `
${component.name}
${component.category}
${component.adoption}%
Variants: ${component.variants} Adoption: ${component.adoption}%
`).join(''); } setupEventListeners() { // Filter buttons this.querySelectorAll('.filter-btn').forEach(btn => { btn.addEventListener('click', () => { this.selectedCategory = btn.dataset.category; this.render(); this.setupEventListeners(); }); }); // Storybook buttons this.querySelectorAll('.storybook-btn').forEach(btn => { btn.addEventListener('click', () => { const componentId = btn.dataset.componentId; const component = this.components.find(c => c.id === componentId); if (component) { const url = URLBuilder.getComponentUrl(component); window.open(url, '_blank'); } }); }); // Edit buttons this.querySelectorAll('.edit-btn').forEach(btn => { btn.addEventListener('click', () => { const componentId = btn.dataset.componentId; this.dispatchEvent(new CustomEvent('edit-component', { detail: { componentId }, bubbles: true, composed: true })); }); }); } } customElements.define('ds-component-list', ComponentList);