This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Premium React Loaders is a TypeScript library providing 50+ production-ready loading components for React. The library is published to npm and uses Vite for building, with Storybook for documentation and demos hosted on Firebase.
npm run build # Build library (TypeScript check + Vite build)
npm run build:watch # Build in watch mode
npm run type-check # Run TypeScript compiler without emitting files
npm run dev # Start Vite dev servernpm run storybook # Start Storybook dev server on port 6006
npm run build-storybook # Build static Storybook for deployment
npm run preview-storybook # Preview built Storybook locally
npm run deploy:storybook # Build and deploy to Firebase Hostingnpm run demo # Start demo app dev server on port 3000
npm run demo:build # Build demo app for production
npm run demo:preview # Preview built demo app locally
npm run demo:deploy # Build and deploy demo app to Firebase
npm run deploy:all # Build and deploy both Storybook and demo appNote: The demo app is located in the demo/ directory and can also be run directly:
cd demo
npm install # Install demo dependencies (first time only)
npm run dev # Start dev server
npm run build # Build for productionnpm run prepublishOnly # Runs automatically before npm publish (builds library)The library is organized into 15 main component categories, each in its own directory under src/components/:
-
Skeleton (
src/components/skeleton/) - 9 components for placeholder content- Base
Skeleton,SkeletonText,SkeletonAvatar,SkeletonImage,SkeletonCard,SkeletonForm,SkeletonList,SkeletonTable,SkeletonPage SkeletonPageprovides pre-built full page layouts (default, dashboard, article, profile)
- Base
-
Spinner (
src/components/spinner/) - 7 rotating/animated spinnersSpinnerCircle,SpinnerRing,SpinnerDots,SpinnerBars,SpinnerGrid,SpinnerWave,SpinnerPulse
-
Progress (
src/components/progress/) - 4 progress indicatorsProgressBar,ProgressCircle,ProgressRing,ProgressSteps- Support both determinate (value-based) and indeterminate modes
-
Pulse (
src/components/pulse/) - 4 pulsing/bouncing loadersPulseDots,PulseWave,PulseBars,TypingIndicator
-
Overlay (
src/components/overlay/) - 1 wrapper componentLoaderOverlay- Displays loaders over content with backdrop (full-screen or container-relative)
-
Button (
src/components/button/) - 1 button loading component (v2.2.0+)ButtonSpinner- Compact spinner for button loading states with multiple variants (circle, dots, bars) and positioning options
-
Status (
src/components/status/) - 2 status indicator components (v2.2.0+)SuccessCheckmark- Animated checkmark for successful operations with optional circle backgroundErrorIndicator- Animated error indicator with X mark and optional shake effect
-
Transition (
src/components/transition/) - 1 transition component (v2.3.0+)LoaderTransition- Smooth transitions between loading and loaded states with multiple animation types (fade, slide-up, slide-down, slide-left, slide-right, scale)
-
Shimmer (
src/components/shimmer/) - 3 shimmer components (v3.0.0+)ShimmerBox- Shimmer container with directional animationShimmerText- Multi-line text shimmer placeholderShimmerButton- Button placeholder with shimmer effect
-
Orbit (
src/components/orbit/) - 3 orbital animations (v3.0.0+)OrbitDots- Dots orbiting around a central pointOrbitRings- Concentric rotating ringsAtomLoader- Electron-like orbital animation with nucleus
-
Bounce (
src/components/bounce/) - 2 bouncing loaders (v3.0.0+)BouncingDots- Dots with physics-based bounce animationBouncingBalls- 3D bouncing balls with shadow and squash effects
-
Infinity (
src/components/infinity/) - 2 infinity loaders (v3.0.0+)InfinityLoader- Figure-8 infinity symbol animationMobiusLoader- Segmented ribbon loop with twist effect
-
Text (
src/components/text/) - 1 text loader (v3.0.0+)LoadingText- Animated loading text with multiple animation styles
-
3D (
src/components/3d/) - 5 immersive 3D loaders (v3.1.0+)CubeSpinner- Rotating 3D cube with customizable faces and rotation axes (x, y, z, diagonal)FlipCard- 3D card flip animation with horizontal/vertical modesPlaneRotate- Multiple rotating planes in 3D spaceHelix- DNA-like spiral animation with particlesPerspectiveRing- 3D ring with tilt and shadow effects
-
Smart (
src/components/smart/) - 3 intelligent components (v3.1.0+)FormFieldLoader- Loading states for form inputs (text, select, checkbox, radio, textarea, file)
-
Accessibility (
src/components/accessibility/) - 1 accessibility component (v3.1.0+)LiveRegion- ARIA live region for screen reader announcements
Note: SmartSkeleton and DataTableSkeleton are part of the Skeleton category (src/components/skeleton/) but added in v3.1.0.
The library provides 6 hooks for loading state management in src/hooks/:
- useLoader (v2.1.0+) - Basic loading state with delay, minDuration, and autoHide
- useEnhancedLoader (v2.3.0+) - Advanced loading with retry logic, success/error states, and history
- useLoadingOrchestrator (v3.1.0+) - Manage multiple loading tasks with dependencies
- useLoadingAnalytics (v3.1.0+) - Track loading performance metrics
- useSmartLoader (v3.1.0+) - Intelligent loader with connection detection and progress estimation
- useTheme (v2.1.0+) - Access global theme configuration
All components follow a hierarchical export pattern:
- Category index files (
src/components/[category]/index.ts) export all components in that category - Main component index (
src/components/index.ts) re-exports all category exports - Root index (
src/index.ts) re-exports components and types, imports global CSS
TypeScript types are centralized in src/types/:
common.ts- Base interfaces (BaseLoaderProps,SkeletonBaseProps,ProgressLoaderProps)- Category-specific type files extend base props with component-specific options
- All types are re-exported through
src/types/index.ts
All loader components extend BaseLoaderProps which includes common props:
size,color,secondaryColorclassName,stylefor customizationariaLabel,testIdfor accessibility/testingvisible,speedfor behavior control
The library uses Vite in library mode with specific optimizations:
- Dual format output: ESM (
index.js) and CJS (index.cjs) - Tree-shaking enabled:
preserveModules: truein Rollup options maintains the source structure - Type generation:
vite-plugin-dtsgenerates.d.tsfiles - Path alias:
@/*maps tosrc/*(configured in bothvite.config.tsandtsconfig.json) - External dependencies: React, React-DOM are marked external (peer dependencies)
- No minification: Consumers handle minification to preserve debugging
- Tailwind CSS for utility classes (users must have Tailwind installed)
- CSS animations in
src/styles/animations.cssusing hardware-accelerated transforms - Global styles imported via
src/styles/index.css(auto-imported by root index) - Components use
cn()utility (fromsrc/utils/classNames.ts) to merge class names usingclsx - CSS variables for theming (e.g.,
--loader-primary,--skeleton-base)
Stories are in the stories/ directory (separate from src/), organized by component category. Storybook uses the same Vite configuration through @storybook/react-vite adapter.
- All components are functional components using TypeScript
- Props destructuring with default values where appropriate
- Conditional rendering based on
visibleprop - CSS-only animations - no JavaScript animation loops for performance
- Accessibility: ARIA labels and semantic HTML
cn()- Class name merger usingclsx(notailwind-mergeto keep bundle small)getAnimationDuration()- Converts speed prop to millisecondsnormalizeSize()- Converts size prop to CSS values
Components support a testId prop for test targeting. When provided, it's applied as data-testid.
- Peer dependencies: React 18+/19+ and Tailwind CSS 3.4+ are required but not bundled
- No runtime dependencies: Only
clsxis used internally - Tree-shakeable: Users can import individual components without bundling unused code
- TypeScript strict mode: All code must pass strict type checking
- CSS must be imported: Users must import
'premium-react-loaders/styles'in their app - Tailwind content path: Users must add library path to their Tailwind config content array
Both Storybook and the demo app are deployed to Firebase Hosting using two separate Firebase projects:
-
Storybook: https://docs.premium-react-loaders.ishansasika.dev/ (component documentation)
- Firebase project:
premium-react-loaders - Configuration: Root
firebase.jsonand.firebaserc - Build output:
storybook-static/
- Firebase project:
-
Demo App: https://premium-react-loaders.ishansasika.dev/ (interactive playground)
- Firebase project:
premium-react-loaders-demo - Configuration:
demo/firebase.jsonanddemo/.firebaserc - Build output:
demo/dist/
- Firebase project:
Automated deployments are configured via .github/workflows/deploy.yml:
- Triggers on push to
mainbranch - Builds both Storybook and demo app
- Deploys both to their respective Firebase projects
Required Secrets: Two GitHub repository secrets must be configured:
FIREBASE_SERVICE_ACCOUNT_PREMIUM_REACT_LOADERS(for Storybook)FIREBASE_SERVICE_ACCOUNT_PREMIUM_REACT_LOADERS_DEMO(for demo app)
See .github/workflows/README.md for detailed setup instructions.
The demo/ directory contains a standalone React + Vite application that showcases all 40 library components:
Key Features:
- Interactive playground with live prop controls (similar to Storybook)
- Component gallery with all 40 components
- Documentation pages
- Code generation with copy-to-clipboard
- Background theme switcher (light/dark/gray)
Technology Stack:
- React 19 + TypeScript
- Vite for build tooling
- React Router for navigation
- Tailwind CSS for styling
- prism-react-renderer for syntax highlighting
Structure:
src/components/- UI components (layout, playground, controls, common)src/pages/- Route pages (Home, Playground, Gallery, Documentation)src/data/- Component metadata and examplessrc/hooks/- React hooks (useTheme, useClipboard, useLocalStorage)src/utils/- Utility functions (code generation, formatters)
Component Metadata: All 40 components are defined in demo/src/data/components.ts with:
- Default props
- Prop definitions with control types (range, color, select, boolean, text)
- Usage examples
- Import paths
Library Import: The demo app imports components directly from ../src via Vite alias @lib for development mode.