@design.estate/dees-wcctools 1.0.91 โ†’ 1.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/readme.md +319 -60
  3. package/readme.plan.md +13 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design.estate/dees-wcctools",
3
- "version": "1.0.91",
3
+ "version": "1.0.92",
4
4
  "private": false,
5
5
  "description": "A set of web component tools for creating element catalogues, enabling the structured development and documentation of custom elements and pages.",
6
6
  "exports": {
package/readme.md CHANGED
@@ -1,101 +1,360 @@
1
1
  # @design.estate/dees-wcctools
2
- wcc tools for creating element catalogues
2
+ Web Component Development Tools - A powerful framework for building, testing, and documenting web components
3
3
 
4
- ## Install
5
- To install `@design.estate/dees-wcctools`, you can use npm:
4
+ ## Overview
5
+ `@design.estate/dees-wcctools` provides a comprehensive development environment for web components, featuring:
6
+ - ๐ŸŽจ Interactive component catalogue with live preview
7
+ - ๐Ÿ”ง Real-time property editing
8
+ - ๐ŸŒ“ Theme switching (light/dark modes)
9
+ - ๐Ÿ“ฑ Responsive viewport testing
10
+ - ๐Ÿงช Advanced demo tools for component testing
11
+ - ๐Ÿš€ Zero-config setup with TypeScript and Lit support
12
+
13
+ ## Installation
6
14
 
7
15
  ```bash
8
- npm install @design.estate/dees-wcctools --save
16
+ # Using npm
17
+ npm install @design.estate/dees-wcctools --save-dev
18
+
19
+ # Using pnpm (recommended)
20
+ pnpm add -D @design.estate/dees-wcctools
9
21
  ```
10
22
 
11
- ## Usage
12
- The `@design.estate/dees-wcctools` package provides a set of tools for creating element catalogues using Web Components. It leverages LitElement for creating custom elements and provides a structured way to showcase and test these elements in various environments and themes.
23
+ ## Quick Start
13
24
 
14
- ### Setting Up
15
- First, ensure that your project is set up to use TypeScript and ESM syntax. This guide assumes you have a basic understanding of TypeScript and modern JavaScript development practices.
25
+ ### 1. Create Your Component
16
26
 
17
- Start by importing the necessary tools from `@design.estate/dees-wcctools` in your main TypeScript file.
27
+ ```typescript
28
+ import { DeesElement, customElement, html, css, property } from '@design.estate/dees-element';
29
+
30
+ @customElement('my-button')
31
+ export class MyButton extends DeesElement {
32
+ // Define a demo for the catalogue
33
+ public static demo = () => html`
34
+ <my-button .label=${'Click me!'} .variant=${'primary'}></my-button>
35
+ `;
36
+
37
+ @property({ type: String })
38
+ public label: string = 'Button';
39
+
40
+ @property({ type: String })
41
+ public variant: 'primary' | 'secondary' = 'primary';
42
+
43
+ public static styles = [
44
+ css`
45
+ :host {
46
+ display: inline-block;
47
+ }
48
+ button {
49
+ padding: 8px 16px;
50
+ border-radius: 4px;
51
+ border: none;
52
+ font-size: 14px;
53
+ cursor: pointer;
54
+ transition: all 0.3s;
55
+ }
56
+ button.primary {
57
+ background: #007bff;
58
+ color: white;
59
+ }
60
+ button.secondary {
61
+ background: #6c757d;
62
+ color: white;
63
+ }
64
+ button:hover {
65
+ opacity: 0.9;
66
+ }
67
+ `
68
+ ];
69
+
70
+ public render() {
71
+ return html`
72
+ <button class="${this.variant}">
73
+ ${this.label}
74
+ </button>
75
+ `;
76
+ }
77
+ }
78
+ ```
79
+
80
+ ### 2. Set Up Your Catalogue
18
81
 
19
82
  ```typescript
83
+ // catalogue.ts
20
84
  import { setupWccTools } from '@design.estate/dees-wcctools';
85
+ import { html } from 'lit';
86
+
87
+ // Import your components
88
+ import './components/my-button.js';
89
+ import './components/my-card.js';
90
+
91
+ // Define elements for the catalogue
92
+ const elements = {
93
+ 'my-button': MyButton,
94
+ 'my-card': MyCard,
95
+ };
96
+
97
+ // Optionally define pages
98
+ const pages = {
99
+ 'home': () => html`
100
+ <div style="padding: 20px;">
101
+ <h1>Welcome to My Component Library</h1>
102
+ <p>Browse components using the sidebar.</p>
103
+ </div>
104
+ `,
105
+ 'getting-started': () => html`
106
+ <div style="padding: 20px;">
107
+ <h2>Getting Started</h2>
108
+ <p>Installation and usage instructions...</p>
109
+ </div>
110
+ `,
111
+ };
112
+
113
+ // Initialize the catalogue
114
+ setupWccTools(elements, pages);
21
115
  ```
22
116
 
23
- ### Defining Custom Elements
24
- Define your custom elements using LitElement. Here's a simple example of an element:
117
+ ### 3. Create an HTML Entry Point
118
+
119
+ ```html
120
+ <!DOCTYPE html>
121
+ <html>
122
+ <head>
123
+ <title>Component Catalogue</title>
124
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
125
+ </head>
126
+ <body style="margin: 0; padding: 0;">
127
+ <script type="module" src="./catalogue.js"></script>
128
+ </body>
129
+ </html>
130
+ ```
25
131
 
26
- ```typescript
27
- import { LitElement, html, customElement } from 'lit';
132
+ ## Features
28
133
 
29
- @customElement('my-element')
30
- class MyElement extends LitElement {
31
- render() {
32
- return html`<p>Hello, world!</p>`;
33
- }
134
+ ### ๐ŸŽฏ Live Property Editing
135
+ The properties panel automatically detects and allows editing of:
136
+ - **String** properties with text inputs
137
+ - **Number** properties with number inputs
138
+ - **Boolean** properties with checkboxes
139
+ - **Enum** properties with select dropdowns
140
+ - **Object** and **Array** properties (read-only display)
141
+
142
+ ### ๐Ÿ“ฑ Viewport Testing
143
+ Test your components across different screen sizes:
144
+ - **Phone** (320px width)
145
+ - **Phablet** (600px width)
146
+ - **Tablet** (768px width)
147
+ - **Desktop** (full width)
148
+
149
+ ### ๐ŸŒ“ Theme Support
150
+ Components automatically adapt to light/dark themes using the `goBright` property:
151
+
152
+ ```typescript
153
+ public render() {
154
+ return html`
155
+ <div class="${this.goBright ? 'light-theme' : 'dark-theme'}">
156
+ <!-- Your component content -->
157
+ </div>
158
+ `;
34
159
  }
35
160
  ```
36
161
 
37
- ### Bootstrapping the WCCTools Dashboard
38
- To showcase your elements, `@design.estate/dees-wcctools` provides a handy way to bootstrap a dashboard where your elements can be registered and displayed.
162
+ Or use CSS custom properties:
163
+ ```typescript
164
+ import { cssManager } from '@design.estate/dees-element';
165
+
166
+ public static styles = [
167
+ css`
168
+ :host {
169
+ color: ${cssManager.bdTheme('#000', '#fff')};
170
+ background: ${cssManager.bdTheme('#fff', '#000')};
171
+ }
172
+ `
173
+ ];
174
+ ```
175
+
176
+ ### ๐Ÿงช Advanced Demo Tools
39
177
 
40
- Create a bootstrap function in your main file or a separate module:
178
+ The demo tools provide enhanced testing capabilities:
41
179
 
42
180
  ```typescript
43
- async function bootstrapWCCTools() {
44
- // Define your elements here
45
- const elements = {
46
- 'my-element': MyElement, // Assuming MyElement is imported
47
- };
48
-
49
- // Optionally, define pages as functions returning Lit HTML Templates
50
- const pages = {
51
- home: () => html`<h1>Welcome to My Element Catalogue</h1>`,
52
- };
53
-
54
- // Setup the WCCTools dashboard
55
- setupWccTools(elements, pages);
181
+ import * as demoTools from '@design.estate/dees-wcctools/demoTools';
182
+
183
+ @customElement('my-component')
184
+ export class MyComponent extends DeesElement {
185
+ public static demo = () => html`
186
+ <dees-demowrapper .runAfterRender=${async (element: MyComponent) => {
187
+ // Access the rendered component instance
188
+ console.log('Component mounted:', element);
189
+
190
+ // Simulate user interactions
191
+ element.value = 'Test value';
192
+ await element.updateComplete;
193
+
194
+ // Trigger methods
195
+ element.handleClick();
196
+
197
+ // Assert component state
198
+ if (element.isValid) {
199
+ console.log('Component validation passed');
200
+ }
201
+ }}>
202
+ <my-component></my-component>
203
+ </dees-demowrapper>
204
+ `;
56
205
  }
57
206
  ```
58
207
 
59
- Call this function to initialize your catalogue:
208
+ ### ๐ŸŽญ Container Queries Support
209
+
210
+ Components can respond to their container size:
211
+
212
+ ```typescript
213
+ public static styles = [
214
+ css`
215
+ @container wccToolsViewport (min-width: 768px) {
216
+ :host {
217
+ flex-direction: row;
218
+ }
219
+ }
220
+
221
+ @container wccToolsViewport (max-width: 767px) {
222
+ :host {
223
+ flex-direction: column;
224
+ }
225
+ }
226
+ `
227
+ ];
228
+ ```
229
+
230
+ ## Component Guidelines
60
231
 
232
+ ### Required for Catalogue Display
233
+ 1. Components must expose a static `demo` property returning a Lit template
234
+ 2. Use `@property()` decorators for properties you want to be editable
235
+ 3. Export component classes for proper detection
236
+
237
+ ### Best Practices
61
238
  ```typescript
62
- bootstrapWCCTools();
239
+ @customElement('best-practice-component')
240
+ export class BestPracticeComponent extends DeesElement {
241
+ // โœ… Static demo property
242
+ public static demo = () => html`
243
+ <best-practice-component
244
+ .complexProp=${{ key: 'value' }}
245
+ simpleAttribute="test"
246
+ ></best-practice-component>
247
+ `;
248
+
249
+ // โœ… Typed properties with defaults
250
+ @property({ type: String })
251
+ public title: string = 'Default Title';
252
+
253
+ // โœ… Complex property without attribute
254
+ @property({ attribute: false })
255
+ public complexProp: { key: string } = { key: 'default' };
256
+
257
+ // โœ… Enum with proper typing
258
+ @property({ type: String })
259
+ public variant: 'small' | 'medium' | 'large' = 'medium';
260
+ }
261
+ ```
262
+
263
+ ## URL Routing
264
+
265
+ The catalogue uses URL routing for deep linking:
63
266
  ```
267
+ /wcctools-route/:type/:name/:viewport/:theme
64
268
 
65
- ### Configurations and Customizations
66
- The `setupWccTools` function accepts two arguments: `elements` and `pages`.
269
+ Example:
270
+ /wcctools-route/element/my-button/desktop/dark
271
+ /wcctools-route/page/home/tablet/bright
272
+ ```
67
273
 
68
- - `elements`: An object where keys are element tags (e.g., 'my-element') and values are the corresponding class definitions.
69
- - `pages`: An optional object where keys are page identifiers and values are functions returning Lit HTML templates.
274
+ ## Development Workflow
70
275
 
71
- ### Testing Elements
72
- Once the dashboard is set up, navigate to your project in a web browser. You'll see a sidebar listing all registered elements and pages. Clicking on an element name will display it in the main view, allowing you to interact with it and see it in action.
276
+ ### Build and Watch
277
+ ```json
278
+ {
279
+ "scripts": {
280
+ "build": "tsbuild tsfolders --allowimplicitany && tsbundle element",
281
+ "watch": "tswatch element",
282
+ "serve": "http-server ./dist"
283
+ }
284
+ }
285
+ ```
286
+
287
+ ### Project Structure
288
+ ```
289
+ my-components/
290
+ โ”œโ”€โ”€ src/
291
+ โ”‚ โ”œโ”€โ”€ components/
292
+ โ”‚ โ”‚ โ”œโ”€โ”€ my-button.ts
293
+ โ”‚ โ”‚ โ””โ”€โ”€ my-card.ts
294
+ โ”‚ โ””โ”€โ”€ catalogue.ts
295
+ โ”œโ”€โ”€ dist/
296
+ โ”œโ”€โ”€ index.html
297
+ โ””โ”€โ”€ package.json
298
+ ```
73
299
 
74
- ### Theme and Environment Testing
75
- The dashboard also provides options for testing your elements in different environments (e.g., desktop, tablet) and themes (light or dark). This helps ensure that your elements are versatile and adaptable to varying conditions.
300
+ ## Advanced Features
76
301
 
77
- ### Expanding Your Catalogue
78
- To add more elements to your catalogue, simply extend the `elements` object and rerun `bootstrapWCCTools()`. This modular approach makes it easy to maintain and expand your element catalogue.
302
+ ### Custom Property Handlers
303
+ For complex property types, implement custom logic in your demo:
79
304
 
80
- ### Leveraging TypeScript
81
- Using TypeScript allows you to enforce typing and build more reliable web components. Define properties with decorators, and use TypeScript's features to enhance your component development process.
305
+ ```typescript
306
+ public static demo = () => html`
307
+ <dees-demowrapper .runAfterRender=${(el) => {
308
+ // Set up complex property handling
309
+ el.addEventListener('property-change', (e) => {
310
+ console.log('Property changed:', e.detail);
311
+ });
312
+ }}>
313
+ <my-component></my-component>
314
+ </dees-demowrapper>
315
+ `;
316
+ ```
82
317
 
318
+ ### Responsive Testing Helpers
83
319
  ```typescript
84
- import { LitElement, property, html, customElement } from 'lit';
320
+ import * as domtools from '@design.estate/dees-domtools';
85
321
 
86
- @customElement('typed-element')
87
- class TypedElement extends LitElement {
88
- @property({type: String})
89
- name: string = 'World';
322
+ public static styles = [
323
+ // Media query helpers
324
+ domtools.breakpoints.cssForPhone(css`
325
+ :host { font-size: 14px; }
326
+ `),
90
327
 
91
- render() {
92
- return html`<p>Hello, ${this.name}!</p>`;
93
- }
94
- }
328
+ domtools.breakpoints.cssForTablet(css`
329
+ :host { font-size: 16px; }
330
+ `),
331
+
332
+ domtools.breakpoints.cssForDesktop(css`
333
+ :host { font-size: 18px; }
334
+ `)
335
+ ];
95
336
  ```
96
337
 
97
- ### Conclusion
98
- `@design.estate/dees-wcctools` provides a powerful, flexible platform for developing, showcasing, and testing web components. By leveraging modern development practices like TypeScript and LitElement, you can build a robust catalogue of reusable web components ready for any project.
338
+ ## API Reference
339
+
340
+ ### setupWccTools(elements, pages?)
341
+ Initialize the WCC Tools dashboard.
342
+
343
+ - `elements`: Object mapping element names to element classes
344
+ - `pages`: Optional object mapping page names to template functions
345
+
346
+ ### DeesDemoWrapper
347
+ Component for wrapping demos with post-render logic.
348
+
349
+ - `runAfterRender`: Function called after the wrapped element renders
350
+ - Receives the first child element as parameter
351
+ - Supports async operations
352
+
353
+ ## Browser Support
354
+ - Chrome/Edge (latest)
355
+ - Firefox (latest)
356
+ - Safari (latest)
357
+ - Mobile browsers with Web Components support
99
358
 
100
359
  ## License and Legal Information
101
360
 
@@ -114,4 +373,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
114
373
 
115
374
  For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
116
375
 
117
- 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.
376
+ 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.
package/readme.plan.md CHANGED
@@ -38,4 +38,16 @@ The properties panel has timing issues detecting rendered elements because:
38
38
  - Uses display: contents to not affect layout
39
39
  - Handles timing automatically with 50ms delay after firstUpdated
40
40
  - Supports both sync and async callbacks
41
- - Exports available at @design.estate/dees-wcctools/demoTools
41
+ - Exports available at @design.estate/dees-wcctools/demoTools
42
+
43
+ # Documentation Update (COMPLETED)
44
+
45
+ ## Updated readme.md with:
46
+ - Comprehensive overview with feature highlights
47
+ - Quick start guide with code examples
48
+ - Detailed feature documentation
49
+ - Advanced demo tools usage
50
+ - Best practices and guidelines
51
+ - API reference
52
+ - Browser support information
53
+ - Complete examples for all major features