Shared UI Components
Reusable React components used across all three products (FleetOS, Robo-Hub, Robo-Dapp).
Overview
This directory contains shared UI components that eliminate code duplication and provide consistent user experiences across the T420 ecosystem. All components use CSS variables for theming compatibility.
Available Components
1. Card Component
File: Card.tsx Purpose: Reusable card container with multiple visual variants
Variants:
default- Standard card with subtle stylingfeatured- Highlighted card with accent colorsstat- Card optimized for displaying statisticsservice- Card for service listings
Sub-components:
CardHeader- Optional header sectionCardFooter- Optional footer section
Usage:
Props:
Use Cases:
Blog post cards (BlogDirectoryPage)
Service request cards (SupplierTodoList)
Statistics dashboard cards
RFQ listings (Robo-Hub)
2. EmptyState Component
File: EmptyState.tsx Purpose: Standardized UI for "no data" scenarios
Features:
Customizable icon (emoji or React element)
Title and description text
Optional action button
Support for custom children
Usage:
Props:
Use Cases:
Empty chat conversations
No pending requests
Empty supplier directory
No search results
3. Breadcrumb Component
File: Breadcrumb.tsx Purpose: Navigation breadcrumb for hierarchical pages
Features:
Clickable navigation items
Custom separators
Automatic last-item styling (non-clickable)
Hover effects on navigation items
Usage:
Props:
Use Cases:
Blog navigation (BlogDirectoryPage, BlogPostPage)
Multi-step forms
Settings pages
Hierarchical content
4. FilterBar Component
File: FilterBar.tsx Purpose: Search, filter, and sort interface with debouncing
Features:
Debounced search input (300ms)
Filter dropdown
Sort dropdown
Clear all filters button
Responsive flex layout
Usage:
Props:
Debouncing: The search input debounces user input by 300ms to avoid excessive API calls or re-renders during typing.
Use Cases:
Service request lists
Supplier directories
Blog post listings
RFQ browsing (Robo-Hub)
Shared Chat Helpers
chatHelpers.ts
File: chatHelpers.tsx Purpose: Reusable message rendering utilities for all chat interfaces
Functions:
getMessageBubbleStyles(message, currentRole)
getMessageBubbleStyles(message, currentRole)Returns appropriate styling for message bubbles based on sender type.
Usage:
Styles:
Current user: Accent color background
System messages: Gray background
AI messages: Amber background with left border accent
Other users: Light gray background
getSenderLabel(message, currentRole)
getSenderLabel(message, currentRole)Returns display label for message sender.
Usage:
getSenderLabelColor(message, currentRole)
getSenderLabelColor(message, currentRole)Returns color for sender label text.
getTimestampColor(message, currentRole)
getTimestampColor(message, currentRole)Returns color for timestamp text.
formatMessageTime(date)
formatMessageTime(date)Formats timestamp for display (e.g., "2:45 PM").
Use Cases:
AgenticChatInterface (FleetOS agents)
ShepherdChatInterface (Robo-Hub shepherds)
SupplierChatInterface (Supplier conversations)
Impact: Reduces 1,500 lines of duplicate chat code across 3 interfaces to ~400 lines (73% reduction).
Theme Compatibility
All components use CSS variables for theming:
Product Theming:
FleetOS: Uses accent colors sparingly, gray-dominant
Robo-Hub: More vibrant accent usage, blue accents
Robo-Dapp: Blockchain-inspired colors (future)
Best Practices
1. Import from Shared
Always import shared components to avoid duplication:
2. Use Props for Customization
Prefer props over creating new components:
3. Extend with Children
Use children prop for custom content:
4. CSS Variables for Theming
Use CSS variables instead of hardcoded colors:
Testing Shared Components
Adding New Shared Components
When creating a new shared component:
Check for duplication - Search codebase for similar implementations
Design for reuse - Make it generic, not product-specific
Use TypeScript - Fully type all props and interfaces
Export types - Export prop interfaces for consumers
Add JSDoc comments - Document purpose and usage
Use CSS variables - For theming compatibility
Update this README - Add documentation and examples
Consider testing - Add tests for core functionality
Component Organization
Future Additions:
Modal.tsx- Standardized modal dialogs (6 duplicate modals exist)BaseChatInterface.tsx- Base chat component (in progress)DashboardCard.tsx- Dashboard-specific cards (7 duplicate dashboards)LoadingSpinner.tsx- Loading statesTooltip.tsx- Hover tooltipsBadge.tsx- Status badges
Migration from Product-Specific Components
If you have a product-specific component that could be shared:
Extract to shared/ - Move component to this directory
Generalize props - Remove product-specific assumptions
Update imports - Change all references to use shared version
Test across products - Verify it works in FleetOS, Robo-Hub, Robo-Dapp
Document here - Add section to this README
Example Migration:
Related Documentation
Service Contracts:
services/contracts/- TypeScript interfaces for servicesType Guards:
lib/chatTypeGuards.ts- Runtime type checkingStyle Helpers:
lib/styleHelpers.ts- Theme utilitiesShared Services:
services/shared/README.md- Backend service documentation
Last Updated: 2026-01-05 Maintained By: System Architect Component Count: 5 (Card, EmptyState, Breadcrumb, FilterBar, chatHelpers)
Last updated
Was this helpful?