react-loadly 2.0.2 β 2.1.1
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 +392 -36
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +89 -5
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/dist/types/@types/index.d.ts +3 -0
- package/dist/types/@types/index.d.ts.map +1 -1
- package/dist/types/@types/interfaces/IAutoSkeletonProps.d.ts +24 -0
- package/dist/types/@types/interfaces/IAutoSkeletonProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IFallbackLoaderProps.d.ts +2 -0
- package/dist/types/@types/interfaces/IFallbackLoaderProps.d.ts.map +1 -1
- package/dist/types/@types/interfaces/IHeatmapLoaderProps.d.ts +8 -0
- package/dist/types/@types/interfaces/IHeatmapLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IMorphLoaderProps.d.ts +8 -0
- package/dist/types/@types/interfaces/IMorphLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IProgressRingLoaderProps.d.ts +8 -0
- package/dist/types/@types/interfaces/IProgressRingLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/ISkeletonLoaderProps.d.ts +2 -1
- package/dist/types/@types/interfaces/ISkeletonLoaderProps.d.ts.map +1 -1
- package/dist/types/@types/interfaces/ISpinDotsLoaderProps.d.ts +8 -0
- package/dist/types/@types/interfaces/ISpinDotsLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/index.d.ts +5 -0
- package/dist/types/@types/interfaces/index.d.ts.map +1 -1
- package/dist/types/@types/types/SkeletonVariantType.d.ts +2 -0
- package/dist/types/@types/types/SkeletonVariantType.d.ts.map +1 -0
- package/dist/types/@types/types/WaveDirectionType.d.ts +2 -0
- package/dist/types/@types/types/WaveDirectionType.d.ts.map +1 -0
- package/dist/types/@types/types/index.d.ts +2 -0
- package/dist/types/@types/types/index.d.ts.map +1 -1
- package/dist/types/AutoSkeletonExample.d.ts +3 -0
- package/dist/types/AutoSkeletonExample.d.ts.map +1 -0
- package/dist/types/components/organisms/AutoSkeletonLoader.d.ts +4 -0
- package/dist/types/components/organisms/AutoSkeletonLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/FallbackLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/HeatmapLoader.d.ts +4 -0
- package/dist/types/components/organisms/HeatmapLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/MorphLoader.d.ts +4 -0
- package/dist/types/components/organisms/MorphLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/ProgressRingLoader.d.ts +4 -0
- package/dist/types/components/organisms/ProgressRingLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/SkeletonLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/SpinDotsLoader.d.ts +4 -0
- package/dist/types/components/organisms/SpinDotsLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/index.d.ts +6 -1
- package/dist/types/components/organisms/index.d.ts.map +1 -1
- package/dist/types/constants/defaults.d.ts +17 -0
- package/dist/types/constants/defaults.d.ts.map +1 -0
- package/dist/types/constants/index.d.ts +2 -0
- package/dist/types/constants/index.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +1 -1
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/main.d.ts +2 -0
- package/dist/types/main.d.ts.map +1 -0
- package/dist/types/utils/propUtils.d.ts +4 -1
- package/dist/types/utils/propUtils.d.ts.map +1 -1
- package/package.json +5 -1
- package/dist/types/__tests__/ElementLoader.example.d.ts +0 -4
- package/dist/types/__tests__/ElementLoader.example.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
**React Loadly** is a modern, high-performance library of **React loaders, spinners, and loading indicators**.
|
|
4
4
|
Itβs built with **TypeScript**, optimized for **Next.js / SSR**, and designed with **accessibility** and **developer experience** in mind.
|
|
5
5
|
|
|
6
|
-
Perfect for building **React apps, dashboards, forms, and data-driven UIs** where you need smooth, customizable loading states.
|
|
6
|
+
Perfect for building **React apps, dashboards, forms, and data-driven UIs** where you need smooth, customizable loading states. Includes **AutoSkeletonLoader** for automatically generating skeleton loaders based on your component structure.
|
|
7
7
|
|
|
8
8
|
π **Home Page**: [https://Mostafashadow1.github.io/react-loadly-showCases/](https://Mostafashadow1.github.io/react-loadly-showCases/)
|
|
9
9
|
|
|
@@ -21,6 +21,7 @@ Perfect for building **React apps, dashboards, forms, and data-driven UIs** wher
|
|
|
21
21
|
- **Reduced Motion**: Respects the user's `prefers-reduced-motion` settings.
|
|
22
22
|
- **SSR Compatible**: Works out-of-the-box with frameworks like **Next.js**.
|
|
23
23
|
- **Fullscreen Support**: Display loaders in fullscreen mode with customizable backgrounds.
|
|
24
|
+
- **AutoSkeletonLoader Support**: Automatically generates skeleton loaders based on your component structure.
|
|
24
25
|
|
|
25
26
|
---
|
|
26
27
|
|
|
@@ -98,9 +99,10 @@ function App() {
|
|
|
98
99
|
|
|
99
100
|
### Modern Content Loaders
|
|
100
101
|
|
|
101
|
-
| Component
|
|
102
|
-
|
|
|
103
|
-
| `SkeletonLoader`
|
|
102
|
+
| Component | Description |
|
|
103
|
+
| -------------------- | ---------------------------------------------------------------------------------------------- |
|
|
104
|
+
| `SkeletonLoader` | Modern skeleton placeholders with shimmer effects. with Sophisticated shimmer wave animations. |
|
|
105
|
+
| `AutoSkeletonLoader` | Automatically generates skeleton loaders based on your component structure. |
|
|
104
106
|
|
|
105
107
|
### Organic & Text-Based Loaders
|
|
106
108
|
|
|
@@ -114,11 +116,245 @@ function App() {
|
|
|
114
116
|
|
|
115
117
|
### Flexible Loaders
|
|
116
118
|
|
|
117
|
-
| Component
|
|
118
|
-
|
|
|
119
|
-
| `ElementLoader`
|
|
120
|
-
| `FallbackLoader`
|
|
121
|
-
| `LogoSpinLoader`
|
|
119
|
+
| Component | Description |
|
|
120
|
+
| -------------------- | ------------------------------------------------------------------------------------ | --- |
|
|
121
|
+
| `ElementLoader` | A flexible loader that can display any React element with various animation effects. |
|
|
122
|
+
| `FallbackLoader` | Error handling and retry functionality with customizable UI. |
|
|
123
|
+
| `LogoSpinLoader` | Specialized loader for logos and brand elements. |
|
|
124
|
+
| `ProgressRingLoader` | Accessible progress ring with optional determinate mode. |
|
|
125
|
+
| `MorphLoader` | Smooth morphing SVG shapes that interpolate between paths. |
|
|
126
|
+
| `SpinDotsLoader` | Circular orbit of dots; perfect for inline text. |
|
|
127
|
+
| `HeatmapLoader` | Grid of pulses with staggered timing; useful for dashboards. | |
|
|
128
|
+
|
|
129
|
+
### ProgressRingLoader Component
|
|
130
|
+
|
|
131
|
+
The `ProgressRingLoader` is an accessible progress ring component that supports both determinate and indeterminate modes. In determinate mode, it shows the exact progress percentage, while in indeterminate mode, it provides a continuous spinning animation.
|
|
132
|
+
|
|
133
|
+
#### Basic Usage
|
|
134
|
+
|
|
135
|
+
```jsx
|
|
136
|
+
import { ProgressRingLoader } from "react-loadly";
|
|
137
|
+
|
|
138
|
+
function App() {
|
|
139
|
+
return (
|
|
140
|
+
<div>
|
|
141
|
+
{/* Indeterminate mode (default) */}
|
|
142
|
+
<ProgressRingLoader />
|
|
143
|
+
|
|
144
|
+
{/* Determinate mode */}
|
|
145
|
+
<ProgressRingLoader progress={75} />
|
|
146
|
+
|
|
147
|
+
{/* Custom size and color */}
|
|
148
|
+
<ProgressRingLoader size={60} color="#10b981" thickness={6} />
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### ProgressRingLoader Props
|
|
155
|
+
|
|
156
|
+
| Prop | Type | Default | Description |
|
|
157
|
+
| ----------- | ---------------- | --------- | ------------------------------------------------ |
|
|
158
|
+
| `progress` | number \| null | null | Progress value (0-100) or null for indeterminate |
|
|
159
|
+
| `thickness` | number | 4 | Thickness of the ring |
|
|
160
|
+
| `size` | number \| string | 40 | Size of the loader |
|
|
161
|
+
| `color` | string | "#6366f1" | Color of the progress ring |
|
|
162
|
+
|
|
163
|
+
All other props are inherited from `IBaseLoaderProps`.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### MorphLoader Component
|
|
168
|
+
|
|
169
|
+
The `MorphLoader` creates smooth morphing SVG shapes that interpolate between different paths. It supports three variants: blob, soft, and sharp.
|
|
170
|
+
|
|
171
|
+
#### Basic Usage
|
|
172
|
+
|
|
173
|
+
```jsx
|
|
174
|
+
import { MorphLoader } from "react-loadly";
|
|
175
|
+
|
|
176
|
+
function App() {
|
|
177
|
+
return (
|
|
178
|
+
<div>
|
|
179
|
+
{/* Default blob variant */}
|
|
180
|
+
<MorphLoader />
|
|
181
|
+
|
|
182
|
+
{/* Soft variant */}
|
|
183
|
+
<MorphLoader variant="soft" />
|
|
184
|
+
|
|
185
|
+
{/* Sharp variant */}
|
|
186
|
+
<MorphLoader variant="sharp" />
|
|
187
|
+
|
|
188
|
+
{/* Custom size and color */}
|
|
189
|
+
<MorphLoader size={60} color="#10b981" />
|
|
190
|
+
</div>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### MorphLoader Props
|
|
196
|
+
|
|
197
|
+
| Prop | Type | Default | Description |
|
|
198
|
+
| --------- | --------------------------- | --------- | --------------------------- |
|
|
199
|
+
| `variant` | "blob" \| "soft" \| "sharp" | "blob" | Morph variant type |
|
|
200
|
+
| `speed` | number | 1 | Animation speed multiplier |
|
|
201
|
+
| `size` | number \| string | 40 | Size of the loader |
|
|
202
|
+
| `color` | string | "#6366f1" | Color of the morphing shape |
|
|
203
|
+
|
|
204
|
+
All other props are inherited from `IBaseLoaderProps`.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
### SpinDotsLoader Component
|
|
209
|
+
|
|
210
|
+
The `SpinDotsLoader` creates a circular orbit of dots, perfect for inline text loading indicators.
|
|
211
|
+
|
|
212
|
+
#### Basic Usage
|
|
213
|
+
|
|
214
|
+
```jsx
|
|
215
|
+
import { SpinDotsLoader } from "react-loadly";
|
|
216
|
+
|
|
217
|
+
function App() {
|
|
218
|
+
return (
|
|
219
|
+
<div>
|
|
220
|
+
{/* Default 3 dots */}
|
|
221
|
+
<SpinDotsLoader />
|
|
222
|
+
|
|
223
|
+
{/* Custom number of dots */}
|
|
224
|
+
<SpinDotsLoader dots={5} />
|
|
225
|
+
|
|
226
|
+
{/* Custom size and color */}
|
|
227
|
+
<SpinDotsLoader size={50} color="#10b981" />
|
|
228
|
+
</div>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### SpinDotsLoader Props
|
|
234
|
+
|
|
235
|
+
| Prop | Type | Default | Description |
|
|
236
|
+
| ------- | ---------------- | --------- | -------------------------- |
|
|
237
|
+
| `dots` | number | 3 | Number of dots in orbit |
|
|
238
|
+
| `gap` | number | 8 | Gap between dots |
|
|
239
|
+
| `size` | number \| string | 40 | Size of the loader |
|
|
240
|
+
| `color` | string | "#6366f1" | Color of the dots |
|
|
241
|
+
| `speed` | number | 1 | Animation speed multiplier |
|
|
242
|
+
|
|
243
|
+
All other props are inherited from `IBaseLoaderProps`.
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
### HeatmapLoader Component
|
|
248
|
+
|
|
249
|
+
The `HeatmapLoader` displays a grid of pulses with staggered timing, useful for dashboard data placeholders.
|
|
250
|
+
|
|
251
|
+
#### Basic Usage
|
|
252
|
+
|
|
253
|
+
```jsx
|
|
254
|
+
import { HeatmapLoader } from "react-loadly";
|
|
255
|
+
|
|
256
|
+
function App() {
|
|
257
|
+
return (
|
|
258
|
+
<div>
|
|
259
|
+
{/* Default 3x5 grid */}
|
|
260
|
+
<HeatmapLoader />
|
|
261
|
+
|
|
262
|
+
{/* Custom grid size */}
|
|
263
|
+
<HeatmapLoader rows={4} cols={6} />
|
|
264
|
+
|
|
265
|
+
{/* Custom size and color */}
|
|
266
|
+
<HeatmapLoader size={60} color="#10b981" />
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
#### HeatmapLoader Props
|
|
273
|
+
|
|
274
|
+
| Prop | Type | Default | Description |
|
|
275
|
+
| ------- | ---------------- | --------- | -------------------------- |
|
|
276
|
+
| `rows` | number | 3 | Number of rows in grid |
|
|
277
|
+
| `cols` | number | 5 | Number of columns in grid |
|
|
278
|
+
| `size` | number \| string | 40 | Size of the loader |
|
|
279
|
+
| `color` | string | "#6366f1" | Color of the cells |
|
|
280
|
+
| `speed` | number | 1 | Animation speed multiplier |
|
|
281
|
+
|
|
282
|
+
All other props are inherited from `IBaseLoaderProps`.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
### ClockLoader Component
|
|
287
|
+
|
|
288
|
+
The `ClockLoader` animates like a traditional clock with hour, minute, and second hands.
|
|
289
|
+
|
|
290
|
+
#### Basic Usage
|
|
291
|
+
|
|
292
|
+
```jsx
|
|
293
|
+
import { ClockLoader } from "react-loadly";
|
|
294
|
+
|
|
295
|
+
function App() {
|
|
296
|
+
return (
|
|
297
|
+
<div>
|
|
298
|
+
{/* Default clock */}
|
|
299
|
+
<ClockLoader />
|
|
300
|
+
|
|
301
|
+
{/* Custom size */}
|
|
302
|
+
<ClockLoader size={60} />
|
|
303
|
+
|
|
304
|
+
{/* Custom tick speed */}
|
|
305
|
+
<ClockLoader tickSpeed={2} />
|
|
306
|
+
</div>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
#### ClockLoader Props
|
|
312
|
+
|
|
313
|
+
| Prop | Type | Default | Description |
|
|
314
|
+
| ----------- | ---------------- | --------- | ------------------------ |
|
|
315
|
+
| `size` | number \| string | 40 | Size of the clock |
|
|
316
|
+
| `tickSpeed` | number | 1 | Speed of clock animation |
|
|
317
|
+
| `color` | string | "#6366f1" | Color of the clock hands |
|
|
318
|
+
|
|
319
|
+
All other props are inherited from `IBaseLoaderProps`.
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
### NeumorphicLoader Component
|
|
324
|
+
|
|
325
|
+
The `NeumorphicLoader` creates a soft neumorphic pill/dots loader for modern UI designs.
|
|
326
|
+
|
|
327
|
+
#### Basic Usage
|
|
328
|
+
|
|
329
|
+
```jsx
|
|
330
|
+
import { NeumorphicLoader } from "react-loadly";
|
|
331
|
+
|
|
332
|
+
function App() {
|
|
333
|
+
return (
|
|
334
|
+
<div>
|
|
335
|
+
{/* Default elevation */}
|
|
336
|
+
<NeumorphicLoader />
|
|
337
|
+
|
|
338
|
+
{/* Custom elevation */}
|
|
339
|
+
<NeumorphicLoader elevation={8} />
|
|
340
|
+
|
|
341
|
+
{/* Custom size and color */}
|
|
342
|
+
<NeumorphicLoader size={50} color="#10b981" />
|
|
343
|
+
</div>
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
#### NeumorphicLoader Props
|
|
349
|
+
|
|
350
|
+
| Prop | Type | Default | Description |
|
|
351
|
+
| ----------- | ---------------- | --------- | -------------------------- |
|
|
352
|
+
| `elevation` | number | 5 | Elevation level (1-10) |
|
|
353
|
+
| `size` | number \| string | 40 | Size of the loader |
|
|
354
|
+
| `color` | string | "#6366f1" | Color of the loader |
|
|
355
|
+
| `speed` | number | 1 | Animation speed multiplier |
|
|
356
|
+
|
|
357
|
+
All other props are inherited from `IBaseLoaderProps`.
|
|
122
358
|
|
|
123
359
|
---
|
|
124
360
|
|
|
@@ -220,6 +456,125 @@ The SkeletonLoader supports multiple variants to match different content types:
|
|
|
220
456
|
|
|
221
457
|
---
|
|
222
458
|
|
|
459
|
+
## π€ AutoSkeletonLoader Component
|
|
460
|
+
|
|
461
|
+
The `AutoSkeletonLoader` is an advanced component that automatically generates skeleton loaders based on the structure of your actual components. It analyzes your component's JSX tree and creates matching skeleton placeholders.
|
|
462
|
+
|
|
463
|
+
### Key Features
|
|
464
|
+
|
|
465
|
+
- **Automatic Generation**: Scans the JSX tree of your component and replaces each element with a matching skeleton placeholder
|
|
466
|
+
- **Smart Dimension Estimation**: Automatically estimates skeleton dimensions based on element types and content
|
|
467
|
+
- **Style Inheritance**: Optionally inherits inline styles and props directly from the original element
|
|
468
|
+
- **Customizable Class Names**: Override styles per element type for fine-grained control
|
|
469
|
+
- **Variant Support**: Automatically selects appropriate skeleton variants (rect, circle, text) based on element type
|
|
470
|
+
- **Consistent Animations**: Shimmer effect support that's consistent with SkeletonLoader
|
|
471
|
+
- **Smooth Transitions**: Built-in fade-in/out animations between skeleton and real component
|
|
472
|
+
- **Accessibility**: Full ARIA support and screen reader compatibility
|
|
473
|
+
- **Performance Optimized**: Uses React.memo and useMemo for optimal re-rendering
|
|
474
|
+
|
|
475
|
+
### Basic Usage
|
|
476
|
+
|
|
477
|
+
```jsx
|
|
478
|
+
import { AutoSkeletonLoader } from "react-loadly";
|
|
479
|
+
|
|
480
|
+
function UserProfile({ user, loading }) {
|
|
481
|
+
return <AutoSkeletonLoader loading={loading} component={<UserProfileCard user={user} />} />;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function UserProfileCard({ user }) {
|
|
485
|
+
return (
|
|
486
|
+
<div>
|
|
487
|
+
<img src={user.avatar} alt={user.name} width="100" height="100" />
|
|
488
|
+
<h3>{user.name}</h3>
|
|
489
|
+
<p>{user.bio}</p>
|
|
490
|
+
<button>Follow</button>
|
|
491
|
+
</div>
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### Advanced Usage Examples
|
|
497
|
+
|
|
498
|
+
#### Style Inheritance
|
|
499
|
+
|
|
500
|
+
```jsx
|
|
501
|
+
// Inherits styles from original elements for more accurate skeletons
|
|
502
|
+
<AutoSkeletonLoader loading={loading} component={<UserProfileCard user={user} />} inheritStyles={true} />
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
#### Custom Class Names
|
|
506
|
+
|
|
507
|
+
```jsx
|
|
508
|
+
// Customize skeleton appearance per element type
|
|
509
|
+
<AutoSkeleton
|
|
510
|
+
loading={loading}
|
|
511
|
+
component={<Card data={data} />}
|
|
512
|
+
styless={{
|
|
513
|
+
p: { height: "0.8em", width: "80%" },
|
|
514
|
+
h3: { height: "1.2em", width: "60%", borderRadius: "8px" },
|
|
515
|
+
img: { borderRadius: "12px" },
|
|
516
|
+
button: { width: "150px", height: "50px" },
|
|
517
|
+
}}
|
|
518
|
+
/>
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
#### With Shimmer Effects
|
|
522
|
+
|
|
523
|
+
```jsx
|
|
524
|
+
// Enable shimmer animations for a more polished look
|
|
525
|
+
<AutoSkeleton
|
|
526
|
+
loading={loading}
|
|
527
|
+
component={<ProductCard product={product} />}
|
|
528
|
+
shimmer={true}
|
|
529
|
+
shimmerColor="rgba(255, 255, 255, 0.8)"
|
|
530
|
+
highlightColor="#f8fafc"
|
|
531
|
+
/>
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
#### Complex Component Example
|
|
535
|
+
|
|
536
|
+
```jsx
|
|
537
|
+
function DashboardCard({ title, metrics, loading }) {
|
|
538
|
+
return (
|
|
539
|
+
<AutoSkeletonLoader
|
|
540
|
+
loading={loading}
|
|
541
|
+
component={
|
|
542
|
+
<div className="dashboard-card">
|
|
543
|
+
<h2>{title}</h2>
|
|
544
|
+
<div className="metrics">
|
|
545
|
+
{metrics.map((metric, index) => (
|
|
546
|
+
<div key={index} className="metric">
|
|
547
|
+
<span className="value">{metric.value}</span>
|
|
548
|
+
<span className="label">{metric.label}</span>
|
|
549
|
+
</div>
|
|
550
|
+
))}
|
|
551
|
+
</div>
|
|
552
|
+
</div>
|
|
553
|
+
}
|
|
554
|
+
inheritStyles={true}
|
|
555
|
+
shimmer={true}
|
|
556
|
+
/>
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### AutoSkeleton Props
|
|
562
|
+
|
|
563
|
+
| Prop | Type | Default | Description |
|
|
564
|
+
| ---------------- | ------------------------------------------------------------------------ | ----------------------- | ------------------------------------------------ |
|
|
565
|
+
| `component` | ReactElement | - | The component to render or analyze for skeletons |
|
|
566
|
+
| `inheritStyles` | boolean | false | Whether to inherit styles from original elements |
|
|
567
|
+
| `styless` | object | {} | Custom styles for different element types |
|
|
568
|
+
| `shimmer` | boolean | true | Whether to show shimmer animation |
|
|
569
|
+
| `shimmerColor` | string | "rgba(255,255,255,0.6)" | Shimmer effect color |
|
|
570
|
+
| `highlightColor` | string | "#f1f5f9" | Highlight color for shimmer effect |
|
|
571
|
+
| `waveWidth` | number \| string | "200px" | Shimmer wave width |
|
|
572
|
+
| `waveDirection` | "left-to-right" \| "right-to-left" \| "top-to-bottom" \| "bottom-to-top" | "left-to-right" | Direction of shimmer animation |
|
|
573
|
+
|
|
574
|
+
All other props are inherited from `IBaseLoaderProps`.
|
|
575
|
+
|
|
576
|
+
---
|
|
577
|
+
|
|
223
578
|
## β‘ Performance & Best Practices
|
|
224
579
|
|
|
225
580
|
### Performance Optimization
|
|
@@ -243,32 +598,32 @@ import \* as Loaders from "react-loadly";
|
|
|
243
598
|
|
|
244
599
|
// β
Good: Use appropriate loader for context
|
|
245
600
|
function UserProfile({ user, loading }) {
|
|
246
|
-
if (loading) {
|
|
247
|
-
return (
|
|
248
|
-
<div>
|
|
249
|
-
<SkeletonLoader variant="avatar" size={60} />
|
|
250
|
-
<SkeletonLoader lines={2} />
|
|
251
|
-
</div>
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
return <div>{/_ User content _/}</div>;
|
|
601
|
+
if (loading) {
|
|
602
|
+
return (
|
|
603
|
+
<div>
|
|
604
|
+
<SkeletonLoader variant="avatar" size={60} />
|
|
605
|
+
<SkeletonLoader lines={2} />
|
|
606
|
+
</div>
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
return <div>{/_ User content _/}</div>;
|
|
255
610
|
}
|
|
256
611
|
|
|
257
612
|
// β
Good: Conditional rendering
|
|
258
613
|
function DataComponent({ data, loading }) {
|
|
259
|
-
return <div>{loading ? <SpinLoader /> : <div>{data}</div>}</div>;
|
|
614
|
+
return <div>{loading ? <SpinLoader /> : <div>{data}</div>}</div>;
|
|
260
615
|
}
|
|
261
616
|
|
|
262
617
|
// β
Good: Use fullscreen for page-level loading
|
|
263
618
|
function App() {
|
|
264
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
619
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
265
620
|
|
|
266
|
-
return (
|
|
267
|
-
<div>
|
|
268
|
-
{isLoading && <SpinLoader fullscreen loaderCenter screenBackground="rgba(255, 255, 255, 0.9)" />}
|
|
269
|
-
{/_ App content _/}
|
|
270
|
-
</div>
|
|
271
|
-
);
|
|
621
|
+
return (
|
|
622
|
+
<div>
|
|
623
|
+
{isLoading && <SpinLoader fullscreen loaderCenter screenBackground="rgba(255, 255, 255, 0.9)" />}
|
|
624
|
+
{/_ App content _/}
|
|
625
|
+
</div>
|
|
626
|
+
);
|
|
272
627
|
}
|
|
273
628
|
|
|
274
629
|
```
|
|
@@ -287,7 +642,7 @@ import dynamic from "next/dynamic";
|
|
|
287
642
|
|
|
288
643
|
const SkeletonLoader = dynamic(() => import("react-loadly").then((mod) => ({ default: mod.SkeletonLoader })));
|
|
289
644
|
|
|
290
|
-
|
|
645
|
+
```
|
|
291
646
|
|
|
292
647
|
---
|
|
293
648
|
|
|
@@ -301,13 +656,13 @@ Accessibility is a core feature, not an afterthought. All loaders include:
|
|
|
301
656
|
|
|
302
657
|
<!-- end list -->
|
|
303
658
|
|
|
304
|
-
|
|
659
|
+
``jsx
|
|
305
660
|
// Accessible by default
|
|
306
661
|
<SpinLoader aria-label="Loading content" />
|
|
307
662
|
|
|
308
663
|
// Custom accessible text
|
|
309
664
|
<PulseLoader showText loadingText="Processing your request..." />
|
|
310
|
-
|
|
665
|
+
```
|
|
311
666
|
|
|
312
667
|
---
|
|
313
668
|
|
|
@@ -392,7 +747,7 @@ Display any loader in fullscreen mode with customizable dimensions and backgroun
|
|
|
392
747
|
loaderCenter={true}
|
|
393
748
|
screenBackground="rgba(0, 0, 0, 0.5)"
|
|
394
749
|
/>
|
|
395
|
-
|
|
750
|
+
```
|
|
396
751
|
|
|
397
752
|
---
|
|
398
753
|
|
|
@@ -404,7 +759,7 @@ Display any loader in fullscreen mode with customizable dimensions and backgroun
|
|
|
404
759
|
import { SkeletonLoader, SpinLoader, PulseLoader } from "react-loadly";
|
|
405
760
|
|
|
406
761
|
function ContentLoader() {
|
|
407
|
-
return (
|
|
762
|
+
return (
|
|
408
763
|
|
|
409
764
|
<div>
|
|
410
765
|
{/_ Blog post loading Dashboard loading _/}
|
|
@@ -426,7 +781,7 @@ return (
|
|
|
426
781
|
</div>
|
|
427
782
|
</div>
|
|
428
783
|
|
|
429
|
-
);
|
|
784
|
+
);
|
|
430
785
|
}
|
|
431
786
|
|
|
432
787
|
```
|
|
@@ -461,8 +816,8 @@ function FormWithLoading() {
|
|
|
461
816
|
|
|
462
817
|
``jsx
|
|
463
818
|
function DataTable({ data, loading }) {
|
|
464
|
-
if (loading) {
|
|
465
|
-
return (
|
|
819
|
+
if (loading) {
|
|
820
|
+
return (
|
|
466
821
|
|
|
467
822
|
<div className="data-table">
|
|
468
823
|
{/_ Header skeleton _/}
|
|
@@ -483,9 +838,9 @@ return (
|
|
|
483
838
|
</div>
|
|
484
839
|
);
|
|
485
840
|
|
|
486
|
-
}
|
|
841
|
+
}
|
|
487
842
|
|
|
488
|
-
return <div className="data-table">{/_ Actual table content _/}</div>;
|
|
843
|
+
return <div className="data-table">{/_ Actual table content _/}</div>;
|
|
489
844
|
}
|
|
490
845
|
|
|
491
846
|
```
|
|
@@ -676,3 +1031,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
676
1031
|
---
|
|
677
1032
|
|
|
678
1033
|
**Made with β€οΈ by the React Loadly community**
|
|
1034
|
+
````
|