# @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 sidebar navigation - ๐Ÿ”ง **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 - ๐Ÿš€ **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; font-size: 14px; cursor: pointer; transition: all 0.3s; } button.primary { background: #007bff; color: white; } button.secondary { background: #6c757d; color: white; } button:hover { opacity: 0.9; } ` ]; 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 { MyButton } from './components/my-button.js'; import { MyCard } from './components/my-card.js'; // Define elements for the catalogue const elements = { 'my-button': MyButton, 'my-card': MyCard, }; // Optionally define pages const pages = { 'home': () => html`

Welcome to My Component Library

Browse components using the sidebar.

`, 'getting-started': () => html`

Getting Started

Installation and usage instructions...

`, }; // Initialize the catalogue setupWccTools(elements, pages); ``` ### 3. Create an HTML Entry Point ```html Component Catalogue ``` ## 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 using the `goBright` property: ```typescript public render() { return html`
`; } ``` Or use CSS custom properties with the theme manager: ```typescript import { cssManager } from '@design.estate/dees-element'; public static styles = [ css` :host { color: ${cssManager.bdTheme('#000', '#fff')}; background: ${cssManager.bdTheme('#fff', '#000')}; } ` ]; ``` ### ๐ŸŽฌ Screen Recording Record component demos directly from the catalogue! The built-in recorder supports: - **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
`; } ``` ### โณ Async Demos Return a `Promise` from `demo` for async setup. The dashboard waits for resolution: ```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 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 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/:type/:name/:viewport/:theme Examples: /wcctools-route/element/my-button/desktop/dark /wcctools-route/page/home/tablet/bright ``` ## API Reference ### `setupWccTools(elements, pages?)` Initialize the WCC Tools dashboard. | Parameter | Type | Description | |-----------|------|-------------| | `elements` | `Record` | Map of element names to classes | | `pages` | `Record` | Optional map of page names to template functions | ### `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-components/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ components/ โ”‚ โ”‚ โ”œโ”€โ”€ my-button.ts โ”‚ โ”‚ โ””โ”€โ”€ my-card.ts โ”‚ โ””โ”€โ”€ catalogue.ts โ”œโ”€โ”€ dist/ โ”œโ”€โ”€ 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.