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 styling

  • featured - Highlighted card with accent colors

  • stat - Card optimized for displaying statistics

  • service - Card for service listings

Sub-components:

  • CardHeader - Optional header section

  • CardFooter - 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)

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)

Returns display label for message sender.

Usage:

getSenderLabelColor(message, currentRole)

Returns color for sender label text.

getTimestampColor(message, currentRole)

Returns color for timestamp text.

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:

  1. Check for duplication - Search codebase for similar implementations

  2. Design for reuse - Make it generic, not product-specific

  3. Use TypeScript - Fully type all props and interfaces

  4. Export types - Export prop interfaces for consumers

  5. Add JSDoc comments - Document purpose and usage

  6. Use CSS variables - For theming compatibility

  7. Update this README - Add documentation and examples

  8. 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 states

  • Tooltip.tsx - Hover tooltips

  • Badge.tsx - Status badges


Migration from Product-Specific Components

If you have a product-specific component that could be shared:

  1. Extract to shared/ - Move component to this directory

  2. Generalize props - Remove product-specific assumptions

  3. Update imports - Change all references to use shared version

  4. Test across products - Verify it works in FleetOS, Robo-Hub, Robo-Dapp

  5. Document here - Add section to this README

Example Migration:


  • Service Contracts: services/contracts/ - TypeScript interfaces for services

  • Type Guards: lib/chatTypeGuards.ts - Runtime type checking

  • Style Helpers: lib/styleHelpers.ts - Theme utilities

  • Shared 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?