UI Component Library
Building secure peer-to-peer messaging apps is tough, and it's even tougher to get people to switch from what they already use. I've noticed that a great user interface and an intuitive design often matter more to people than terms like cryptography or end-to-end encryption.
That's why I've built a comprehensive UI library following atomic design principles! It provides everything needed to create modern, messaging-focused applications with React, TypeScript, and Material-UI.
Overviewโ
The UI component library is a collection of 45+ reusable React components built specifically for messaging applications. It follows atomic design principles, organizing components into atoms, molecules, organisms, and templates for maximum reusability and composability.
Key Featuresโ
- ๐งฑ Atomic Design Architecture - Components organized from simple atoms to complete page templates
- โ๏ธ React 18 & TypeScript - Modern React patterns with full type safety
- ๐จ Material-UI 5 Integration - Built on top of MUI with custom enhancements
- ๐ Theme Support - Complete dark/light mode with customizable theming
- ๐ฑ Responsive Design - Mobile-first approach with full desktop support
- โฟ Accessibility - WCAG compliant components with proper ARIA attributes
- ๐ Storybook Integration - Interactive component documentation and testing
- ๐ Module Federation - Seamless integration with other microfrontends
Tech Stackโ
{
"framework": "React 18",
"language": "TypeScript",
"ui-library": "Material-UI 5",
"styling": "Emotion (CSS-in-JS)",
"documentation": "Storybook 8",
"testing": "Jest + React Testing Library",
"build": "Webpack 5 with Module Federation"
}
Component Architectureโ
The library follows the atomic design methodology, organizing components into five distinct layers:
๐น Atoms (Basic Building Blocks)โ
The smallest, indivisible UI elements that serve as the foundation:
Core Components:
Button
,IconButton
- Action triggers with variantsInput
- Text fields with validation and password toggleCard
,CardHeader
,CardContent
,CardActions
- Container componentsDialog
,DialogTitle
,DialogContent
,DialogActions
- Modal dialogsAvatar
,AvatarGroup
,AvatarWithStatus
- User profile images with status indicatorsText
,Heading
,Body
,Label
,Caption
- Typography componentsAlert
,SuccessAlert
,ErrorAlert
,WarningAlert
- Notification componentsAccordion
,AccordionSummary
,AccordionDetails
- Expandable sectionsDropdown
,DropdownMenuItem
- Menu componentsQRCode
- QR code generator for connection sharing
Specialized Atoms:
EditorCanvas
- Fabric.js-based drawing canvasToolbarButton
- Icon buttons for toolbarsSwipeableContainer
- Touch-enabled swipe actionsParticleDissolveContainer
- Animated particle effectsOnlineIndicator
- Status dots for presenceSpeedDial
- Floating action button menu
๐ธ Molecules (Component Combinations)โ
Functional groups combining atoms into useful UI elements:
Form & Input:
MessageInput
- Rich message input with attachments, voice, and emojiAuthForm
- Complete authentication form with validationFileUpload
- Drag-and-drop file upload with previewsCommentInput
- Comment input with mentions support
Display & Navigation:
AppBar
- Application header with navigationBottomNavigationBar
- Mobile bottom navigationConversationItem
- Chat conversation previewContactList
,ContactsList
- Contact directory displaysMessage
- Individual message bubble with reactions
Media & Location:
LocationPicker
- Interactive map location selectorMapPreview
- Static map displayImageCarouselPreview
- Image slideshow with thumbnailsImageEditorPreview
- Image preview with editing toolsImageEditorToolbar
- Drawing and editing controls
Interactive:
ConnectByQRCode
- QR code scanning for P2P connectionsAvatarSelector
- Avatar selection interfaceCryptoDemo
- Encryption/decryption demonstrationOperationStatus
- Loading and status indicatorsTermsAgreement
- Terms and conditions acceptanceCommentsDialog
- Comment thread dialogCommentSection
- Complete comment system
๐ท Organisms (Complex Components)โ
Feature-complete components combining molecules and atoms:
Chat & Messaging:
Chat
- Complete chat interface with messages and inputMessageThread
- Threaded conversation viewChatList
- List of all chat conversationsConversationList
,ConversationListSidebar
- Conversation navigation
Contacts & Profile:
Contacts
- Contact management interfaceContactManager
- Full contact CRUD operationsContactDetails
- Detailed contact information viewContactsDrawer
- Side drawer with contactsProfile
- User profile displayProfileEditor
- Profile editing interfaceGroupDetails
- Group chat information
Media & Content:
ImageEditor
- Full-featured image editor with drawing toolsFileExplorer
- File browsing and managementSocialFeedList
- Social media-style feedCreatePostDrawer
- Post creation drawer
Auth & Navigation:
Login
- Authentication interfacePageContainer
- Standard page layout wrapperPageRouter
- Client-side routing container
๐ถ Templates (Complete Page Layouts)โ
Production-ready page templates combining all layers:
AuthPage
- Complete authentication pageChatPage
- Full chat application page with conversationsConversationListPage
- Chat list viewContactDetailsPage
- Contact information pageProfilePage
- User profile pageSocialFeedPage
- Social media feed pageCallsListPage
- Video/audio call historyCallPage
- Active call interfaceFilesPage
- File management pageGroupDetailsPage
- Group chat settingsMediaViewerPage
- Full-screen media viewerMainAppPage
- Main application shell with navigation
Design Systemโ
Typography Systemโ
The library provides semantic typography components:
import { Heading, Body, Label, Caption } from 'ui';
<Heading level={1}>Main Title</Heading>
<Heading level={2}>Section Title</Heading>
<Body size="lg">Large body text</Body>
<Body>Normal body text</Body>
<Label>Form labels and names</Label>
<Caption>Supplementary information</Caption>
Theme & Stylingโ
Built-in Theme Support:
import { ThemeProvider, useColorMode } from 'ui';
function App() {
return (
<ThemeProvider>
<YourComponents />
</ThemeProvider>
);
}
// In any component
function MyComponent() {
const { mode, toggleColorMode } = useColorMode();
return (
<button onClick={toggleColorMode}>
Switch to {mode === 'light' ? 'dark' : 'light'} mode
</button>
);
}
Custom Theme Colors:
- Primary: Blue tones for main actions
- Secondary: Purple tones for secondary actions
- Success: Green for confirmations
- Warning: Orange for cautions
- Error: Red for errors
- Info: Cyan for informational content
Component Enhancementsโ
The atomic components include enhancements over standard Material-UI:
Enhanced Dialog:
<Dialog open={open} onClose={handleClose}>
<DialogTitle showCloseButton onClose={handleClose}>
Title with auto close button
</DialogTitle>
<DialogContent>Content here</DialogContent>
<DialogActions>Action buttons</DialogActions>
</Dialog>
Smart Avatar with Status:
<Avatar
src={user.avatar}
status="online" // 'online' | 'offline' | 'away' | 'busy'
showStatus
size="md"
/>
Auto-Dismissible Alerts:
<SuccessAlert
open={showSuccess}
dismissible
autoHideDuration={5000}
onDismiss={() => setShowSuccess(false)}
>
Operation completed successfully!
</SuccessAlert>
Module Federation & Microfrontendsโ
The UI library is designed to work seamlessly with other microfrontends through Webpack Module Federation:
// Remote modules integrated
remotes: {
"dim": "dim@[url]/remoteEntry.js", // Functional web components
"cryptography": "cryptography@[url]/remoteEntry.js" // Encryption utilities
}
This enables:
- Runtime integration with other projects
- Independent deployment of UI components
- Shared dependencies to reduce bundle size
- Version flexibility across applications
Using Remote Componentsโ
// Import components from federated modules
import { useFS } from 'dim/hooks'; // File system hook from dim
import { encrypt } from 'cryptography/utils'; // Encryption from cryptography
function MyComponent() {
const fs = useFS({ encrypt: true });
const saveSecure = async (data) => {
const encrypted = await encrypt(data);
await fs.writeFile('secure.txt', encrypted);
};
}
Usage Examplesโ
Basic Chat Interfaceโ
import { ChatPage, ThemeProvider } from 'ui';
function App() {
return (
<ThemeProvider>
<ChatPage
conversations={conversations}
currentConversation={selectedConversation}
onSendMessage={handleSendMessage}
onSelectConversation={handleSelectConversation}
/>
</ThemeProvider>
);
}
Custom Message Inputโ
import { MessageInput } from 'ui';
function CustomChat() {
const handleSend = (message) => {
console.log('Sending:', message);
};
return (
<MessageInput
onSend={handleSend}
placeholder="Type a message..."
enableVoice
enableLocation
enableAttachments
enableEmoji
/>
);
}
Authentication Flowโ
import { AuthPage } from 'ui';
function Authentication() {
const handleSignIn = async (credentials) => {
// Your authentication logic
};
return (
<AuthPage
onSignIn={handleSignIn}
onSignUp={handleSignUp}
enableSocialAuth
providers={['google', 'github']}
/>
);
}
Development Workflowโ
Running Storybook Locallyโ
cd ui
npm install
npm start # Opens Storybook at localhost:6006
Building the Libraryโ
npm run build
# Outputs to ./Frontend directory
# - Storybook static site
# - Webpack bundle with module federation
Testing Componentsโ
npm test # Run tests once
npm run test:watch # Watch mode
npm run test:coverage # Generate coverage report
Code Qualityโ
npm run lint # Run ESLint and Prettier
npm run lint:fix # Auto-fix issues
Integration with Chat-v2โ
The UI library is designed specifically for the chat-v2 project, providing all the visual components needed for:
โ Real-time messaging with message bubbles, typing indicators, and timestamps โ Contact management with profile editing and status indicators โ Media sharing with image editor, carousel, and file uploads โ Location sharing with interactive map pickers โ Voice messages with recording and playback interfaces โ Authentication with social login and registration flows โ Dark/light themes for better user experience โ Mobile-responsive design that works on all devices
The components integrate with the P2P networking layer and encryption systems from other modules to create a complete, secure messaging application.
Interactive Demosโ
Full Component Libraryโ
Explore all components interactively: Open Storybook
Chat Page Templateโ
See the complete chat interface in action: View Chat Template
Live Application Demoโ
Experience the full Glitr application: Try Glitr Demo
Repository & Resourcesโ
- GitHub Repository: positive-intentions/ui
- Live Storybook: ui.positive-intentions.com
- NPM Package:
@positive-intentions/ui
(coming soon) - License: GPL-3.0
Quick Linksโ
- ๐ Component Documentation
- ๐จ Design System Guide
- ๐งช Interactive Demos
- ๐ง Atomic Component Migration Guide
Roadmap & Feedbackโ
This library is actively developed and evolving! Current focus areas:
- Video/Audio Calling Components - WebRTC-based call interfaces
- Notification System - Push notifications and badges
- Accessibility Improvements - Enhanced keyboard navigation and screen reader support
- Performance Optimizations - Virtualization for large lists
- Animation Library - Micro-interactions and transitions
- Testing Coverage - Comprehensive unit and integration tests
Your feedback matters! If you have suggestions, feature requests, or encounter issues, please open an issue on the GitHub repository or reach out through the project's communication channels.
Contributingโ
Contributions are welcome! The component library follows these principles:
- Atomic Design - Place components in the correct layer (atom/molecule/organism/template)
- TypeScript First - All components must have proper type definitions
- Accessibility - Include proper ARIA labels and keyboard navigation
- Storybook Stories - Every component needs interactive stories
- Testing - Unit tests for all new functionality
- Documentation - Clear prop descriptions and usage examples
Check the repository's CONTRIBUTING.md for detailed guidelines.