feat(wcctools): Add section-based configuration API for setupWccTools, new Views, and section-aware routing/sidebar

This commit is contained in:
2025-12-28 12:51:55 +00:00
parent dd151bdad8
commit 14e63738b7
14 changed files with 1709 additions and 212 deletions

View File

@@ -1,5 +1,67 @@
# Project Hints and Findings
## Section-based Configuration API (2025-12-27)
### Overview
Refactored `setupWccTools` to accept a section-based configuration object instead of separate elements/pages arguments. This allows multiple custom sections with filtering, sorting, and collapsible headers.
### New API
```typescript
import * as deesWccTools from '@design.estate/dees-wcctools';
deesWccTools.setupWccTools({
sections: [
{
name: 'Pages',
type: 'pages',
items: pages,
},
{
name: 'Elements',
type: 'elements',
items: elements,
filter: (name, item) => !name.startsWith('internal-'),
sort: ([a], [b]) => a.localeCompare(b),
},
{
name: 'Views',
type: 'elements',
items: elements,
filter: (name, item) => name.startsWith('view-'),
icon: 'web',
collapsed: true, // Start collapsed
},
],
});
```
### Section Properties
- `name`: Display name for the section header
- `type`: `'elements'` (shows demos) or `'pages'` (renders directly)
- `items`: Record of items (element classes or page factories)
- `filter`: Optional `(name, item) => boolean` to filter items
- `sort`: Optional `([name, item], [name, item]) => number` for ordering
- `icon`: Optional Material icon name for section header
- `collapsed`: Optional boolean to start section collapsed
### Backwards Compatibility
Legacy format is still supported:
```typescript
deesWccTools.setupWccTools(elements, pages); // Still works
```
### URL Routing
Changed from `/wcctools-route/:itemType/:itemName/...` to `/wcctools-route/:sectionName/:itemName/...`
Section names are URL-encoded. Legacy routes (`element`/`page` as section name) still work for backwards compatibility.
### Files Changed
- `ts_web/wcctools.interfaces.ts` - New types: `IWccSection`, `IWccConfig`
- `ts_web/index.ts` - Updated `setupWccTools` with backwards compat detection
- `ts_web/elements/wcc-dashboard.ts` - Uses sections, updated routing
- `ts_web/elements/wcc-sidebar.ts` - Dynamic section rendering
---
## UI Redesign with Shadcn-like Styles (2025-06-27)
### Changes Made