-
Notifications
You must be signed in to change notification settings - Fork 0
Loading States Guide
Complete implementation of loading states and skeleton screens for nself-chat.
| File | Purpose | Status |
|---|---|---|
skeleton.tsx |
Base skeleton components | β Existing |
spinner.tsx |
Loading spinners | β Existing |
message-skeleton.tsx |
Message list skeletons | β Existing |
channel-skeleton.tsx |
Channel list skeletons | β Existing |
profile-skeleton.tsx |
Profile skeletons | β Existing |
user-skeleton.tsx |
User skeletons | β Existing |
chat-skeleton.tsx |
Chat interface skeletons | β Existing |
sidebar-skeleton.tsx |
Sidebar skeletons | β Existing |
search-skeleton.tsx |
Search result skeletons | β Existing |
settings-skeleton.tsx |
Settings page skeletons | β Existing |
app-loader.tsx |
App-level loading | β Existing |
button-loading.tsx |
Button loading states | β Existing |
loading-overlay.tsx |
Loading overlays | β Existing |
suspense-wrapper.tsx |
Suspense boundaries | β Existing |
infinite-scroll-loader.tsx |
Infinite scroll | β Existing |
progress-bar.tsx |
Progress indicators | β New |
loading-state.tsx |
State management | β New |
examples.tsx |
Usage examples | β New |
index.ts |
Component exports | β Updated |
README.md |
Documentation | β New |
| File | Purpose | Status |
|---|---|---|
suspense-helper.ts |
Suspense utilities | β New |
optimistic-updates.ts |
Optimistic UI helpers | β New |
loading-text.ts |
Loading text constants | β New |
index.ts |
Library exports | β New |
- Message list skeleton
- Channel list skeleton
- User profile skeleton
- Settings skeleton
- Search results skeleton
- Matches content shape for smooth transitions
- Inline spinner (for buttons)
- Full-page spinner
- Button spinner
- Progress bar (linear & circular)
- Shimmer effect
- Step progress indicator
- Suspense boundaries
- Lazy loading with retry
- Incremental loading
- Optimistic updates
- Resource caching
- Initial page load
- Data fetching
- Infinite scroll
- File uploads
- Form submissions
- Search queries
- Linear progress bars
- Circular progress
- Step indicators
- Upload progress with file info
- Indeterminate progress
- LoadingState component
- DataWrapper (single items)
- ListWrapper (arrays)
- Empty states
- Error states with retry
- useOptimistic hook
- useOptimisticList hook
- withOptimisticUpdate utility
- OptimisticMessageSender
- Retry mechanism
- Type-safe lazy loading
- Named export lazy loading
- Retry with exponential backoff
- Resource creation
- Resource caching
- Suspense-compatible fetching
import { Spinner } from '@/components/loading'
;<Spinner size="md" text="Loading..." />import { MessageSkeleton } from '@/components/loading'
;<MessageSkeleton count={5} showAvatar />import { LoadingButton } from '@/components/loading'
;<LoadingButton isLoading={isSubmitting} loadingText="Saving...">
Save
</LoadingButton>import { ProgressBar } from '@/components/loading'
;<ProgressBar value={progress} showPercentage variant="gradient" />import { DataWrapper } from '@/components/loading'
;<DataWrapper data={user} isLoading={isLoading} error={error} loadingSkeleton={<ProfileSkeleton />}>
{(user) => <UserProfile user={user} />}
</DataWrapper>import { useOptimisticList } from '@/lib/loading'
const { list, addOptimistic, confirmUpdate, isPending } = useOptimisticList(initialMessages)
// Add optimistically
addOptimistic(newMessage)
// Confirm when API succeeds
confirmUpdate(messageId)import {
LOADING_TEXT,
CHAT_LOADING_TEXT,
SUCCESS_TEXT,
ERROR_TEXT,
} from '@/lib/loading'
// Use standard messages
<Spinner text={CHAT_LOADING_TEXT.LOADING_MESSAGES} />
<Spinner text={LOADING_TEXT.UPLOADING} />- Match skeleton shape to actual content
- Provide specific loading messages
- Show progress for long operations
- Handle errors with retry options
- Use optimistic updates for instant feedback
- Ensure accessibility (aria-labels, roles)
- Use generic "Loading..." everywhere
- Show spinners without context
- Block entire UI for small operations
- Forget error states
- Re-mount components unnecessarily
All loading components include:
- ARIA labels
- Role attributes
- Screen reader announcements
- Keyboard navigation support
- Focus management
Optimizations included:
- Lazy loading components
- Suspense boundaries
- Skeleton transitions
- Optimistic updates
- Resource caching
- Retry mechanisms
Example test:
import { render, screen } from '@testing-library/react'
import { MessageSkeleton } from '@/components/loading'
test('renders skeleton', () => {
render(<MessageSkeleton count={3} />)
expect(screen.getAllByRole('status')).toHaveLength(3)
})All loading states respect:
prefers-reduced-motion- Accessibility settings
- Custom animation durations
- Smooth transitions
Full documentation: /src/components/loading/README.md
Examples: /src/components/loading/examples.tsx
All components and utilities are fully typed with TypeScript generics where appropriate.
- Modern browsers (Chrome, Firefox, Safari, Edge)
- IE11 not supported (uses modern CSS animations)
- Mobile browsers (iOS Safari, Chrome Mobile)
- Progressive enhancement for older browsers
The loading states implementation is COMPLETE and PRODUCTION-READY with:
β 20 component files β 4 utility libraries β Complete documentation β 10 working examples β Full TypeScript support β Accessibility compliance β Performance optimizations β Comprehensive loading patterns β Optimistic update system β Suspense integration
All requested features have been implemented with production-quality code, proper error handling, accessibility support, and comprehensive documentation.
nself-chat v0.3.0 | GitHub | Issues | Discussions | Demo
Edit this page | MIT License | Β© 2026
(See π Security section below for 2FA, PIN Lock, and security audits.)
(Search lives in π Reference below.)
- π¬ Advanced Messaging
- π E2EE Setup
- π Search Setup
- π Call Management
- πΊ Live Streaming
- π₯οΈ Screen Sharing
- πΉ Video Calling
- ποΈ Voice Calling
- π± Mobile Optimization
- π§ͺ Testing
- π i18n
- π API Overview
- π Complete Reference
- π» API Examples
- π€ Bot API
- π Auth API
- π GraphQL Schema
- π Deployment Overview
- π³ Docker
- βΈοΈ Kubernetes
- β Helm Charts
- β Production Checklist
- π Production Validation
- π’ Multi-Tenant
- ποΈ Architecture
- π Diagrams
- ποΈ Database Schema
- π Project Structure
- π TypeScript Types
- π SPORT Reference
- π 2FA
- π¬ Messaging
- π Call Management
- π Call State Machine
- π E2EE
- πΊ Live Streaming
- π± Mobile Calls
- π PIN Lock
- π Polls
- π₯οΈ Screen Sharing
- π Search
- π Social Media
- ποΈ Voice Calling
- π Security Overview
- π‘οΈ Security Audit
- β‘ Performance
- π Best Practices
- π 2FA
- π PIN Lock
- π E2EE
- π‘οΈ E2EE Audit
v1.0.0 β’ 2026