# @design.estate/dees-wcctools ๐Ÿ› ๏ธ **Web Component Development Tools** โ€” A powerful framework for building, testing, documenting, and recording web components ## Overview `@design.estate/dees-wcctools` provides a comprehensive development environment for web components, featuring: - ๐ŸŽจ **Interactive Component Catalogue** โ€” Live preview with customizable sidebar sections - ๐Ÿ”ง **Real-time Property Editing** โ€” Modify component props on the fly with auto-detected editors - ๐ŸŒ“ **Theme Switching** โ€” Test light/dark modes instantly - ๐Ÿ“ฑ **Responsive Viewport Testing** โ€” Phone, phablet, tablet, and desktop views - ๐ŸŽฌ **Screen Recording** โ€” Record component demos with audio support and video trimming - ๐Ÿงช **Advanced Demo Tools** โ€” Post-render hooks for interactive testing - ๐Ÿ“‚ **Section-based Organization** โ€” Group components into custom sections with filtering and sorting - ๐Ÿš€ **Zero-config Setup** โ€” TypeScript and Lit support out of the box ## Issue Reporting and Security For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly. ## Installation ```bash # Using pnpm (recommended) pnpm add -D @design.estate/dees-wcctools # Using npm npm install @design.estate/dees-wcctools --save-dev ``` ## Quick Start ### 1. Create Your Component ```typescript import { DeesElement, customElement, html, css, property } from '@design.estate/dees-element'; @customElement('my-button') export class MyButton extends DeesElement { // Define a demo for the catalogue public static demo = () => html` `; @property({ type: String }) accessor label: string = 'Button'; @property({ type: String }) accessor variant: 'primary' | 'secondary' = 'primary'; public static styles = [ css` :host { display: inline-block; } button { padding: 8px 16px; border-radius: 4px; border: none; cursor: pointer; } button.primary { background: #3b82f6; color: white; } button.secondary { background: #6b7280; color: white; } ` ]; public render() { return html` `; } } ``` ### 2. Set Up Your Catalogue ```typescript // catalogue.ts import { setupWccTools } from '@design.estate/dees-wcctools'; import { html } from 'lit'; // Import your components import * as elements from './components/index.js'; import * as views from './views/index.js'; import * as pages from './pages/index.js'; // Initialize with sections-based configuration setupWccTools({ sections: [ { name: 'Pages', type: 'pages', items: pages, }, { name: 'Views', type: 'elements', items: views, icon: 'web', }, { name: 'Elements', type: 'elements', items: elements, sort: ([a], [b]) => a.localeCompare(b), }, ], }); ``` ### 3. Create an HTML Entry Point ```html Component Catalogue ``` ## ๐Ÿ“‚ Sections Configuration The sections-based API gives you full control over how components are organized in the sidebar. ### Section Properties | Property | Type | Description | |----------|------|-------------| | `name` | `string` | Display name for the section header | | `type` | `'elements' \| 'pages'` | How items render (`elements` show demos, `pages` render directly) | | `items` | `Record` | Object containing element classes or page factories | | `filter` | `(name, item) => boolean` | Optional filter function to include/exclude items | | `sort` | `([a, itemA], [b, itemB]) => number` | Optional sort function for ordering items | | `icon` | `string` | Optional Material Symbols icon name | | `collapsed` | `boolean` | Start section collapsed (default: `false`) | ### Advanced Example ```typescript import { setupWccTools } from '@design.estate/dees-wcctools'; import * as allElements from './elements/index.js'; import * as pages from './pages/index.js'; setupWccTools({ sections: [ { name: 'Pages', type: 'pages', items: pages, }, { name: 'Form Controls', type: 'elements', items: allElements, icon: 'edit_note', filter: (name) => name.startsWith('form-') || name.includes('input'), sort: ([a], [b]) => a.localeCompare(b), }, { name: 'Layout', type: 'elements', items: allElements, icon: 'dashboard', filter: (name) => name.startsWith('layout-') || name.startsWith('grid-'), }, { name: 'Legacy', type: 'elements', items: allElements, filter: (name) => name.startsWith('legacy-'), collapsed: true, // Start collapsed }, ], }); ``` ### Legacy API (Still Supported) ```typescript // The old format still works for simple use cases setupWccTools(elements, pages); ``` ## Features ### ๐ŸŽฏ Live Property Editing The properties panel automatically detects and allows editing of: | Property Type | Editor | |--------------|--------| | **String** | Text input | | **Number** | Number input | | **Boolean** | Checkbox | | **Enum** | Select dropdown | | **Object/Array** | JSON editor modal | ### ๐Ÿ“ฑ Viewport Testing Test your components across different screen sizes: - **Phone** โ€” 320px width - **Phablet** โ€” 600px width - **Tablet** โ€” 768px width - **Desktop** โ€” Full width (native) ### ๐ŸŒ“ Theme Support Components automatically adapt to light/dark themes. Use CSS custom properties with the theme manager: ```typescript import { cssManager } from '@design.estate/dees-element'; public static styles = [ css` :host { color: ${cssManager.bdTheme('#1a1a1a', '#e5e5e5')}; background: ${cssManager.bdTheme('#ffffff', '#0a0a0a')}; } ` ]; ``` ### ๐ŸŽฌ Screen Recording Record component demos directly from the catalogue: - **Viewport Recording** โ€” Record just the component viewport - **Full Screen Recording** โ€” Capture the entire screen - **Audio Support** โ€” Add microphone commentary with live level monitoring - **Video Trimming** โ€” Trim start/end before export with visual timeline - **WebM Export** โ€” High-quality video output Click the red record button in the bottom toolbar to start. ### ๐Ÿงช Demo Tools The demotools module provides enhanced testing capabilities with `dees-demowrapper`: ```typescript import '@design.estate/dees-wcctools/demotools'; @customElement('my-component') export class MyComponent extends DeesElement { public static demo = () => html` { // Find elements using standard DOM APIs const myComponent = wrapper.querySelector('my-component'); // Simulate user interactions myComponent.value = 'Test value'; await myComponent.updateComplete; // Work with multiple elements wrapper.querySelectorAll('.item').forEach((el, i) => { console.log(`Item ${i}:`, el.textContent); }); }}>
Item 1
Item 2
`; } ``` ### ๐ŸŽญ Multiple Demos Components can expose multiple demo variations: ```typescript @customElement('my-button') export class MyButton extends DeesElement { public static demo = [ () => html`Primary`, () => html`Secondary`, () => html`Danger`, ]; } ``` Each demo appears as a numbered item in an expandable folder in the sidebar. ### โณ Async Demos Return a `Promise` from `demo` for async setup: ```typescript public static demo = async () => { const data = await fetchSomeData(); return html``; }; ``` ### ๐ŸŽฏ Container Queries Components can respond to their container size using the `wccToolsViewport` container: ```typescript public static styles = [ css` @container wccToolsViewport (min-width: 768px) { :host { flex-direction: row; } } @container wccToolsViewport (max-width: 767px) { :host { flex-direction: column; } } ` ]; ``` ## Component Guidelines ### Required for Catalogue Display 1. Components must expose a static `demo` property returning a Lit template (or array of templates) 2. Use `@property()` decorators with the `accessor` keyword for editable properties 3. Export component classes for proper detection ### Best Practices ```typescript @customElement('best-practice-component') export class BestPracticeComponent extends DeesElement { // โœ… Static demo property (single or array) public static demo = () => html` `; // โœ… Typed properties with defaults (TC39 decorators) @property({ type: String }) accessor title: string = 'Default Title'; // โœ… Complex property without attribute @property({ attribute: false }) accessor complexProp: { key: string } = { key: 'default' }; // โœ… Enum with proper typing @property({ type: String }) accessor variant: 'small' | 'medium' | 'large' = 'medium'; } ``` ## URL Routing The catalogue uses URL routing for deep linking: ``` /wcctools-route/:sectionName/:itemName/:demoIndex/:viewport/:theme Examples: /wcctools-route/Elements/my-button/0/desktop/dark /wcctools-route/Views/view-dashboard/0/tablet/bright /wcctools-route/Pages/home/0/desktop/dark ``` ## API Reference ### `setupWccTools(config)` Initialize the WCC Tools dashboard with sections configuration. ```typescript interface IWccSection { name: string; type: 'elements' | 'pages'; items: Record; filter?: (name: string, item: any) => boolean; sort?: (a: [string, any], b: [string, any]) => number; icon?: string; collapsed?: boolean; } interface IWccConfig { sections: IWccSection[]; } setupWccTools(config: IWccConfig): void; // Legacy (still supported) setupWccTools(elements: Record, pages?: Record): void; ``` ### `DeesDemoWrapper` Component for wrapping demos with post-render logic. | Property | Type | Description | |----------|------|-------------| | `runAfterRender` | `(wrapper) => void \| Promise` | Callback after wrapped elements render | The wrapper provides full DOM API access: - `wrapper.querySelector()` โ€” Find single element - `wrapper.querySelectorAll()` โ€” Find multiple elements - `wrapper.children` โ€” Access child elements directly ### Recording Components (Advanced) For custom recording integrations: ```typescript import { RecorderService } from '@design.estate/dees-wcctools'; const recorder = new RecorderService({ onDurationUpdate: (duration) => console.log(`${duration}s`), onRecordingComplete: (blob) => console.log('Recording done!', blob), onAudioLevelUpdate: (level) => console.log(`Audio: ${level}%`), }); await recorder.startRecording({ mode: 'viewport' }); // ... later recorder.stopRecording(); ``` ## Project Structure ``` my-component-library/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ elements/ # UI components โ”‚ โ”‚ โ”œโ”€โ”€ my-button.ts โ”‚ โ”‚ โ”œโ”€โ”€ my-card.ts โ”‚ โ”‚ โ””โ”€โ”€ index.ts โ”‚ โ”œโ”€โ”€ views/ # Full-page layouts โ”‚ โ”‚ โ”œโ”€โ”€ view-dashboard.ts โ”‚ โ”‚ โ””โ”€โ”€ index.ts โ”‚ โ”œโ”€โ”€ pages/ # Documentation pages โ”‚ โ”‚ โ”œโ”€โ”€ home.ts โ”‚ โ”‚ โ””โ”€โ”€ index.ts โ”‚ โ””โ”€โ”€ catalogue.ts # WCC Tools setup โ”œโ”€โ”€ html/ โ”‚ โ””โ”€โ”€ index.html โ””โ”€โ”€ package.json ``` ## Browser Support - โœ… Chrome/Edge (latest) - โœ… Firefox (latest) - โœ… Safari (latest) - โœ… Mobile browsers with Web Components support ## License and Legal Information This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file. **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. ### Trademarks This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar. ### Company Information Task Venture Capital GmbH Registered at District Court Bremen HRB 35230 HB, Germany For any legal inquiries or further information, please contact us via email at hello@task.vc. By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.