react-loadly 1.0.1 → 1.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 +529 -62
- package/dist/index.cjs.js +1 -1701
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +146 -55
- package/dist/index.esm.js +1 -1662
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/dist/styles.js +1 -0
- package/dist/types/@types/index.d.ts +3 -1
- package/dist/types/@types/index.d.ts.map +1 -1
- package/dist/types/@types/interfaces/IBaseLoaderProps.d.ts +4 -0
- package/dist/types/@types/interfaces/IBaseLoaderProps.d.ts.map +1 -1
- package/dist/types/@types/interfaces/IShimmerLoaderProps.d.ts +20 -0
- package/dist/types/@types/interfaces/IShimmerLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/ISkeletonLoaderProps.d.ts +24 -0
- package/dist/types/@types/interfaces/ISkeletonLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/index.d.ts +14 -0
- package/dist/types/@types/interfaces/index.d.ts.map +1 -0
- package/dist/types/@types/types/index.d.ts +3 -3
- package/dist/types/@types/types/index.d.ts.map +1 -1
- package/dist/types/components/organisms/FallbackLoader.d.ts +1 -1
- package/dist/types/components/organisms/FallbackLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/LogoSpinLoader.d.ts +1 -1
- package/dist/types/components/organisms/LogoSpinLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/ShimmerLoader.d.ts +4 -0
- package/dist/types/components/organisms/ShimmerLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/SkeletonLoader.d.ts +4 -0
- package/dist/types/components/organisms/SkeletonLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/index.d.ts +3 -1
- package/dist/types/components/organisms/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/styles.d.ts +2 -0
- package/dist/types/styles.d.ts.map +1 -0
- package/dist/types/utils/animationUtils.d.ts +24 -1
- package/dist/types/utils/animationUtils.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts.map +1 -1
- package/package.json +41 -6
- package/dist/types/@types/interfaces/ILoaderTheme.d.ts +0 -20
- package/dist/types/@types/interfaces/ILoaderTheme.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
# ⚛️ React Loadly
|
|
1
|
+
# ⚛️ React Loadly — React Loader, Spinner & Loading Indicator Components for React
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**React Loadly** is a modern, high-performance library of **React loaders, spinners, and loading indicators**.
|
|
4
|
+
It’s built with **TypeScript**, optimized for **Next.js / SSR**, and designed with **accessibility** and **developer experience** in mind.
|
|
5
|
+
|
|
6
|
+
Perfect for building **React apps, dashboards, forms, and data-driven UIs** where you need smooth, customizable loading states.
|
|
4
7
|
|
|
5
8
|
[](https://www.npmjs.com/package/react-loadly)
|
|
6
9
|
[](https://bundlephobia.com/result?p=react-loadly)
|
|
@@ -33,6 +36,24 @@ yarn add react-loadly
|
|
|
33
36
|
pnpm add react-loadly
|
|
34
37
|
```
|
|
35
38
|
|
|
39
|
+
### Bundle Optimization
|
|
40
|
+
|
|
41
|
+
React Loadly is optimized for minimal bundle size and supports tree shaking:
|
|
42
|
+
|
|
43
|
+
- **Zero Side Effects**: Set `"sideEffects": false` in your bundler config for optimal tree shaking
|
|
44
|
+
- **Individual Imports**: Import only the components you need
|
|
45
|
+
- **Separate CSS**: Import styles separately to avoid bundling unused styles
|
|
46
|
+
|
|
47
|
+
```jsx
|
|
48
|
+
// ✅ Recommended: Import only what you need
|
|
49
|
+
import { SpinLoader } from "react-loadly";
|
|
50
|
+
import "react-loadly/styles.css";
|
|
51
|
+
|
|
52
|
+
// ✅ Alternative: Import from specific paths (if supported by your bundler)
|
|
53
|
+
import { SpinLoader } from "react-loadly/components";
|
|
54
|
+
import { useLoaderState } from "react-loadly/hooks";
|
|
55
|
+
```
|
|
56
|
+
|
|
36
57
|
### Quick Usage
|
|
37
58
|
|
|
38
59
|
Import the components you need along with the base styles, then use them in your React application.
|
|
@@ -60,29 +81,171 @@ function App() {
|
|
|
60
81
|
|
|
61
82
|
### Geometric Loaders
|
|
62
83
|
|
|
63
|
-
| Component
|
|
64
|
-
|
|
|
65
|
-
| `SpinLoader`
|
|
66
|
-
| `PulseLoader`
|
|
67
|
-
| `WaveLoader`
|
|
68
|
-
| `GridLoader`
|
|
69
|
-
| `RingLoader`
|
|
84
|
+
| Component | Description |
|
|
85
|
+
| -------------- | ------------------------------------------------ |
|
|
86
|
+
| `SpinLoader` | A classic spinner with a minimalist design. |
|
|
87
|
+
| `PulseLoader` | A dynamic animation of pulsing dots. |
|
|
88
|
+
| `WaveLoader` | A series of bars creating a wave-like effect. |
|
|
89
|
+
| `GridLoader` | A grid of squares that animate in sequence. |
|
|
90
|
+
| `RingLoader` | A sophisticated ring spinner with dual rotation. |
|
|
91
|
+
| `BarsLoader` | Animated bars with staggered timing. |
|
|
92
|
+
| `BounceLoader` | Bouncing dots with elastic animation. |
|
|
93
|
+
| `RotateLoader` | 3D rotating elements with depth. |
|
|
70
94
|
|
|
71
95
|
---
|
|
72
96
|
|
|
97
|
+
### Modern Content Loaders
|
|
98
|
+
|
|
99
|
+
| Component | Description |
|
|
100
|
+
| ---------------- | -------------------------------------------------- |
|
|
101
|
+
| `SkeletonLoader` | Modern skeleton placeholders with shimmer effects. |
|
|
102
|
+
| `ShimmerLoader` | Sophisticated shimmer wave animations. |
|
|
103
|
+
|
|
73
104
|
### Organic & Text-Based Loaders
|
|
74
105
|
|
|
75
|
-
| Component |
|
|
76
|
-
| -------------- |
|
|
77
|
-
| `BlobLoader` |
|
|
78
|
-
| `TypingLoader` |
|
|
79
|
-
| `DotsLoader` |
|
|
106
|
+
| Component | Description |
|
|
107
|
+
| -------------- | --------------------------------------------------- |
|
|
108
|
+
| `BlobLoader` | A liquid-like loader with a smooth, organic feel. |
|
|
109
|
+
| `TypingLoader` | A loader that simulates typing or processing text. |
|
|
110
|
+
| `DotsLoader` | The familiar three-dot animation, perfect for text. |
|
|
111
|
+
| `LiquidLoader` | Fluid, morphing shapes with organic movement. |
|
|
112
|
+
| `FlowLoader` | Flowing particles with smooth transitions. |
|
|
80
113
|
|
|
81
114
|
### Flexible Loaders
|
|
82
115
|
|
|
83
|
-
| Component
|
|
84
|
-
|
|
|
85
|
-
| `ElementLoader`
|
|
116
|
+
| Component | Description |
|
|
117
|
+
| ---------------- | ------------------------------------------------------------------------------------ |
|
|
118
|
+
| `ElementLoader` | A flexible loader that can display any React element with various animation effects. |
|
|
119
|
+
| `FallbackLoader` | Error handling and retry functionality with customizable UI. |
|
|
120
|
+
| `LogoSpinLoader` | Specialized loader for logos and brand elements. |
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 🦴 SkeletonLoader Component
|
|
125
|
+
|
|
126
|
+
The `SkeletonLoader` is perfect for modern loading states, creating placeholder content that mimics the actual content structure.
|
|
127
|
+
|
|
128
|
+
### Basic Usage
|
|
129
|
+
|
|
130
|
+
```jsx
|
|
131
|
+
import { SkeletonLoader } from "react-loadly";
|
|
132
|
+
|
|
133
|
+
function App() {
|
|
134
|
+
return (
|
|
135
|
+
<div>
|
|
136
|
+
{/* Basic skeleton line */}
|
|
137
|
+
<SkeletonLoader />
|
|
138
|
+
|
|
139
|
+
{/* Multiple skeleton lines */}
|
|
140
|
+
<SkeletonLoader lines={3} />
|
|
141
|
+
|
|
142
|
+
{/* Card skeleton */}
|
|
143
|
+
<SkeletonLoader variant="card" width={300} height={200} />
|
|
144
|
+
|
|
145
|
+
{/* Avatar skeleton */}
|
|
146
|
+
<SkeletonLoader variant="avatar" size={60} />
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Skeleton Variants
|
|
153
|
+
|
|
154
|
+
```jsx
|
|
155
|
+
// Line skeleton (default)
|
|
156
|
+
<SkeletonLoader variant="line" lines={3} />
|
|
157
|
+
|
|
158
|
+
// Card skeleton
|
|
159
|
+
<SkeletonLoader variant="card" width={300} height={200} />
|
|
160
|
+
|
|
161
|
+
// Avatar skeleton
|
|
162
|
+
<SkeletonLoader variant="avatar" size={60} />
|
|
163
|
+
|
|
164
|
+
// Text skeleton
|
|
165
|
+
<SkeletonLoader variant="text" width="100%" height={16} />
|
|
166
|
+
|
|
167
|
+
// Custom skeleton
|
|
168
|
+
<SkeletonLoader
|
|
169
|
+
variant="custom"
|
|
170
|
+
width={200}
|
|
171
|
+
height={100}
|
|
172
|
+
borderRadius="8px"
|
|
173
|
+
/>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Customization Options
|
|
177
|
+
|
|
178
|
+
```jsx
|
|
179
|
+
<SkeletonLoader
|
|
180
|
+
lines={3}
|
|
181
|
+
baseColor="#f0f0f0"
|
|
182
|
+
highlightColor="#e0e0e0"
|
|
183
|
+
shimmerColor="rgba(255, 255, 255, 0.6)"
|
|
184
|
+
spacing="12px"
|
|
185
|
+
shimmer={true}
|
|
186
|
+
speed={1.5}
|
|
187
|
+
/>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## ✨ ShimmerLoader Component
|
|
193
|
+
|
|
194
|
+
The `ShimmerLoader` creates sophisticated wave-like animations perfect for modern UIs.
|
|
195
|
+
|
|
196
|
+
### Basic Usage
|
|
197
|
+
|
|
198
|
+
```jsx
|
|
199
|
+
import { ShimmerLoader } from "react-loadly";
|
|
200
|
+
|
|
201
|
+
function App() {
|
|
202
|
+
return (
|
|
203
|
+
<div>
|
|
204
|
+
{/* Basic shimmer */}
|
|
205
|
+
<ShimmerLoader />
|
|
206
|
+
|
|
207
|
+
{/* Multiple shimmer lines */}
|
|
208
|
+
<ShimmerLoader lines={3} />
|
|
209
|
+
|
|
210
|
+
{/* Card shimmer */}
|
|
211
|
+
<ShimmerLoader variant="card" width={300} height={200} />
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Shimmer Variants
|
|
218
|
+
|
|
219
|
+
```jsx
|
|
220
|
+
// Line shimmer (default)
|
|
221
|
+
<ShimmerLoader variant="line" lines={3} />
|
|
222
|
+
|
|
223
|
+
// Card shimmer
|
|
224
|
+
<ShimmerLoader variant="card" width={300} height={200} />
|
|
225
|
+
|
|
226
|
+
// Avatar shimmer
|
|
227
|
+
<ShimmerLoader variant="avatar" size={60} />
|
|
228
|
+
|
|
229
|
+
// Wave shimmer
|
|
230
|
+
<ShimmerLoader variant="wave" width="100%" height={20} />
|
|
231
|
+
|
|
232
|
+
// Text shimmer
|
|
233
|
+
<ShimmerLoader variant="text" width="100%" height={16} />
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Customization Options
|
|
237
|
+
|
|
238
|
+
```jsx
|
|
239
|
+
<ShimmerLoader
|
|
240
|
+
lines={3}
|
|
241
|
+
baseColor="#f1f5f9"
|
|
242
|
+
highlightColor="#e2e8f0"
|
|
243
|
+
shimmerColor="rgba(255, 255, 255, 0.8)"
|
|
244
|
+
waveWidth="200px"
|
|
245
|
+
waveDirection="left-to-right"
|
|
246
|
+
speed={1.2}
|
|
247
|
+
/>
|
|
248
|
+
```
|
|
86
249
|
|
|
87
250
|
---
|
|
88
251
|
|
|
@@ -98,7 +261,7 @@ import { ElementLoader } from "react-loadly";
|
|
|
98
261
|
function App() {
|
|
99
262
|
return (
|
|
100
263
|
<ElementLoader>
|
|
101
|
-
<div style={{ width:
|
|
264
|
+
<div style={{ width: "40px", height: "40px", backgroundColor: "blue" }} />
|
|
102
265
|
</ElementLoader>
|
|
103
266
|
);
|
|
104
267
|
}
|
|
@@ -137,56 +300,117 @@ The ElementLoader supports multiple animation types:
|
|
|
137
300
|
|
|
138
301
|
### Customization Options
|
|
139
302
|
|
|
140
|
-
|
|
141
|
-
<ElementLoader
|
|
142
|
-
|
|
143
|
-
color="#ff6b6b"
|
|
144
|
-
speed={1.5}
|
|
145
|
-
glowIntensity={0.5}
|
|
146
|
-
showText
|
|
147
|
-
loadingText="Loading..."
|
|
148
|
-
>
|
|
149
|
-
<YourCustomElement />
|
|
303
|
+
``jsx
|
|
304
|
+
<ElementLoader size={80} color="#ff6b6b" speed={1.5} glowIntensity={0.5} showText loadingText="Loading...">
|
|
305
|
+
<YourCustomElement />
|
|
150
306
|
</ElementLoader>
|
|
307
|
+
|
|
151
308
|
```
|
|
152
309
|
|
|
153
310
|
### Fullscreen Mode
|
|
154
311
|
|
|
155
312
|
Like other loaders, ElementLoader supports fullscreen mode:
|
|
156
313
|
|
|
157
|
-
|
|
158
|
-
<ElementLoader
|
|
159
|
-
fullscreen
|
|
160
|
-
loaderCenter
|
|
161
|
-
screenBackground="rgba(0, 0, 0, 0.5)"
|
|
162
|
-
>
|
|
314
|
+
``jsx
|
|
315
|
+
<ElementLoader fullscreen loaderCenter screenBackground="rgba(0, 0, 0, 0.5)">
|
|
163
316
|
<YourIconComponent />
|
|
164
317
|
</ElementLoader>
|
|
165
318
|
```
|
|
166
319
|
|
|
167
320
|
### Props
|
|
168
321
|
|
|
169
|
-
| Prop
|
|
170
|
-
|
|
|
171
|
-
| `children`
|
|
172
|
-
| `animationType`
|
|
173
|
-
| `glowIntensity`
|
|
174
|
-
| `size`
|
|
175
|
-
| `width`
|
|
176
|
-
| `height`
|
|
177
|
-
| `color`
|
|
178
|
-
| `speed`
|
|
179
|
-
| `loading`
|
|
180
|
-
| `className`
|
|
181
|
-
| `style`
|
|
182
|
-
| `aria-label`
|
|
183
|
-
| `showText`
|
|
184
|
-
| `loadingText`
|
|
185
|
-
| `fullscreen`
|
|
186
|
-
| `screenWidth`
|
|
187
|
-
| `screenHeight`
|
|
188
|
-
| `loaderCenter`
|
|
189
|
-
| `screenBackground` | string
|
|
322
|
+
| Prop | Type | Default | Description |
|
|
323
|
+
| ------------------ | ------------------------------------------------- | --------------------------- | ----------------------------------------------- |
|
|
324
|
+
| `children` | ReactNode | undefined | The React element to apply loading animation to |
|
|
325
|
+
| `animationType` | "spin" \| "pulse" \| "glow" \| "bounce" \| "flip" | "spin" | Type of animation to apply |
|
|
326
|
+
| `glowIntensity` | number (0-1) | 0.3 | Intensity of the glow effect |
|
|
327
|
+
| `size` | number \| string | 60 | Size of the loader |
|
|
328
|
+
| `width` | number \| string | undefined | Width of the loader (overrides size) |
|
|
329
|
+
| `height` | number \| string | undefined | Height of the loader (overrides size) |
|
|
330
|
+
| `color` | string | "var(--react-loadly-color)" | Primary color of the loader |
|
|
331
|
+
| `speed` | number | 1 | Animation speed multiplier |
|
|
332
|
+
| `loading` | boolean | true | Whether the loader is active |
|
|
333
|
+
| `className` | string | undefined | Custom CSS class name |
|
|
334
|
+
| `style` | CSSProperties | undefined | Custom inline styles |
|
|
335
|
+
| `aria-label` | string | "Loading..." | Accessibility label for screen readers |
|
|
336
|
+
| `showText` | boolean | false | Whether to show loading text |
|
|
337
|
+
| `loadingText` | string | undefined | Custom loading text |
|
|
338
|
+
| `fullscreen` | boolean | false | Enable fullscreen mode |
|
|
339
|
+
| `screenWidth` | number \| string | undefined | Screen width for fullscreen mode |
|
|
340
|
+
| `screenHeight` | number \| string | undefined | Screen height for fullscreen mode |
|
|
341
|
+
| `loaderCenter` | boolean | false | Center the loader in fullscreen mode |
|
|
342
|
+
| `screenBackground` | string | undefined | Background color for fullscreen mode |
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## ⚡ Performance & Best Practices
|
|
347
|
+
|
|
348
|
+
### Performance Optimization
|
|
349
|
+
|
|
350
|
+
React Loadly is built with performance in mind:
|
|
351
|
+
|
|
352
|
+
- **Hardware Acceleration**: All animations use CSS transforms and `will-change` for optimal performance
|
|
353
|
+
- **Reduced Motion Support**: Automatically respects user's motion preferences
|
|
354
|
+
- **Tree Shaking**: Import only the components you need
|
|
355
|
+
- **Memoization**: Components use React.memo and useMemo for optimal re-rendering
|
|
356
|
+
- **CSS-in-JS**: Minimal runtime overhead with CSS variables
|
|
357
|
+
|
|
358
|
+
### Best Practices
|
|
359
|
+
|
|
360
|
+
```jsx
|
|
361
|
+
// ✅ Good: Import only what you need
|
|
362
|
+
import { SpinLoader, SkeletonLoader } from "react-loadly";
|
|
363
|
+
|
|
364
|
+
// ❌ Avoid: Importing everything
|
|
365
|
+
import \* as Loaders from "react-loadly";
|
|
366
|
+
|
|
367
|
+
// ✅ Good: Use appropriate loader for context
|
|
368
|
+
function UserProfile({ user, loading }) {
|
|
369
|
+
if (loading) {
|
|
370
|
+
return (
|
|
371
|
+
<div>
|
|
372
|
+
<SkeletonLoader variant="avatar" size={60} />
|
|
373
|
+
<SkeletonLoader lines={2} />
|
|
374
|
+
</div>
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
return <div>{/_ User content _/}</div>;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// ✅ Good: Conditional rendering
|
|
381
|
+
function DataComponent({ data, loading }) {
|
|
382
|
+
return <div>{loading ? <SpinLoader /> : <div>{data}</div>}</div>;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// ✅ Good: Use fullscreen for page-level loading
|
|
386
|
+
function App() {
|
|
387
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
388
|
+
|
|
389
|
+
return (
|
|
390
|
+
<div>
|
|
391
|
+
{isLoading && <SpinLoader fullscreen loaderCenter screenBackground="rgba(255, 255, 255, 0.9)" />}
|
|
392
|
+
{/_ App content _/}
|
|
393
|
+
</div>
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Bundle Size Optimization
|
|
400
|
+
|
|
401
|
+
``jsx
|
|
402
|
+
// ✅ Tree-shakable imports
|
|
403
|
+
import { SpinLoader } from "react-loadly";
|
|
404
|
+
|
|
405
|
+
// ✅ CSS imports (only import what you need)
|
|
406
|
+
import "react-loadly/styles.css";
|
|
407
|
+
|
|
408
|
+
// ✅ For Next.js, use dynamic imports for code splitting
|
|
409
|
+
import dynamic from "next/dynamic";
|
|
410
|
+
|
|
411
|
+
const SkeletonLoader = dynamic(() => import("react-loadly").then((mod) => ({ default: mod.SkeletonLoader })));
|
|
412
|
+
|
|
413
|
+
````
|
|
190
414
|
|
|
191
415
|
---
|
|
192
416
|
|
|
@@ -206,7 +430,7 @@ Accessibility is a core feature, not an afterthought. All loaders include:
|
|
|
206
430
|
|
|
207
431
|
// Custom accessible text
|
|
208
432
|
<PulseLoader showText loadingText="Processing your request..." />
|
|
209
|
-
|
|
433
|
+
````
|
|
210
434
|
|
|
211
435
|
---
|
|
212
436
|
|
|
@@ -248,6 +472,28 @@ interface BaseLoaderProps {
|
|
|
248
472
|
}
|
|
249
473
|
```
|
|
250
474
|
|
|
475
|
+
### TypeScript Integration
|
|
476
|
+
|
|
477
|
+
React Loadly provides comprehensive TypeScript definitions for all components and hooks. You can import types and interfaces directly from the library:
|
|
478
|
+
|
|
479
|
+
```tsx
|
|
480
|
+
// ✅ Correct way to import shared interfaces
|
|
481
|
+
import type { IBaseLoaderProps, ISkeletonLoaderProps } from "react-loadly";
|
|
482
|
+
|
|
483
|
+
// For component-specific props
|
|
484
|
+
import type { CircleProps } from "react-loadly/components";
|
|
485
|
+
|
|
486
|
+
// For hook return types
|
|
487
|
+
import type { IUseLoaderStateReturn } from "react-loadly/hooks";
|
|
488
|
+
|
|
489
|
+
// For animation types
|
|
490
|
+
import type { AnimationDirectionType } from "react-loadly";
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
All types are properly exported and can be used in your TypeScript projects for better type safety and autocompletion.
|
|
494
|
+
|
|
495
|
+
Avoid importing directly from internal paths like `react-loadly/types` or `react-loadly/interfaces` as these are not part of the public API and may change.
|
|
496
|
+
|
|
251
497
|
### Fullscreen Mode
|
|
252
498
|
|
|
253
499
|
Display any loader in fullscreen mode with customizable dimensions and background:
|
|
@@ -272,6 +518,130 @@ Display any loader in fullscreen mode with customizable dimensions and backgroun
|
|
|
272
518
|
|
|
273
519
|
---
|
|
274
520
|
|
|
521
|
+
## 🎯 Real-World Examples
|
|
522
|
+
|
|
523
|
+
### Loading States for Different Content Types
|
|
524
|
+
|
|
525
|
+
``jsx
|
|
526
|
+
import { SkeletonLoader, ShimmerLoader, SpinLoader, PulseLoader } from "react-loadly";
|
|
527
|
+
|
|
528
|
+
function ContentLoader() {
|
|
529
|
+
return (
|
|
530
|
+
|
|
531
|
+
<div>
|
|
532
|
+
{/_ Blog post loading _/}
|
|
533
|
+
<div className="blog-post">
|
|
534
|
+
<SkeletonLoader variant="avatar" size={40} />
|
|
535
|
+
<SkeletonLoader lines={3} spacing="8px" />
|
|
536
|
+
<SkeletonLoader variant="card" width="100%" height={200} />
|
|
537
|
+
</div>
|
|
538
|
+
|
|
539
|
+
{/* Dashboard loading */}
|
|
540
|
+
<div className="dashboard">
|
|
541
|
+
<ShimmerLoader variant="card" width={300} height={150} />
|
|
542
|
+
<ShimmerLoader variant="card" width={300} height={150} />
|
|
543
|
+
<ShimmerLoader variant="card" width={300} height={150} />
|
|
544
|
+
</div>
|
|
545
|
+
|
|
546
|
+
{/* Button loading */}
|
|
547
|
+
<button disabled>
|
|
548
|
+
<SpinLoader size={16} />
|
|
549
|
+
Processing...
|
|
550
|
+
</button>
|
|
551
|
+
|
|
552
|
+
{/* Inline loading */}
|
|
553
|
+
<div>
|
|
554
|
+
Loading data <PulseLoader size={12} />
|
|
555
|
+
</div>
|
|
556
|
+
</div>
|
|
557
|
+
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### Form Loading States
|
|
564
|
+
|
|
565
|
+
``jsx
|
|
566
|
+
function FormWithLoading() {
|
|
567
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
568
|
+
|
|
569
|
+
return (
|
|
570
|
+
<form onSubmit={handleSubmit}>
|
|
571
|
+
<input type="text" placeholder="Name" />
|
|
572
|
+
<input type="email" placeholder="Email" />
|
|
573
|
+
|
|
574
|
+
<button type="submit" disabled={isSubmitting}>
|
|
575
|
+
{isSubmitting ? (
|
|
576
|
+
<>
|
|
577
|
+
<SpinLoader size={16} />
|
|
578
|
+
Submitting...
|
|
579
|
+
</>
|
|
580
|
+
) : (
|
|
581
|
+
"Submit"
|
|
582
|
+
)}
|
|
583
|
+
</button>
|
|
584
|
+
</form>
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### Data Table Loading
|
|
590
|
+
|
|
591
|
+
```jsx
|
|
592
|
+
function DataTable({ data, loading }) {
|
|
593
|
+
if (loading) {
|
|
594
|
+
return (
|
|
595
|
+
<div className="data-table">
|
|
596
|
+
{/* Header skeleton */}
|
|
597
|
+
<div className="table-header">
|
|
598
|
+
{Array.from({ length: 5 }).map((_, i) => (
|
|
599
|
+
<SkeletonLoader key={i} width={120} height={20} />
|
|
600
|
+
))}
|
|
601
|
+
</div>
|
|
602
|
+
|
|
603
|
+
{/* Row skeletons */}
|
|
604
|
+
{Array.from({ length: 10 }).map((_, i) => (
|
|
605
|
+
<div key={i} className="table-row">
|
|
606
|
+
{Array.from({ length: 5 }).map((_, j) => (
|
|
607
|
+
<SkeletonLoader key={j} width={100} height={16} />
|
|
608
|
+
))}
|
|
609
|
+
</div>
|
|
610
|
+
))}
|
|
611
|
+
</div>
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
return <div className="data-table">{/* Actual table content */}</div>;
|
|
616
|
+
}
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
### Image Gallery Loading
|
|
620
|
+
|
|
621
|
+
```jsx
|
|
622
|
+
function ImageGallery({ images, loading }) {
|
|
623
|
+
if (loading) {
|
|
624
|
+
return (
|
|
625
|
+
<div className="image-gallery">
|
|
626
|
+
{Array.from({ length: 6 }).map((_, i) => (
|
|
627
|
+
<ShimmerLoader key={i} variant="card" width={200} height={200} borderRadius="8px" />
|
|
628
|
+
))}
|
|
629
|
+
</div>
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
return (
|
|
634
|
+
<div className="image-gallery">
|
|
635
|
+
{images.map((image, i) => (
|
|
636
|
+
<img key={i} src={image.url} alt={image.alt} />
|
|
637
|
+
))}
|
|
638
|
+
</div>
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
---
|
|
644
|
+
|
|
275
645
|
## 🧩 Advanced Usage
|
|
276
646
|
|
|
277
647
|
### `useLoaderState` Hook
|
|
@@ -317,12 +687,109 @@ function DataComponent() {
|
|
|
317
687
|
}
|
|
318
688
|
```
|
|
319
689
|
|
|
320
|
-
|
|
690
|
+
---
|
|
321
691
|
|
|
322
|
-
|
|
692
|
+
## 🤝 Contributing
|
|
693
|
+
|
|
694
|
+
We welcome contributions from the community! Whether you're fixing bugs, adding new features, or improving documentation, your contributions help make React Loadly better for everyone.
|
|
695
|
+
|
|
696
|
+
### How to Contribute
|
|
697
|
+
|
|
698
|
+
1. **Fork the repository** on GitHub
|
|
699
|
+
2. **Clone your fork** locally:
|
|
700
|
+
```bash
|
|
701
|
+
git clone https://github.com/your-username/react-loadly.git
|
|
702
|
+
cd react-loadly
|
|
703
|
+
```
|
|
704
|
+
3. **Create a new branch** for your changes:
|
|
705
|
+
```bash
|
|
706
|
+
git checkout -b feature/your-feature-name
|
|
707
|
+
```
|
|
708
|
+
4. **Install dependencies**:
|
|
709
|
+
```bash
|
|
710
|
+
pnpm install
|
|
711
|
+
```
|
|
712
|
+
5. **Make your changes** and ensure tests pass:
|
|
713
|
+
```bash
|
|
714
|
+
pnpm test
|
|
715
|
+
pnpm build
|
|
716
|
+
```
|
|
717
|
+
6. **Commit your changes**:
|
|
718
|
+
```bash
|
|
719
|
+
git commit -m "feat: add your awesome feature"
|
|
720
|
+
```
|
|
721
|
+
7. **Push to your fork**:
|
|
722
|
+
```bash
|
|
723
|
+
git push origin feature/your-feature-name
|
|
724
|
+
```
|
|
725
|
+
8. **Open a Pull Request** with a clear description of your changes
|
|
726
|
+
|
|
727
|
+
### What You Can Contribute
|
|
728
|
+
|
|
729
|
+
- 🐛 **Bug fixes** - Help us squash bugs
|
|
730
|
+
- ✨ **New loader components** - Add new loading animations
|
|
731
|
+
- 📚 **Documentation** - Improve examples and guides
|
|
732
|
+
- 🎨 **Design improvements** - Enhance existing components
|
|
733
|
+
- 🧪 **Tests** - Add test coverage
|
|
734
|
+
- 🌐 **Internationalization** - Help with translations
|
|
735
|
+
- 📦 **Build improvements** - Optimize bundle size and build process
|
|
736
|
+
|
|
737
|
+
### Development Guidelines
|
|
738
|
+
|
|
739
|
+
- Follow the existing code style and patterns
|
|
740
|
+
- Add tests for new features
|
|
741
|
+
- Update documentation for API changes
|
|
742
|
+
- Ensure accessibility standards are met
|
|
743
|
+
- Keep bundle size impact minimal
|
|
744
|
+
|
|
745
|
+
### Need Help?
|
|
746
|
+
|
|
747
|
+
- 💬 **Join our discussions** in GitHub Discussions
|
|
748
|
+
- 🐛 **Report bugs** in GitHub Issues
|
|
749
|
+
- 💡 **Suggest features** in GitHub Issues
|
|
750
|
+
- 📖 **Read our contributing guide** for detailed information
|
|
323
751
|
|
|
324
|
-
|
|
325
|
-
import { FallbackLoader } from "react-loadly";
|
|
752
|
+
---
|
|
326
753
|
|
|
327
|
-
|
|
328
|
-
|
|
754
|
+
## 👥 Contributors
|
|
755
|
+
|
|
756
|
+
Thank you to all the amazing people who have contributed to React Loadly:
|
|
757
|
+
|
|
758
|
+
<!-- Contributors will be automatically updated by GitHub Actions -->
|
|
759
|
+
<!--
|
|
760
|
+
<a href="https://github.com/Mostafashadow1/react-loadly/graphs/contributors">
|
|
761
|
+
<img src="https://contrib.rocks/image?repo=Mostafashadow1/react-loadly" />
|
|
762
|
+
</a>
|
|
763
|
+
-->
|
|
764
|
+
|
|
765
|
+
### Hall of Fame
|
|
766
|
+
|
|
767
|
+
- **[@Mostafashadow1](https://github.com/Mostafashadow1)** - Creator and maintainer
|
|
768
|
+
- _Your name could be here!_ - [Contribute today](#-contributing)
|
|
769
|
+
|
|
770
|
+
### Recognition
|
|
771
|
+
|
|
772
|
+
We recognize contributors in several ways:
|
|
773
|
+
|
|
774
|
+
- 🏆 **Contributor badges** in pull requests
|
|
775
|
+
- 📝 **Contributor recognition** in release notes
|
|
776
|
+
- 🌟 **Hall of fame** in this README
|
|
777
|
+
- 🎉 **Special thanks** in our changelog
|
|
778
|
+
|
|
779
|
+
---
|
|
780
|
+
|
|
781
|
+
## 📄 License
|
|
782
|
+
|
|
783
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
784
|
+
|
|
785
|
+
---
|
|
786
|
+
|
|
787
|
+
## 🙏 Acknowledgments
|
|
788
|
+
|
|
789
|
+
- Thanks to the React community for inspiration and feedback
|
|
790
|
+
- Special thanks to all contributors who help make this project better
|
|
791
|
+
- Built with ❤️ for developers who value great UX
|
|
792
|
+
|
|
793
|
+
---
|
|
794
|
+
|
|
795
|
+
**Made with ❤️ by the React Loadly community**
|