2025-06-16 13:10:12 +00:00
|
|
|
# Project Hints and Findings
|
|
|
|
|
2025-06-27 20:03:54 +00:00
|
|
|
## UI Redesign with Shadcn-like Styles (2025-06-27)
|
|
|
|
|
|
|
|
### Changes Made
|
|
|
|
Updated the WCC Dashboard UI components (properties and sidebar) to use shadcn-like design patterns:
|
|
|
|
|
|
|
|
1. **Color System**: Implemented CSS variables for theming:
|
|
|
|
- `--background`, `--foreground`, `--card`, `--primary`, `--secondary`
|
|
|
|
- `--muted`, `--accent`, `--border`, `--input`, `--ring`
|
|
|
|
- Consistent dark theme with subtle borders and proper contrast
|
|
|
|
|
|
|
|
2. **Properties Panel Improvements**:
|
|
|
|
- Changed from fixed 3-column grid to flexible flexbox layout
|
|
|
|
- Properties now wrap and use space more efficiently
|
|
|
|
- Added rounded corners and better spacing
|
|
|
|
- Complex properties (Objects/Arrays) show "Edit" button
|
|
|
|
- Advanced JSON editor appears above properties panel when editing complex types
|
|
|
|
- Dynamic height adjustment (50px when editor is open, 100px normally)
|
|
|
|
|
|
|
|
3. **Sidebar Styling**:
|
|
|
|
- Updated with consistent color scheme
|
|
|
|
- Added rounded corners to menu items
|
|
|
|
- Improved hover states with smooth transitions
|
|
|
|
- Better typography with proper font weights
|
|
|
|
|
|
|
|
4. **Advanced Property Editor**:
|
|
|
|
- JSON editor for complex types (Objects and Arrays)
|
|
|
|
- Monaco-style monospace font for code editing
|
|
|
|
- Live updates to element properties
|
|
|
|
- Positioned above the properties panel with smooth transitions
|
|
|
|
|
|
|
|
### Technical Details
|
|
|
|
- Uses system font stack for better native appearance
|
|
|
|
- Subtle borders with rgba values for transparency
|
|
|
|
- Consistent spacing using CSS variables
|
|
|
|
- Smooth transitions (0.15s ease) for interactive elements
|
|
|
|
- Custom scrollbar styling for better visual integration
|
|
|
|
|
2025-06-16 13:10:12 +00:00
|
|
|
## Properties Panel Element Detection Issue (Fixed)
|
|
|
|
|
|
|
|
### Problem
|
|
|
|
The properties panel had timing issues detecting rendered elements because:
|
|
|
|
1. Elements are rendered asynchronously via lit's `render()` function in the dashboard component
|
|
|
|
2. The properties panel tried to find elements immediately without waiting for render completion
|
|
|
|
3. Element search only looked at direct children of the viewport, missing nested elements or those inside shadow DOM
|
|
|
|
|
|
|
|
### Solution Implemented
|
|
|
|
1. Added a 100ms initial delay to allow render completion
|
|
|
|
2. Implemented recursive element search that:
|
|
|
|
- Searches through nested children up to 5 levels deep
|
2025-06-16 15:56:12 +00:00
|
|
|
- Checks both light DOM and shadow DOM for all elements
|
|
|
|
- Handles complex DOM structures generically
|
|
|
|
- Works with any wrapper elements, not specific to dees-demowrapper
|
2025-06-16 13:10:12 +00:00
|
|
|
3. Added retry mechanism with up to 5 attempts (200ms between retries)
|
|
|
|
4. Improved error messages to show retry count
|
2025-06-16 15:56:12 +00:00
|
|
|
5. Comprehensive error handling:
|
|
|
|
- Errors in element search don't break the update cycle
|
|
|
|
- Individual property errors don't prevent other properties from rendering
|
|
|
|
- scheduleUpdate always completes even if createProperties fails
|
|
|
|
- Clears warnings and property content appropriately on errors
|
2025-06-16 13:10:12 +00:00
|
|
|
|
|
|
|
### Code Flow
|
|
|
|
1. Dashboard renders element demo into viewport using `render(anonItem.demo(), viewport)`
|
2025-06-16 17:56:14 +00:00
|
|
|
2. Properties panel waits 200ms for demo wrappers to run and set initial values
|
|
|
|
3. Searches recursively for the element instance
|
|
|
|
4. If not found, retries with delays to handle async rendering
|
|
|
|
5. Once found, extracts and displays element properties
|
|
|
|
6. Uses property binding (`.value=`) instead of attribute binding to prevent input events during initialization
|
2025-06-16 13:18:13 +00:00
|
|
|
|
|
|
|
## Demo Tools
|
|
|
|
|
|
|
|
### DeesDemoWrapper Component
|
|
|
|
A utility component for wrapping demo elements with post-render functionality.
|
|
|
|
|
|
|
|
**Usage:**
|
|
|
|
```typescript
|
2025-06-16 14:35:28 +00:00
|
|
|
import * as demoTools from '@design.estate/dees-wcctools/demotools';
|
2025-06-16 13:18:13 +00:00
|
|
|
|
|
|
|
// In your demo function:
|
|
|
|
demo: () => html`
|
2025-06-16 14:45:19 +00:00
|
|
|
<dees-demowrapper .runAfterRender=${(wrapper) => {
|
|
|
|
// Use querySelector for specific elements
|
|
|
|
const myElement = wrapper.querySelector('my-custom-element');
|
|
|
|
myElement?.setAttribute('data-demo', 'true');
|
2025-06-16 14:35:28 +00:00
|
|
|
|
2025-06-16 14:45:19 +00:00
|
|
|
// Access all children
|
|
|
|
console.log('All children:', wrapper.children);
|
|
|
|
|
|
|
|
// Use querySelectorAll for multiple elements
|
|
|
|
wrapper.querySelectorAll('div').forEach(div => {
|
|
|
|
console.log('Found div:', div);
|
2025-06-16 14:35:28 +00:00
|
|
|
});
|
2025-06-16 14:45:19 +00:00
|
|
|
|
|
|
|
// Full DOM API available
|
|
|
|
const firstChild = wrapper.firstElementChild;
|
|
|
|
const hasClass = wrapper.querySelector('.my-class');
|
2025-06-16 13:18:13 +00:00
|
|
|
}}>
|
|
|
|
<my-custom-element></my-custom-element>
|
2025-06-16 14:35:28 +00:00
|
|
|
<div>Additional content</div>
|
2025-06-16 13:18:13 +00:00
|
|
|
</dees-demowrapper>
|
|
|
|
`
|
|
|
|
```
|
|
|
|
|
|
|
|
**Features:**
|
|
|
|
- Wraps demo elements without affecting layout (uses `display: contents`)
|
2025-06-16 14:45:19 +00:00
|
|
|
- Provides the wrapper element itself with full DOM API access
|
|
|
|
- Use querySelector/querySelectorAll for powerful element selection
|
|
|
|
- Access children via wrapper.children property
|
2025-06-16 13:18:13 +00:00
|
|
|
- Supports async operations in runAfterRender callback
|
2025-06-16 14:45:19 +00:00
|
|
|
- Automatically handles timing to ensure elements are fully rendered
|