premium-react-loaders 1.3.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +264 -30
- package/dist/components/pulse/TypingIndicator.d.ts.map +1 -1
- package/dist/context/ThemeContext.d.ts +84 -0
- package/dist/context/ThemeContext.d.ts.map +1 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useLoader.d.ts +56 -0
- package/dist/hooks/useLoader.d.ts.map +1 -0
- package/dist/index.cjs +31 -27
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -27
- package/dist/index10.cjs +20 -32
- package/dist/index10.js +20 -32
- package/dist/index11.cjs +47 -26
- package/dist/index11.js +47 -26
- package/dist/index12.cjs +30 -127
- package/dist/index12.js +31 -128
- package/dist/index13.cjs +30 -54
- package/dist/index13.js +30 -54
- package/dist/index14.cjs +127 -44
- package/dist/index14.js +128 -45
- package/dist/index15.cjs +58 -38
- package/dist/index15.js +59 -39
- package/dist/index16.cjs +24 -37
- package/dist/index16.js +24 -37
- package/dist/index17.cjs +19 -22
- package/dist/index17.js +19 -22
- package/dist/index18.cjs +25 -21
- package/dist/index18.js +25 -21
- package/dist/index19.cjs +22 -33
- package/dist/index19.js +22 -33
- package/dist/index20.cjs +26 -36
- package/dist/index20.js +28 -38
- package/dist/index21.cjs +40 -77
- package/dist/index21.js +42 -79
- package/dist/index22.cjs +53 -103
- package/dist/index22.js +54 -104
- package/dist/index23.cjs +46 -81
- package/dist/index23.js +47 -82
- package/dist/index24.cjs +105 -104
- package/dist/index24.js +107 -106
- package/dist/index25.cjs +108 -28
- package/dist/index25.js +111 -31
- package/dist/index26.cjs +104 -37
- package/dist/index26.js +106 -39
- package/dist/index27.cjs +22 -31
- package/dist/index27.js +23 -32
- package/dist/index28.cjs +30 -30
- package/dist/index28.js +31 -31
- package/dist/index29.cjs +49 -53
- package/dist/index29.js +50 -54
- package/dist/index3.cjs +11 -3
- package/dist/index3.js +11 -3
- package/dist/index30.cjs +77 -17
- package/dist/index30.js +76 -16
- package/dist/index31.cjs +77 -121
- package/dist/index31.js +78 -122
- package/dist/index32.cjs +125 -0
- package/dist/index32.js +125 -0
- package/dist/index4.cjs +0 -1
- package/dist/index4.js +0 -1
- package/dist/index5.cjs +11 -73
- package/dist/index5.js +12 -74
- package/dist/index6.cjs +86 -66
- package/dist/index6.js +87 -67
- package/dist/index7.cjs +40 -21
- package/dist/index7.js +40 -21
- package/dist/index8.cjs +34 -22
- package/dist/index8.js +34 -22
- package/dist/index9.cjs +21 -56
- package/dist/index9.js +22 -57
- package/dist/premium-react-loaders.css +250 -1073
- package/dist/utils/classNames.d.ts +3 -2
- package/dist/utils/classNames.d.ts.map +1 -1
- package/package.json +5 -8
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index10.cjs.map +0 -1
- package/dist/index10.js.map +0 -1
- package/dist/index11.cjs.map +0 -1
- package/dist/index11.js.map +0 -1
- package/dist/index12.cjs.map +0 -1
- package/dist/index12.js.map +0 -1
- package/dist/index13.cjs.map +0 -1
- package/dist/index13.js.map +0 -1
- package/dist/index14.cjs.map +0 -1
- package/dist/index14.js.map +0 -1
- package/dist/index15.cjs.map +0 -1
- package/dist/index15.js.map +0 -1
- package/dist/index16.cjs.map +0 -1
- package/dist/index16.js.map +0 -1
- package/dist/index17.cjs.map +0 -1
- package/dist/index17.js.map +0 -1
- package/dist/index18.cjs.map +0 -1
- package/dist/index18.js.map +0 -1
- package/dist/index19.cjs.map +0 -1
- package/dist/index19.js.map +0 -1
- package/dist/index20.cjs.map +0 -1
- package/dist/index20.js.map +0 -1
- package/dist/index21.cjs.map +0 -1
- package/dist/index21.js.map +0 -1
- package/dist/index22.cjs.map +0 -1
- package/dist/index22.js.map +0 -1
- package/dist/index23.cjs.map +0 -1
- package/dist/index23.js.map +0 -1
- package/dist/index24.cjs.map +0 -1
- package/dist/index24.js.map +0 -1
- package/dist/index25.cjs.map +0 -1
- package/dist/index25.js.map +0 -1
- package/dist/index26.cjs.map +0 -1
- package/dist/index26.js.map +0 -1
- package/dist/index27.cjs.map +0 -1
- package/dist/index27.js.map +0 -1
- package/dist/index28.cjs.map +0 -1
- package/dist/index28.js.map +0 -1
- package/dist/index29.cjs.map +0 -1
- package/dist/index29.js.map +0 -1
- package/dist/index3.cjs.map +0 -1
- package/dist/index3.js.map +0 -1
- package/dist/index30.cjs.map +0 -1
- package/dist/index30.js.map +0 -1
- package/dist/index31.cjs.map +0 -1
- package/dist/index31.js.map +0 -1
- package/dist/index4.cjs.map +0 -1
- package/dist/index4.js.map +0 -1
- package/dist/index5.cjs.map +0 -1
- package/dist/index5.js.map +0 -1
- package/dist/index6.cjs.map +0 -1
- package/dist/index6.js.map +0 -1
- package/dist/index7.cjs.map +0 -1
- package/dist/index7.js.map +0 -1
- package/dist/index8.cjs.map +0 -1
- package/dist/index8.js.map +0 -1
- package/dist/index9.cjs.map +0 -1
- package/dist/index9.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Premium React Loaders
|
|
2
2
|
|
|
3
|
-
A comprehensive collection of **25 premium, production-ready loading components** for React applications. Built with TypeScript and
|
|
3
|
+
A comprehensive collection of **25 premium, production-ready loading components** for React applications. Built with TypeScript and custom CSS for maximum flexibility and zero configuration.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/premium-react-loaders)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -16,16 +16,20 @@ See all 25 components in action with interactive examples and customization opti
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
18
|
- **25 Premium Components** across 5 categories (Skeleton, Spinner, Progress, Pulse, Overlay)
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
19
|
+
- **Global Theming** - ThemeProvider for app-wide customization ✨ *New in v2.1.0*
|
|
20
|
+
- **Smart Loading UX** - useLoader hook with delay, minDuration, and autoHide ✨ *New in v2.1.0*
|
|
21
|
+
- **Enhanced CSS Variables** - Comprehensive theming with dark mode support ✨ *New in v2.1.0*
|
|
22
|
+
- **Zero Configuration** - No Tailwind or build setup required ✨ *New in v2.0.0*
|
|
23
|
+
- **Tiny Bundle Size** - 70% smaller CSS (6.27 KB → 1.64 KB gzipped) ✨ *New in v2.0.0*
|
|
24
|
+
- **Zero Runtime Dependencies** - No external dependencies needed ✨ *New in v2.0.0*
|
|
25
|
+
- **Size Presets** - Easy sizing with `xs`, `sm`, `md`, `lg`, `xl` presets
|
|
26
|
+
- **Reduced Motion Support** - Respects `prefers-reduced-motion` for accessibility
|
|
27
|
+
- **Animation Direction Control** - Reverse animations with `reverse` prop
|
|
22
28
|
- **Full TypeScript Support** with exported type definitions
|
|
23
|
-
- **Tailwind CSS Integration** for easy customization
|
|
24
29
|
- **Tree-shakeable** - only bundle what you use
|
|
25
30
|
- **Accessible** - built with ARIA labels and best practices
|
|
26
31
|
- **Performant** - hardware-accelerated CSS animations (60fps)
|
|
27
32
|
- **Customizable** - multiple ways to style components
|
|
28
|
-
- **Zero Dependencies** (except peer dependencies)
|
|
29
33
|
|
|
30
34
|
## Installation
|
|
31
35
|
|
|
@@ -35,15 +39,15 @@ npm install premium-react-loaders
|
|
|
35
39
|
|
|
36
40
|
### Peer Dependencies
|
|
37
41
|
|
|
38
|
-
This library requires React
|
|
42
|
+
This library only requires React:
|
|
39
43
|
|
|
40
44
|
```bash
|
|
41
|
-
npm install react react-dom
|
|
45
|
+
npm install react react-dom
|
|
42
46
|
```
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
> **Note:** v2.0.0+ no longer requires Tailwind CSS! See [Migration Guide](#migrating-from-v1x-to-v20) below.
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
## Setup
|
|
47
51
|
|
|
48
52
|
Import the styles in your main entry file (e.g., `main.tsx` or `App.tsx`):
|
|
49
53
|
|
|
@@ -51,18 +55,29 @@ Import the styles in your main entry file (e.g., `main.tsx` or `App.tsx`):
|
|
|
51
55
|
import 'premium-react-loaders/styles';
|
|
52
56
|
```
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
That's it! No Tailwind configuration or additional setup needed.
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
### Optional: Global Theming (v2.1.0+)
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
Wrap your app with `ThemeProvider` to customize all loaders globally:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { ThemeProvider } from 'premium-react-loaders';
|
|
66
|
+
|
|
67
|
+
function App() {
|
|
68
|
+
return (
|
|
69
|
+
<ThemeProvider
|
|
70
|
+
theme={{
|
|
71
|
+
primaryColor: '#8b5cf6',
|
|
72
|
+
secondaryColor: '#ec4899',
|
|
73
|
+
defaultSize: 'lg',
|
|
74
|
+
defaultSpeed: 'fast',
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
<YourApp />
|
|
78
|
+
</ThemeProvider>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
66
81
|
```
|
|
67
82
|
|
|
68
83
|
## Quick Start
|
|
@@ -100,7 +115,7 @@ function App() {
|
|
|
100
115
|
|
|
101
116
|
## Component Categories
|
|
102
117
|
|
|
103
|
-
### Skeleton Loaders (
|
|
118
|
+
### Skeleton Loaders (9 components)
|
|
104
119
|
|
|
105
120
|
Placeholder components that mimic content layout while loading:
|
|
106
121
|
|
|
@@ -109,11 +124,12 @@ Placeholder components that mimic content layout while loading:
|
|
|
109
124
|
- **SkeletonAvatar** - Avatar placeholder (circle/square)
|
|
110
125
|
- **SkeletonImage** - Image placeholder with aspect ratio
|
|
111
126
|
- **SkeletonCard** - Card layout with avatar + text
|
|
127
|
+
- **SkeletonForm** - Form skeleton with inputs and labels
|
|
112
128
|
- **SkeletonList** - List of skeleton items
|
|
113
129
|
- **SkeletonTable** - Table skeleton with rows/columns
|
|
114
130
|
- **SkeletonPage** - Pre-built full page layouts (default, dashboard, article, profile)
|
|
115
131
|
|
|
116
|
-
### Spinner Loaders (
|
|
132
|
+
### Spinner Loaders (7 components)
|
|
117
133
|
|
|
118
134
|
Rotating and animated spinners:
|
|
119
135
|
|
|
@@ -122,22 +138,26 @@ Rotating and animated spinners:
|
|
|
122
138
|
- **SpinnerDots** - Multiple dots rotating around center
|
|
123
139
|
- **SpinnerBars** - Vertical bars with wave animation
|
|
124
140
|
- **SpinnerGrid** - Grid of fading squares
|
|
141
|
+
- **SpinnerPulse** - Pulsing circle spinner
|
|
142
|
+
- **SpinnerWave** - Wave pattern spinner
|
|
125
143
|
|
|
126
|
-
### Progress Loaders (
|
|
144
|
+
### Progress Loaders (4 components)
|
|
127
145
|
|
|
128
146
|
Progress indicators (determinate/indeterminate):
|
|
129
147
|
|
|
130
148
|
- **ProgressBar** - Linear horizontal progress bar
|
|
131
149
|
- **ProgressCircle** - Circular progress indicator
|
|
132
150
|
- **ProgressRing** - Ring progress with gradient option
|
|
151
|
+
- **ProgressSteps** - Multi-step progress indicator
|
|
133
152
|
|
|
134
|
-
### Pulse Loaders (
|
|
153
|
+
### Pulse Loaders (4 components)
|
|
135
154
|
|
|
136
155
|
Bouncing, pulsing, wave animations:
|
|
137
156
|
|
|
138
157
|
- **PulseDots** - Bouncing dots in sequence
|
|
139
158
|
- **PulseWave** - Wave pattern bars
|
|
140
159
|
- **PulseBars** - Equalizer-style pulsing bars
|
|
160
|
+
- **TypingIndicator** - Typing animation indicator
|
|
141
161
|
|
|
142
162
|
### Overlay Components (1 component)
|
|
143
163
|
|
|
@@ -317,16 +337,111 @@ import { SpinnerCircle, ProgressBar, PulseDots } from 'premium-react-loaders';
|
|
|
317
337
|
<PulseDots size="md" reverse />
|
|
318
338
|
```
|
|
319
339
|
|
|
340
|
+
### New in v2.1.0
|
|
341
|
+
|
|
342
|
+
**Global Theming** - Customize all loaders from one place:
|
|
343
|
+
|
|
344
|
+
```tsx
|
|
345
|
+
import { ThemeProvider } from 'premium-react-loaders';
|
|
346
|
+
|
|
347
|
+
function App() {
|
|
348
|
+
return (
|
|
349
|
+
<ThemeProvider
|
|
350
|
+
theme={{
|
|
351
|
+
primaryColor: '#8b5cf6',
|
|
352
|
+
secondaryColor: '#ec4899',
|
|
353
|
+
skeletonBase: '#e2e8f0',
|
|
354
|
+
skeletonHighlight: '#f1f5f9',
|
|
355
|
+
defaultSize: 'lg',
|
|
356
|
+
defaultSpeed: 'fast',
|
|
357
|
+
defaultDelay: 200,
|
|
358
|
+
defaultMinDuration: 600,
|
|
359
|
+
respectMotionPreference: true,
|
|
360
|
+
}}
|
|
361
|
+
>
|
|
362
|
+
{/* All loaders inherit these settings */}
|
|
363
|
+
<SpinnerCircle /> {/* Uses theme colors and size */}
|
|
364
|
+
<Skeleton /> {/* Uses theme skeleton colors */}
|
|
365
|
+
</ThemeProvider>
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Smart Loading State Management** - Better UX with the `useLoader` hook:
|
|
371
|
+
|
|
372
|
+
```tsx
|
|
373
|
+
import { useLoader } from 'premium-react-loaders';
|
|
374
|
+
import { SpinnerCircle } from 'premium-react-loaders';
|
|
375
|
+
|
|
376
|
+
function MyComponent() {
|
|
377
|
+
const { loading, startLoading, stopLoading, isVisible } = useLoader({
|
|
378
|
+
delay: 200, // Don't show loader for quick operations (<200ms)
|
|
379
|
+
minDuration: 600, // Show loader for at least 600ms to avoid flashing
|
|
380
|
+
autoHide: 5000, // Auto-hide after 5 seconds (optional)
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
const fetchData = async () => {
|
|
384
|
+
startLoading();
|
|
385
|
+
try {
|
|
386
|
+
await api.fetchData();
|
|
387
|
+
} finally {
|
|
388
|
+
stopLoading();
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
return (
|
|
393
|
+
<div>
|
|
394
|
+
<button onClick={fetchData}>Load Data</button>
|
|
395
|
+
<SpinnerCircle visible={isVisible} />
|
|
396
|
+
</div>
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
**Enhanced CSS Variables** - More control with comprehensive theming:
|
|
402
|
+
|
|
403
|
+
```css
|
|
404
|
+
:root {
|
|
405
|
+
/* Colors */
|
|
406
|
+
--loader-primary: #3b82f6;
|
|
407
|
+
--loader-secondary: #8b5cf6;
|
|
408
|
+
--skeleton-base: #e5e7eb;
|
|
409
|
+
--skeleton-highlight: #f5f5f5;
|
|
410
|
+
|
|
411
|
+
/* Sizes */
|
|
412
|
+
--loader-size-xs: 16px;
|
|
413
|
+
--loader-size-sm: 24px;
|
|
414
|
+
--loader-size-md: 40px;
|
|
415
|
+
--loader-size-lg: 56px;
|
|
416
|
+
--loader-size-xl: 72px;
|
|
417
|
+
|
|
418
|
+
/* Animation */
|
|
419
|
+
--loader-transition-fast: 150ms;
|
|
420
|
+
--loader-transition-normal: 300ms;
|
|
421
|
+
--loader-transition-slow: 500ms;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/* Dark mode support */
|
|
425
|
+
@media (prefers-color-scheme: dark) {
|
|
426
|
+
:root {
|
|
427
|
+
--skeleton-base: #2d3748;
|
|
428
|
+
--skeleton-highlight: #4a5568;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
**Improved TypingIndicator** - Smoother animations with dynamic timing that scales with speed settings.
|
|
434
|
+
|
|
320
435
|
## Customization
|
|
321
436
|
|
|
322
437
|
All components support multiple customization methods:
|
|
323
438
|
|
|
324
439
|
### 1. className Prop
|
|
325
440
|
|
|
326
|
-
Pass
|
|
441
|
+
Pass custom CSS classes:
|
|
327
442
|
|
|
328
443
|
```tsx
|
|
329
|
-
<SpinnerCircle size={40} className="my-
|
|
444
|
+
<SpinnerCircle size={40} className="my-spinner" />
|
|
330
445
|
```
|
|
331
446
|
|
|
332
447
|
### 2. style Prop
|
|
@@ -345,16 +460,77 @@ Direct color control:
|
|
|
345
460
|
<SpinnerCircle color="#8b5cf6" secondaryColor="#e0e0e0" />
|
|
346
461
|
```
|
|
347
462
|
|
|
348
|
-
### 4. CSS Variables
|
|
463
|
+
### 4. CSS Variables (Enhanced in v2.1.0)
|
|
349
464
|
|
|
350
|
-
Override theme variables globally:
|
|
465
|
+
Override theme variables globally for comprehensive customization:
|
|
351
466
|
|
|
352
467
|
```css
|
|
353
468
|
:root {
|
|
469
|
+
/* Primary colors */
|
|
354
470
|
--loader-primary: #3b82f6;
|
|
355
471
|
--loader-secondary: #8b5cf6;
|
|
356
|
-
|
|
472
|
+
|
|
473
|
+
/* Skeleton colors */
|
|
474
|
+
--skeleton-base: #e5e7eb;
|
|
357
475
|
--skeleton-highlight: #f5f5f5;
|
|
476
|
+
|
|
477
|
+
/* Size presets */
|
|
478
|
+
--loader-size-xs: 16px;
|
|
479
|
+
--loader-size-sm: 24px;
|
|
480
|
+
--loader-size-md: 40px;
|
|
481
|
+
--loader-size-lg: 56px;
|
|
482
|
+
--loader-size-xl: 72px;
|
|
483
|
+
|
|
484
|
+
/* Spacing and layout */
|
|
485
|
+
--loader-gap: 0.5rem;
|
|
486
|
+
--loader-radius-sm: 0.25rem;
|
|
487
|
+
--loader-radius-md: 0.5rem;
|
|
488
|
+
--loader-radius-lg: 1rem;
|
|
489
|
+
--loader-radius-full: 9999px;
|
|
490
|
+
|
|
491
|
+
/* Animation speeds */
|
|
492
|
+
--loader-transition-fast: 150ms;
|
|
493
|
+
--loader-transition-normal: 300ms;
|
|
494
|
+
--loader-transition-slow: 500ms;
|
|
495
|
+
|
|
496
|
+
/* Overlay */
|
|
497
|
+
--loader-overlay-backdrop: rgba(0, 0, 0, 0.5);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/* Dark mode support */
|
|
501
|
+
@media (prefers-color-scheme: dark) {
|
|
502
|
+
:root {
|
|
503
|
+
--skeleton-base: #2d3748;
|
|
504
|
+
--skeleton-highlight: #4a5568;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
### 5. ThemeProvider (v2.1.0+)
|
|
510
|
+
|
|
511
|
+
Use the `ThemeProvider` component for runtime theming:
|
|
512
|
+
|
|
513
|
+
```tsx
|
|
514
|
+
import { ThemeProvider, useTheme } from 'premium-react-loaders';
|
|
515
|
+
|
|
516
|
+
function App() {
|
|
517
|
+
return (
|
|
518
|
+
<ThemeProvider
|
|
519
|
+
theme={{
|
|
520
|
+
primaryColor: '#8b5cf6',
|
|
521
|
+
secondaryColor: '#ec4899',
|
|
522
|
+
defaultSize: 'lg',
|
|
523
|
+
}}
|
|
524
|
+
>
|
|
525
|
+
<YourComponents />
|
|
526
|
+
</ThemeProvider>
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// Access theme in child components
|
|
531
|
+
function ChildComponent() {
|
|
532
|
+
const { theme } = useTheme();
|
|
533
|
+
return <SpinnerCircle />; // Automatically uses theme settings
|
|
358
534
|
}
|
|
359
535
|
```
|
|
360
536
|
|
|
@@ -368,6 +544,9 @@ import type {
|
|
|
368
544
|
SpinnerCircleProps,
|
|
369
545
|
ProgressBarProps,
|
|
370
546
|
PulseDotsProps,
|
|
547
|
+
LoaderTheme,
|
|
548
|
+
UseLoaderOptions,
|
|
549
|
+
UseLoaderReturn,
|
|
371
550
|
} from 'premium-react-loaders';
|
|
372
551
|
|
|
373
552
|
const MyComponent: React.FC = () => {
|
|
@@ -379,6 +558,21 @@ const MyComponent: React.FC = () => {
|
|
|
379
558
|
|
|
380
559
|
return <Skeleton {...skeletonProps} />;
|
|
381
560
|
};
|
|
561
|
+
|
|
562
|
+
// Theme typing (v2.1.0+)
|
|
563
|
+
const customTheme: LoaderTheme = {
|
|
564
|
+
primaryColor: '#8b5cf6',
|
|
565
|
+
secondaryColor: '#ec4899',
|
|
566
|
+
defaultSize: 'lg',
|
|
567
|
+
defaultSpeed: 'fast',
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
// useLoader hook typing (v2.1.0+)
|
|
571
|
+
const loaderOptions: UseLoaderOptions = {
|
|
572
|
+
delay: 200,
|
|
573
|
+
minDuration: 600,
|
|
574
|
+
autoHide: 5000,
|
|
575
|
+
};
|
|
382
576
|
```
|
|
383
577
|
|
|
384
578
|
## Common Props
|
|
@@ -456,12 +650,52 @@ Contributions are welcome! Please feel free to submit a Pull Request.
|
|
|
456
650
|
|
|
457
651
|
MIT © Ishan Karunaratne
|
|
458
652
|
|
|
653
|
+
## Migrating from v1.x to v2.0
|
|
654
|
+
|
|
655
|
+
v2.0.0 removes the Tailwind CSS dependency for a simpler, lighter library. Here's what changed:
|
|
656
|
+
|
|
657
|
+
### Breaking Changes
|
|
658
|
+
|
|
659
|
+
1. **No Tailwind Required** - The library now uses custom CSS instead of Tailwind
|
|
660
|
+
2. **No Tailwind Configuration Needed** - Remove the library path from your `tailwind.config.js`
|
|
661
|
+
3. **Slightly Different Styling** - Components use the same class names but with custom CSS utilities
|
|
662
|
+
|
|
663
|
+
### Migration Steps
|
|
664
|
+
|
|
665
|
+
1. **Update the package:**
|
|
666
|
+
```bash
|
|
667
|
+
npm install premium-react-loaders@latest
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
2. **Remove Tailwind configuration** (if you're not using Tailwind for other parts of your app):
|
|
671
|
+
```javascript
|
|
672
|
+
// Remove this from tailwind.config.js
|
|
673
|
+
'./node_modules/premium-react-loaders/dist/**/*.{js,ts,jsx,tsx}'
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
3. **That's it!** Your components will continue to work with the same API. The styling is now self-contained.
|
|
677
|
+
|
|
678
|
+
### What Stayed the Same
|
|
679
|
+
|
|
680
|
+
- ✅ All component APIs are identical
|
|
681
|
+
- ✅ All props work exactly the same
|
|
682
|
+
- ✅ TypeScript types unchanged
|
|
683
|
+
- ✅ Same import paths
|
|
684
|
+
- ✅ Same customization options (className, style, color props)
|
|
685
|
+
|
|
686
|
+
### Benefits of v2.0
|
|
687
|
+
|
|
688
|
+
- 🎉 **70% smaller CSS bundle** (21KB → 6.27KB, 1.64KB gzipped)
|
|
689
|
+
- 🎉 **36% smaller total package** (1.0MB → 640KB)
|
|
690
|
+
- 🎉 **Zero configuration** - no Tailwind setup required
|
|
691
|
+
- 🎉 **Works in any React project** - not just Tailwind projects
|
|
692
|
+
- 🎉 **Faster installation** - fewer dependencies to download
|
|
693
|
+
|
|
459
694
|
## Acknowledgments
|
|
460
695
|
|
|
461
696
|
Built with:
|
|
462
697
|
- [React](https://react.dev/)
|
|
463
698
|
- [TypeScript](https://www.typescriptlang.org/)
|
|
464
|
-
- [Tailwind CSS](https://tailwindcss.com/)
|
|
465
699
|
- [Vite](https://vite.dev/)
|
|
466
700
|
- [Storybook](https://storybook.js.org/)
|
|
467
701
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypingIndicator.d.ts","sourceRoot":"","sources":["../../../src/components/pulse/TypingIndicator.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"TypingIndicator.d.ts","sourceRoot":"","sources":["../../../src/components/pulse/TypingIndicator.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,iHA+E3B,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Theme configuration for loaders
|
|
4
|
+
*/
|
|
5
|
+
export interface LoaderTheme {
|
|
6
|
+
/** Primary color for loaders */
|
|
7
|
+
primaryColor?: string;
|
|
8
|
+
/** Secondary color for loaders */
|
|
9
|
+
secondaryColor?: string;
|
|
10
|
+
/** Base color for skeletons */
|
|
11
|
+
skeletonBase?: string;
|
|
12
|
+
/** Highlight color for skeletons */
|
|
13
|
+
skeletonHighlight?: string;
|
|
14
|
+
/** Default size for loaders */
|
|
15
|
+
defaultSize?: number | string;
|
|
16
|
+
/** Default speed for animations */
|
|
17
|
+
defaultSpeed?: 'slow' | 'normal' | 'fast' | number;
|
|
18
|
+
/** Default delay before showing loaders */
|
|
19
|
+
defaultDelay?: number;
|
|
20
|
+
/** Default minimum duration for loaders */
|
|
21
|
+
defaultMinDuration?: number;
|
|
22
|
+
/** Default transition duration */
|
|
23
|
+
defaultTransition?: number | boolean;
|
|
24
|
+
/** Respect user's motion preferences by default */
|
|
25
|
+
respectMotionPreference?: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface ThemeContextValue {
|
|
28
|
+
theme: LoaderTheme;
|
|
29
|
+
}
|
|
30
|
+
export interface ThemeProviderProps {
|
|
31
|
+
/** Theme configuration */
|
|
32
|
+
theme?: LoaderTheme;
|
|
33
|
+
/** Child components */
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* ThemeProvider - Global theme configuration for loaders
|
|
38
|
+
*
|
|
39
|
+
* Provides theme values to all loader components in the component tree.
|
|
40
|
+
* Components will use theme values as defaults unless overridden by props.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* import { ThemeProvider } from 'premium-react-loaders';
|
|
45
|
+
*
|
|
46
|
+
* function App() {
|
|
47
|
+
* return (
|
|
48
|
+
* <ThemeProvider
|
|
49
|
+
* theme={{
|
|
50
|
+
* primaryColor: '#8b5cf6',
|
|
51
|
+
* defaultSpeed: 'fast',
|
|
52
|
+
* defaultDelay: 200,
|
|
53
|
+
* defaultMinDuration: 600,
|
|
54
|
+
* }}
|
|
55
|
+
* >
|
|
56
|
+
* <YourApp />
|
|
57
|
+
* </ThemeProvider>
|
|
58
|
+
* );
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function ThemeProvider({ theme, children }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
63
|
+
/**
|
|
64
|
+
* useTheme - Access theme configuration
|
|
65
|
+
*
|
|
66
|
+
* Returns the current theme configuration from ThemeProvider.
|
|
67
|
+
* If no ThemeProvider is present, returns an empty theme object.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* function MyComponent() {
|
|
72
|
+
* const { theme } = useTheme();
|
|
73
|
+
* return <div style={{ color: theme.primaryColor }}>Hello</div>;
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function useTheme(): ThemeContextValue;
|
|
78
|
+
/**
|
|
79
|
+
* Get theme value with fallback
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
export declare function useThemeValue<K extends keyof LoaderTheme>(key: K, propValue: LoaderTheme[K] | undefined, defaultValue: LoaderTheme[K]): LoaderTheme[K];
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=ThemeContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../../src/context/ThemeContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,+BAA+B;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IACnD,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kCAAkC;IAClC,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACrC,mDAAmD;IACnD,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,UAAU,iBAAiB;IACzB,KAAK,EAAE,WAAW,CAAC;CACpB;AAID,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,uBAAuB;IACvB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,aAAa,CAAC,EAAE,KAAU,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CAIzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAG5C;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,WAAW,EACvD,GAAG,EAAE,CAAC,EACN,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,EACrC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,GAC3B,WAAW,CAAC,CAAC,CAAC,CAGhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACxE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface UseLoaderOptions {
|
|
2
|
+
/** Initial loading state */
|
|
3
|
+
initialLoading?: boolean;
|
|
4
|
+
/** Delay before showing loader (ms) */
|
|
5
|
+
delay?: number;
|
|
6
|
+
/** Minimum duration to show loader (ms) */
|
|
7
|
+
minDuration?: number;
|
|
8
|
+
/** Auto-hide loader after duration (ms) */
|
|
9
|
+
autoHide?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface UseLoaderReturn {
|
|
12
|
+
/** Current loading state */
|
|
13
|
+
loading: boolean;
|
|
14
|
+
/** Start loading */
|
|
15
|
+
startLoading: () => void;
|
|
16
|
+
/** Stop loading */
|
|
17
|
+
stopLoading: () => void;
|
|
18
|
+
/** Toggle loading state */
|
|
19
|
+
toggleLoading: () => void;
|
|
20
|
+
/** Set loading state directly */
|
|
21
|
+
setLoading: (loading: boolean) => void;
|
|
22
|
+
/** Whether loader should be visible (accounts for delay/minDuration) */
|
|
23
|
+
isVisible: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* useLoader - Manage loading states with smart UX features
|
|
27
|
+
*
|
|
28
|
+
* A hook for managing loader visibility with built-in delay, minimum duration,
|
|
29
|
+
* and auto-hide capabilities for optimal user experience.
|
|
30
|
+
*
|
|
31
|
+
* @param options - Configuration options
|
|
32
|
+
* @returns Loading state and control functions
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* function MyComponent() {
|
|
37
|
+
* const { loading, startLoading, stopLoading, isVisible } = useLoader({
|
|
38
|
+
* delay: 200,
|
|
39
|
+
* minDuration: 600,
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* const fetchData = async () => {
|
|
43
|
+
* startLoading();
|
|
44
|
+
* try {
|
|
45
|
+
* await api.fetchData();
|
|
46
|
+
* } finally {
|
|
47
|
+
* stopLoading();
|
|
48
|
+
* }
|
|
49
|
+
* };
|
|
50
|
+
*
|
|
51
|
+
* return <SpinnerCircle visible={isVisible} />;
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function useLoader(options?: UseLoaderOptions): UseLoaderReturn;
|
|
56
|
+
//# sourceMappingURL=useLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLoader.d.ts","sourceRoot":"","sources":["../../src/hooks/useLoader.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,4BAA4B;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB;IACpB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,mBAAmB;IACnB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,2BAA2B;IAC3B,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,iCAAiC;IACjC,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,wEAAwE;IACxE,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,eAAe,CAyGzE"}
|
package/dist/index.cjs
CHANGED
|
@@ -3,35 +3,40 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
;/* empty css */
|
|
4
4
|
const classNames = require("./index3.cjs");
|
|
5
5
|
const colors = require("./index4.cjs");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
6
|
+
const ThemeContext = require("./index5.cjs");
|
|
7
|
+
const useLoader = require("./index6.cjs");
|
|
8
|
+
const Skeleton = require("./index7.cjs");
|
|
9
|
+
const SkeletonText = require("./index8.cjs");
|
|
10
|
+
const SkeletonAvatar = require("./index9.cjs");
|
|
11
|
+
const SkeletonImage = require("./index10.cjs");
|
|
12
|
+
const SkeletonCard = require("./index11.cjs");
|
|
13
|
+
const SkeletonList = require("./index12.cjs");
|
|
14
|
+
const SkeletonTable = require("./index13.cjs");
|
|
15
|
+
const SkeletonPage = require("./index14.cjs");
|
|
16
|
+
const SkeletonForm = require("./index15.cjs");
|
|
17
|
+
const SpinnerCircle = require("./index16.cjs");
|
|
18
|
+
const SpinnerRing = require("./index17.cjs");
|
|
19
|
+
const SpinnerDots = require("./index18.cjs");
|
|
20
|
+
const SpinnerBars = require("./index19.cjs");
|
|
21
|
+
const SpinnerGrid = require("./index20.cjs");
|
|
22
|
+
const SpinnerWave = require("./index21.cjs");
|
|
23
|
+
const SpinnerPulse = require("./index22.cjs");
|
|
24
|
+
const ProgressBar = require("./index23.cjs");
|
|
25
|
+
const ProgressCircle = require("./index24.cjs");
|
|
26
|
+
const ProgressRing = require("./index25.cjs");
|
|
27
|
+
const ProgressSteps = require("./index26.cjs");
|
|
28
|
+
const PulseDots = require("./index27.cjs");
|
|
29
|
+
const PulseWave = require("./index28.cjs");
|
|
30
|
+
const PulseBars = require("./index29.cjs");
|
|
31
|
+
const TypingIndicator = require("./index30.cjs");
|
|
32
|
+
const LoaderOverlay = require("./index31.cjs");
|
|
33
|
+
const version = "2.1.0";
|
|
32
34
|
exports.cn = classNames.cn;
|
|
33
35
|
exports.getAnimationDuration = colors.getAnimationDuration;
|
|
34
36
|
exports.normalizeSize = colors.normalizeSize;
|
|
37
|
+
exports.ThemeProvider = ThemeContext.ThemeProvider;
|
|
38
|
+
exports.useTheme = ThemeContext.useTheme;
|
|
39
|
+
exports.useLoader = useLoader.useLoader;
|
|
35
40
|
exports.Skeleton = Skeleton.Skeleton;
|
|
36
41
|
exports.SkeletonText = SkeletonText.SkeletonText;
|
|
37
42
|
exports.SkeletonAvatar = SkeletonAvatar.SkeletonAvatar;
|
|
@@ -58,4 +63,3 @@ exports.PulseBars = PulseBars.PulseBars;
|
|
|
58
63
|
exports.TypingIndicator = TypingIndicator.TypingIndicator;
|
|
59
64
|
exports.LoaderOverlay = LoaderOverlay.LoaderOverlay;
|
|
60
65
|
exports.version = version;
|
|
61
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from './components';
|
|
2
2
|
export type * from './types';
|
|
3
|
+
export { ThemeProvider, useTheme } from './context';
|
|
4
|
+
export type { LoaderTheme, ThemeProviderProps } from './context';
|
|
5
|
+
export { useLoader } from './hooks';
|
|
6
|
+
export type { UseLoaderOptions, UseLoaderReturn } from './hooks';
|
|
3
7
|
export { cn } from './utils/classNames';
|
|
4
8
|
export { getAnimationDuration, normalizeSize } from './utils/colors';
|
|
5
|
-
export declare const version = "
|
|
9
|
+
export declare const version = "2.1.0";
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|