Component Development Guide
Complete guide to developing and maintaining UI components for the Cascadia Marquee website
Component Development Guide
Complete guide to developing and maintaining UI components for the Cascadia Marquee website.
Component Architecture
The website uses a layered component architecture:
- UI Components - Base components from shadcn/ui
- Layout Components - Page structure and navigation
- Feature Components - Business logic and functionality
- Content Components - MDX and content-specific components
Component Structure
Adding New UI Components
Using shadcn/ui (Recommended)
-
Install a component:
-
Components are automatically added to:
src/components/ui/[component-name].tsxsrc/components/ui/index.ts(export)
-
Use the component:
Available shadcn/ui Components
- Button - Interactive buttons with variants
- Card - Content containers
- Dialog - Modal dialogs
- Input - Form inputs
- Label - Form labels
- Select - Dropdown selects
- Textarea - Multi-line text inputs
- Badge - Status indicators
- Alert - Alert messages
- Accordion - Collapsible content
- Tabs - Tabbed interfaces
- Tooltip - Hover tooltips
- Dropdown Menu - Context menus
- Command - Command palette
- Form - Form handling
- Checkbox - Checkbox inputs
- Switch - Toggle switches
- Slider - Range sliders
- Progress - Progress bars
- Separator - Visual separators
- Aspect Ratio - Responsive containers
- Hover Card - Hover content
- Collapsible - Collapsible sections
- Resizable - Resizable panels
- Drawer - Mobile-friendly drawers
- Sonner - Toast notifications
Creating Custom Components
Component Template
Component Best Practices
- Use forwardRef for proper ref forwarding
- Include className prop for customization
- Use cn() utility for conditional classes
- Export with displayName for debugging
- Follow TypeScript interfaces for type safety
Example: Custom Card Component
Component Registry System
The website uses an automated component registry for dynamic component loading:
Registry Structure
Adding Components to Registry
-
Place component in appropriate directory:
- Charts:
src/components/charts/ - Examples:
src/components/examples/
- Charts:
-
Run registry build:
-
Component is automatically registered and available for dynamic loading
Using Registry Components
Layout Components
Page Layouts
Section Components
Feature Components
Contact Form Components
Chart Components
Styling Components
Using Tailwind CSS
Using CSS Variables
Custom CSS Classes
Component Testing
Unit Testing
Integration Testing
Performance Optimization
Lazy Loading
Memoization
Code Splitting
Accessibility
ARIA Attributes
Keyboard Navigation
Focus Management
Component Documentation
JSDoc Comments
Storybook Integration
Troubleshooting
Common Issues
Component not rendering:
- Check import paths
- Verify component is exported
- Check for TypeScript errors
Styling not applying:
- Verify Tailwind classes are correct
- Check CSS variable definitions
- Ensure proper className prop usage
Performance issues:
- Use React DevTools Profiler
- Check for unnecessary re-renders
- Implement proper memoization
Accessibility issues:
- Run
pnpm a11y:scanor use thea11y-accessibilityMCP server in Cursor (test_accessibility) - Check ARIA attributes
- Test keyboard navigation
Best Practices
- Follow the component hierarchy - UI → Layout → Feature → Content
- Use TypeScript interfaces for all component props
- Implement proper error boundaries for robust error handling
- Write comprehensive tests for critical components
- Document components with JSDoc and Storybook
- Optimize for performance with lazy loading and memoization
- Ensure accessibility with proper ARIA attributes and keyboard support
- Follow design system patterns and conventions
For questions about component development, check the other documentation sections or contact the development team.