react-loadly 1.0.0 โ 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 +619 -44
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +215 -70
- package/dist/index.esm.js +1 -1370
- 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 +14 -0
- package/dist/types/@types/interfaces/IBaseLoaderProps.d.ts.map +1 -1
- package/dist/types/@types/interfaces/IElementLoaderProps.d.ts +11 -0
- package/dist/types/@types/interfaces/IElementLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IFallbackLoaderProps.d.ts +2 -1
- package/dist/types/@types/interfaces/IFallbackLoaderProps.d.ts.map +1 -1
- package/dist/types/@types/interfaces/ILogoLoaderProps.d.ts +1 -1
- package/dist/types/@types/interfaces/ILogoLoaderProps.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/ITextLoaderProps.d.ts +1 -2
- package/dist/types/@types/interfaces/ITextLoaderProps.d.ts.map +1 -1
- 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/__tests__/ElementLoader.example.d.ts +4 -0
- package/dist/types/__tests__/ElementLoader.example.d.ts.map +1 -0
- package/dist/types/components/atoms/Circle.d.ts +2 -1
- package/dist/types/components/atoms/Circle.d.ts.map +1 -1
- package/dist/types/components/atoms/Dot.d.ts +1 -1
- package/dist/types/components/atoms/Dot.d.ts.map +1 -1
- package/dist/types/components/atoms/Line.d.ts +1 -1
- package/dist/types/components/atoms/Line.d.ts.map +1 -1
- package/dist/types/components/atoms/Rectangle.d.ts +1 -0
- package/dist/types/components/atoms/Rectangle.d.ts.map +1 -1
- package/dist/types/components/molecules/DotCluster.d.ts +1 -0
- package/dist/types/components/molecules/DotCluster.d.ts.map +1 -1
- package/dist/types/components/molecules/LineGroup.d.ts +1 -0
- package/dist/types/components/molecules/LineGroup.d.ts.map +1 -1
- package/dist/types/components/molecules/ShapeGroup.d.ts +1 -0
- package/dist/types/components/molecules/ShapeGroup.d.ts.map +1 -1
- package/dist/types/components/organisms/BarsLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/BlobLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/BounceLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/DotsLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/ElementLoader.d.ts +27 -0
- package/dist/types/components/organisms/ElementLoader.d.ts.map +1 -0
- 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/FlowLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/GridLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/LiquidLoader.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/PulseLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/RingLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/RotateLoader.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/SpinLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/TypingLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/WaveLoader.d.ts.map +1 -1
- package/dist/types/components/organisms/index.d.ts +9 -6
- package/dist/types/components/organisms/index.d.ts.map +1 -1
- package/dist/types/hooks/useLoaderState.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 +49 -24
- package/dist/index.js +0 -1409
- package/dist/index.js.map +0 -1
- 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,13 +1,13 @@
|
|
|
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.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[](https://www.npmjs.com/package/react-loadly)
|
|
7
|
-
[](https://bundlephobia.com/result?p=react-loadly)
|
|
8
|
-
[](https://github.com/react-loaders/react-loaders/blob/main/LICENSE)
|
|
6
|
+
Perfect for building **React apps, dashboards, forms, and data-driven UIs** where you need smooth, customizable loading states.
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
[](https://www.npmjs.com/package/react-loadly)
|
|
9
|
+
[](https://bundlephobia.com/result?p=react-loadly)
|
|
10
|
+
[](https://github.com/Mostafashadow1/react-loadly/blob/main/LICENSE)
|
|
11
11
|
|
|
12
12
|
## โจ Key Features
|
|
13
13
|
|
|
@@ -18,6 +18,7 @@ A professional, high-performance, and accessible collection of **React loader co
|
|
|
18
18
|
- **Tree-Shakable**: Supports modern bundlers to only include what you use.
|
|
19
19
|
- **Reduced Motion**: Respects the user's `prefers-reduced-motion` settings.
|
|
20
20
|
- **SSR Compatible**: Works out-of-the-box with frameworks like **Next.js**.
|
|
21
|
+
- **Fullscreen Support**: Display loaders in fullscreen mode with customizable backgrounds.
|
|
21
22
|
|
|
22
23
|
---
|
|
23
24
|
|
|
@@ -35,6 +36,24 @@ yarn add react-loadly
|
|
|
35
36
|
pnpm add react-loadly
|
|
36
37
|
```
|
|
37
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
|
+
|
|
38
57
|
### Quick Usage
|
|
39
58
|
|
|
40
59
|
Import the components you need along with the base styles, then use them in your React application.
|
|
@@ -62,23 +81,336 @@ function App() {
|
|
|
62
81
|
|
|
63
82
|
### Geometric Loaders
|
|
64
83
|
|
|
65
|
-
| Component
|
|
66
|
-
|
|
|
67
|
-
| `SpinLoader`
|
|
68
|
-
| `PulseLoader`
|
|
69
|
-
| `WaveLoader`
|
|
70
|
-
| `GridLoader`
|
|
71
|
-
| `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. |
|
|
72
94
|
|
|
73
95
|
---
|
|
74
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
|
+
|
|
75
104
|
### Organic & Text-Based Loaders
|
|
76
105
|
|
|
77
|
-
| Component |
|
|
78
|
-
| -------------- |
|
|
79
|
-
| `BlobLoader` |
|
|
80
|
-
| `TypingLoader` |
|
|
81
|
-
| `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. |
|
|
113
|
+
|
|
114
|
+
### Flexible Loaders
|
|
115
|
+
|
|
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
|
+
```
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## ๐งฉ ElementLoader Component
|
|
253
|
+
|
|
254
|
+
The `ElementLoader` is a versatile component that can wrap any React element and apply various loading animations to it. Unlike other loaders that are pre-designed with specific visuals, the ElementLoader allows you to use your own elements (icons, divs, images, etc.) as the loading indicator.
|
|
255
|
+
|
|
256
|
+
### Basic Usage
|
|
257
|
+
|
|
258
|
+
```jsx
|
|
259
|
+
import { ElementLoader } from "react-loadly";
|
|
260
|
+
|
|
261
|
+
function App() {
|
|
262
|
+
return (
|
|
263
|
+
<ElementLoader>
|
|
264
|
+
<div style={{ width: "40px", height: "40px", backgroundColor: "blue" }} />
|
|
265
|
+
</ElementLoader>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Animation Types
|
|
271
|
+
|
|
272
|
+
The ElementLoader supports multiple animation types:
|
|
273
|
+
|
|
274
|
+
```jsx
|
|
275
|
+
// Spin animation (default)
|
|
276
|
+
<ElementLoader animationType="spin">
|
|
277
|
+
<YourIconComponent />
|
|
278
|
+
</ElementLoader>
|
|
279
|
+
|
|
280
|
+
// Pulse animation
|
|
281
|
+
<ElementLoader animationType="pulse">
|
|
282
|
+
<YourIconComponent />
|
|
283
|
+
</ElementLoader>
|
|
284
|
+
|
|
285
|
+
// Glow animation
|
|
286
|
+
<ElementLoader animationType="glow">
|
|
287
|
+
<YourIconComponent />
|
|
288
|
+
</ElementLoader>
|
|
289
|
+
|
|
290
|
+
// Bounce animation
|
|
291
|
+
<ElementLoader animationType="bounce">
|
|
292
|
+
<YourIconComponent />
|
|
293
|
+
</ElementLoader>
|
|
294
|
+
|
|
295
|
+
// Flip animation
|
|
296
|
+
<ElementLoader animationType="flip">
|
|
297
|
+
<YourIconComponent />
|
|
298
|
+
</ElementLoader>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Customization Options
|
|
302
|
+
|
|
303
|
+
``jsx
|
|
304
|
+
<ElementLoader size={80} color="#ff6b6b" speed={1.5} glowIntensity={0.5} showText loadingText="Loading...">
|
|
305
|
+
<YourCustomElement />
|
|
306
|
+
</ElementLoader>
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Fullscreen Mode
|
|
311
|
+
|
|
312
|
+
Like other loaders, ElementLoader supports fullscreen mode:
|
|
313
|
+
|
|
314
|
+
``jsx
|
|
315
|
+
<ElementLoader fullscreen loaderCenter screenBackground="rgba(0, 0, 0, 0.5)">
|
|
316
|
+
<YourIconComponent />
|
|
317
|
+
</ElementLoader>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Props
|
|
321
|
+
|
|
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
|
+
````
|
|
82
414
|
|
|
83
415
|
---
|
|
84
416
|
|
|
@@ -98,7 +430,7 @@ Accessibility is a core feature, not an afterthought. All loaders include:
|
|
|
98
430
|
|
|
99
431
|
// Custom accessible text
|
|
100
432
|
<PulseLoader showText loadingText="Processing your request..." />
|
|
101
|
-
|
|
433
|
+
````
|
|
102
434
|
|
|
103
435
|
---
|
|
104
436
|
|
|
@@ -131,6 +463,180 @@ interface BaseLoaderProps {
|
|
|
131
463
|
style?: React.CSSProperties;
|
|
132
464
|
showText?: boolean;
|
|
133
465
|
loadingText?: string;
|
|
466
|
+
// Fullscreen props
|
|
467
|
+
fullscreen?: boolean;
|
|
468
|
+
screenWidth?: number | string;
|
|
469
|
+
screenHeight?: number | string;
|
|
470
|
+
loaderCenter?: boolean;
|
|
471
|
+
screenBackground?: string;
|
|
472
|
+
}
|
|
473
|
+
```
|
|
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
|
+
|
|
497
|
+
### Fullscreen Mode
|
|
498
|
+
|
|
499
|
+
Display any loader in fullscreen mode with customizable dimensions and background:
|
|
500
|
+
|
|
501
|
+
```jsx
|
|
502
|
+
// Fullscreen loader covering entire viewport
|
|
503
|
+
<SpinLoader
|
|
504
|
+
fullscreen={true}
|
|
505
|
+
loaderCenter={true}
|
|
506
|
+
screenBackground="#f0f0f0"
|
|
507
|
+
/>
|
|
508
|
+
|
|
509
|
+
// Fullscreen loader with custom dimensions
|
|
510
|
+
<PulseLoader
|
|
511
|
+
fullscreen={true}
|
|
512
|
+
screenWidth={800}
|
|
513
|
+
screenHeight={600}
|
|
514
|
+
loaderCenter={true}
|
|
515
|
+
screenBackground="rgba(0, 0, 0, 0.5)"
|
|
516
|
+
/>
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
---
|
|
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
|
+
);
|
|
134
640
|
}
|
|
135
641
|
```
|
|
136
642
|
|
|
@@ -181,40 +687,109 @@ function DataComponent() {
|
|
|
181
687
|
}
|
|
182
688
|
```
|
|
183
689
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
A component to gracefully handle and display errors, timeouts, or network issues.
|
|
690
|
+
---
|
|
187
691
|
|
|
188
|
-
|
|
189
|
-
import { FallbackLoader } from "react-loadly";
|
|
692
|
+
## ๐ค Contributing
|
|
190
693
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
```
|
|
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
|
|
201
751
|
|
|
202
752
|
---
|
|
203
753
|
|
|
204
|
-
##
|
|
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
|
|
205
771
|
|
|
206
|
-
|
|
772
|
+
We recognize contributors in several ways:
|
|
207
773
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
5. Open a pull request.
|
|
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
|
|
213
778
|
|
|
214
779
|
---
|
|
215
780
|
|
|
216
781
|
## ๐ License
|
|
217
782
|
|
|
218
|
-
This project is licensed under the
|
|
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
|
+
---
|
|
219
794
|
|
|
220
|
-
|
|
795
|
+
**Made with โค๏ธ by the React Loadly community**
|