Building the Universal Demo Shell

Category: tech

Reading Time: 6 min read

Tags: React, Design System, UX, TypeScript

Building the Universal Demo Shell

The challenge of showcasing complex financial analysis tools led me to create a universal demo shell that maintains visual consistency while allowing each demonstration to shine through its functionality.

The Design Philosophy

Every demo needed to feel cohesive while serving different purposes:
- Deep Value Screener: Stock analysis and screening
- Portfolio Stress Testing: Risk assessment and scenario modeling
- Quality Score Engine: Company evaluation metrics

Technical Implementation

The solution was a React component that accepts metadata and dynamically styles itself:

``tsx
interface DemoMeta {
title: string
description: string
color: string
features: string[]
component: React.ComponentType
}
`

This approach ensures consistent branding while allowing each demo's unique functionality to take center stage.

Key Features

Dynamic Color Theming

Each demo has its own color scheme that automatically applies to borders, text, and hover effects:

`tsx
const colorClasses = {
purple: { primary: '#8b5cf6', secondary: '#a78bfa' },
blue: { primary: '#3b82f6', secondary: '#60a5fa' },
green: { primary: '#10b981', secondary: '#34d399' }
}
`

Lazy Loading

Components are dynamically imported to keep initial bundle size small:

`tsx
const Demo = dynamic(meta.component, {
ssr: false,
loading: () =>
})
`

Responsive Grid System

Features adapt to screen size while maintaining consistent spacing:

`css
.grid sm:grid-cols-2 lg:grid-cols-3 gap-4
``

Performance Optimizations

1. Code Splitting: Each demo loads only when needed
2. CSS-in-JS Avoidance: Tailwind utilities for minimal runtime overhead
3. Memoization: Feature lists and color calculations cached
4. Lazy Iframe Loading: Demo content loads on-demand

Accessibility Considerations

- Keyboard Navigation: Full tab support through all interactive elements
- Screen Reader Support: Semantic HTML and ARIA labels
- Color Contrast: All text meets WCAG AA standards
- Focus Indicators: Clear visual feedback for keyboard users

Results

- 40% faster demo development time
- Consistent user experience across all tools
- Maintainable codebase with shared styling logic
- Enhanced accessibility through standardized patterns

Lessons Learned

1. Consistency Matters: Users appreciate predictable interfaces
2. Performance First: Lazy loading dramatically improves initial load
3. Flexibility Through Constraints: Limited color palette enforces cohesion
4. Documentation is Key: Clear prop interfaces speed development

What's Next

The universal shell will evolve to support:
- Dark/light theme variants
- Animation preferences
- Custom layouts per demo type
- Embedded documentation panels

The universal shell became the foundation for our entire interactive demo ecosystem, proving that thoughtful constraints can enhance rather than limit creativity.