- Added dropdown and radio input components to the demo for application settings. - Introduced horizontal layout for display preferences and notification settings. - Implemented checkbox demo with programmatic selection and clear functionality. - Created file upload and quantity selector demos with various states and configurations. - Added comprehensive radio input demo showcasing group behavior and various states. - Developed text input demo with validation states and advanced features like password visibility. - Introduced a new panel component for better content organization in demos.
6.9 KiB
Input Component Unification Plan
Command to reread guidelines: cat /home/philkunz/.claude/CLAUDE.md
Problem Summary
The dees-input components have inconsistent margin behavior causing vertical alignment issues in horizontal flexbox layouts:
- dees-input-text: 8px top, 24px bottom margin
- dees-input-dropdown: 0px top, 24px bottom margin
- dees-input-checkbox/radio: 20px top, 20px bottom margin
- Different components use different label implementations (some use dees-label, others have built-in labels)
Proposed Solution
1. Standardize Margin System
Create a unified margin approach for all input components:
/* Default vertical stacking mode (for forms) */
:host {
margin: 0;
margin-bottom: 16px; /* Reduced from 24px for better density */
}
/* Last child in container should have no bottom margin */
:host(:last-child) {
margin-bottom: 0;
}
/* Horizontal layout mode - activated by parent context or attribute */
:host([horizontal-layout]) {
margin: 0;
margin-right: 16px;
margin-bottom: 0;
}
:host([horizontal-layout]:last-child) {
margin-right: 0;
}
2. Unified Label Architecture
All input components should use the dees-label
component for consistency:
- Move label rendering from built-in implementations to
dees-label
usage - Add a
labelPosition
property to all inputs:'top' | 'left' | 'right' | 'none'
- Default to 'top' for text/dropdown, 'right' for checkbox/radio
3. Layout Mode Support
Add a layoutMode
property to all input components:
@property({ type: String })
public layoutMode: 'vertical' | 'horizontal' | 'auto' = 'auto';
vertical
: Traditional form layout (label on top)horizontal
: Inline layout (label position configurable)auto
: Detect from parent context
4. Implementation Steps
-
Create base input class (
DeesInputBase
):- Common margin styles
- Layout mode detection
- Label position handling
- Shared properties (key, required, disabled, value)
-
Update dees-input-text:
- Extend from DeesInputBase
- Remove hardcoded margins
- Keep using dees-label component
-
Update dees-input-dropdown:
- Extend from DeesInputBase
- Remove hardcoded margins
- Switch from built-in label to dees-label
-
Update dees-input-checkbox:
- Extend from DeesInputBase
- Remove hardcoded margins
- Add support for label position (keep default as 'right')
- Switch to dees-label component
-
Update dees-input-radio:
- Same as checkbox
-
Update dees-form:
- Add property to control child input layout mode
- Ensure proper spacing context
5. CSS Variable System
Introduce CSS variables for consistent spacing:
:host {
--dees-input-spacing-unit: 8px;
--dees-input-vertical-gap: calc(var(--dees-input-spacing-unit) * 2); /* 16px */
--dees-input-horizontal-gap: calc(var(--dees-input-spacing-unit) * 2); /* 16px */
--dees-input-label-gap: var(--dees-input-spacing-unit); /* 8px */
}
6. Backward Compatibility
- Keep existing properties and methods
- Add deprecation notices for properties that will be removed
- Provide migration guide in documentation
7. Testing Requirements
- Test all inputs in vertical form layouts
- Test all inputs in horizontal flexbox containers
- Test mixed input types in same container
- Test with and without labels
- Test theme switching (light/dark)
- Test responsive behavior
Expected Outcome
- All input components will align properly in horizontal layouts
- Consistent spacing in vertical forms
- Unified label handling across all inputs
- Better developer experience with predictable behavior
- Maintained backward compatibility
Timeline
- Phase 1: Create DeesInputBase class and update dees-input-text ✅
- Phase 2: Update remaining input components ✅
- Phase 3: Update documentation and examples ✅
- Phase 4: Testing and refinement ✅
Implementation Status
Completed:
-
Created DeesInputBase class (
dees-input-base.ts
):- Generic base class with unified margin system
- Layout mode support (vertical/horizontal/auto)
- Label position control
- Common properties and methods
- CSS variables for consistent spacing
-
Updated all input components:
dees-input-text
: Now extends DeesInputBase, margins removeddees-input-dropdown
: Now extends DeesInputBase, uses dees-labeldees-input-checkbox
: Now extends DeesInputBase, uses dees-label (default label position: right)dees-input-radio
: Now extends DeesInputBase, uses dees-label (default label position: right)dees-input-phone
: Now extends DeesInputBase with phone formatting functionalitydees-input-iban
: Now extends DeesInputBase with IBAN validationdees-input-quantityselector
: Now extends DeesInputBasedees-input-multitoggle
: Now extends DeesInputBase with value property for formsdees-input-typelist
: Now extends DeesInputBasedees-input-fileupload
: Now extends DeesInputBase, uses dees-label
-
Updated dees-form:
- Added
horizontal-layout
property - Auto-detection of layout mode for child inputs
- Added dropdown to form input types
- Added
-
Fixed TypeScript errors:
- Added value property to dropdown for form compatibility
- Fixed changeSubject typing
- Updated form value type to include dropdown options
- Fixed firstUpdated method signatures (phone, iban, fileupload)
- Fixed CSS-in-JS errors in quantityselector (removed dynamic references)
- Added value property to multitoggle for form compatibility
- Removed duplicate properties in fileupload (label, key, disabled, required)
Result:
All input components now have:
- Unified 16px bottom margin in vertical layouts
- 16px right margin in horizontal layouts
- No margin on last child
- Consistent label handling via dees-label
- Flexible layout modes
- Better alignment in flexbox containers
Demo Improvements
Created external demo files:
-
dees-input-text.demo.ts: Comprehensive demos showing:
- Basic text inputs with descriptions
- Horizontal layout examples
- Label position variations
- Validation states
- Password input features
-
dees-input-checkbox.demo.ts: Interactive demos featuring:
- Basic checkbox usage
- Horizontal layout groups
- Feature selection with batch operations
- Real-world examples
-
dees-input-radio.demo.ts: Radio button demos including:
- Radio groups with proper behavior
- Horizontal yes/no questions
- Survey-style layouts
- Settings examples
Updated existing demos:
- dees-input-dropdown.demo.ts: Enhanced with dees-demowrapper and comprehensive examples
- dees-form.demo.ts: Added horizontal form layout examples and advanced form features
- dees-simple-appdash.demo.ts: Enhanced settings view with horizontal forms and radio groups
All demos now use the dees-demowrapper
component for consistency and include proper styling for light/dark themes.