react-loadly 2.3.2 → 2.4.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 CHANGED
@@ -12,10 +12,118 @@ Perfect for building **React applications, React dashboards, forms, and data-dri
12
12
 
13
13
  🏠 **Home Page**: [https://Mostafashadow1.github.io/react-loadly-showCases/](https://Mostafashadow1.github.io/react-loadly-showCases/)
14
14
 
15
- [![NPM Version](https://img.shields.io/npm/v/react-loadly.svg)](https://www.npmjs.com/package/react-loadly)
16
- [![Bundle Size](https://img.shields.io/bundlephobia/minzip/react-loadly.svg)](https://bundlephobia.com/result?p=react-loadly)
15
+ [![NPM Version](https://img.shields.io/npm/v/react-loadly.svg)](https://www.npmjs.com/package/react-loadly)
16
+ [![Version](https://img.shields.io/badge/version-2.4.0-blue.svg)](https://github.com/Mostafashadow1/react-loadly)
17
+ [![Bundle Size](https://img.shields.io/bundlephobia/minzip/react-loadly.svg)](https://bundlephobia.com/result?p=react-loadly)
17
18
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Mostafashadow1/react-loadly/blob/main/LICENSE)
18
19
 
20
+ ---
21
+
22
+ ## 🚀 Getting Started
23
+
24
+ ### Installation
25
+
26
+ Install the package using your preferred package manager.
27
+
28
+ ```bash
29
+ npm install react-loadly
30
+ # or
31
+ yarn add react-loadly
32
+ # or
33
+ pnpm i react-loadly
34
+ ```
35
+
36
+ ---
37
+
38
+ ## 🤖 AutoSkeletonLoader — The Zero-Manual-Work Skeleton Engine
39
+
40
+ Stop wasting time designing manual skeleton screens for every UI update. The **AutoSkeletonLoader** is an industry-leading React engine that dynamically analyzes your components at runtime and generates matching, high-fidelity skeleton placeholders automatically.
41
+
42
+ ### 🧠 The Tech Behind the Magic
43
+
44
+ The AutoSkeletonLoader doesn't just show a generic grey box; it uses **Dynamic Runtime VDOM Traversal** to mirror your UI's exact hierarchy.
45
+
46
+ * **Advanced Component Decoding**: Fully supports modern React patterns including `React.memo`, `forwardRef`, `React.lazy`, and `React.Fragments`. It recursively "unwraps" Higher-Order Components to find the underlying UI structure.
47
+ * **Hooks-Resilient "Safe Render"**: Our proprietary `safeRender` mechanism allows the engine to traverse components that use `useState`, `useTranslation`, or `useContext` without crashing. It gracefully handles missing data dependencies that normally break skeleton rendering.
48
+ * **Intelligence (Heuristic Estimation)**: Built-in analysis predicts dimensions for Atoms (Text, Buttons, Badges, Images) and Molecules (Cards, Lists) based on naming conventions and HTML metadata.
49
+ * **Animation Continuity (Stable Key Algorithm)**: v2.4.x introduces a stable keying algorithm that ensures shimmer animations don't "reset" or flicker when your component's state changes.
50
+ * **Smart Memoization**: The VDOM analysis is extremely fast and memoized, occurring only when the component structure or configuration changes.
51
+
52
+ ---
53
+
54
+ ### 🚀 Full Example: The WorkerCard Molecule
55
+
56
+ In this example, we take a complex card with multiple hooks and nested components. See how `AutoSkeletonLoader` handles it with zero extra code.
57
+
58
+ ```tsx
59
+ import { AutoSkeletonLoader } from "react-loadly";
60
+ import "react-loadly/styles.css";
61
+
62
+ // A complex component with hooks, memo, and sub-components
63
+ const WorkerCard = React.memo(({ data }) => {
64
+ const { t } = useTranslation();
65
+ return (
66
+ <div className="card-container">
67
+ <div className="flex gap-4">
68
+ <img src={data.avatar} className="rounded-full w-12 h-12" />
69
+ <div>
70
+ <h3 className="text-lg font-bold">{data.name}</h3>
71
+ <p className="text-gray-500">{data.role}</p>
72
+ </div>
73
+ </div>
74
+ <div className="mt-4">
75
+ <BadgeAtom text={data.status} variant="success" />
76
+ </div>
77
+ <BaseButtonAtom text="View Profile" onClick={handleProfile} />
78
+ </div>
79
+ );
80
+ });
81
+
82
+ // Implementation
83
+ function Dashboard({ isLoading, worker }) {
84
+ return (
85
+ <AutoSkeletonLoader
86
+ loading={isLoading}
87
+ inheritStyles={true}
88
+ shimmer={true}
89
+ component={<WorkerCard data={worker} />}
90
+ />
91
+ );
92
+ }
93
+ ```
94
+
95
+ ---
96
+
97
+ ### 📊 Comparison: Why AutoSkeletonLoader?
98
+
99
+ | Feature | Manual Skeletons (`SkeletonLoader`) | **AutoSkeletonLoader** (AI-Powered) |
100
+ | :--- | :--- | :--- |
101
+ | **Setup Time** | High (Design every line/block) | **Near-Zero** (Drop in and go) |
102
+ | **Maintenance** | Brittle (Breaks on UI changes) | **Self-Healing** (Adapts to UI changes) |
103
+ | **Accuracy** | Approximate | **Dynamic Match** (1:1 VDOM Mapping) |
104
+ | **Code Weight** | Verbose JSX boilerplate | **Single Component Wrapper** |
105
+ | **HOC Support** | Manual | **Automatic** (`memo`, `forwardRef`) |
106
+
107
+ ---
108
+
109
+ ### ⚙️ AutoSkeletonLoader Props (IAutoSkeletonProps)
110
+
111
+ | Prop | Type | Default | Description |
112
+ | :--- | :--- | :--- | :--- |
113
+ | `component` | `ReactElement` | **Required** | The actual component to analyze and mirror. |
114
+ | `loading` | `boolean` | `true` | When `false`, the real component is rendered with a smooth transition. |
115
+ | `inheritStyles` | `boolean` | `false` | If `true`, skeleton blocks will copy `style` and `className` from original elements. |
116
+ | `styless` | `Record<string, CSSProperties>` | `{}` | Key-value pairs to override dimensions for specific tags (e.g., `{ h1: { width: '50%'} }`). |
117
+ | `shimmer` | `boolean` | `true` | Enables the high-performance GPU-accelerated shimmer wave. |
118
+ | `speed` | `number` | `1` | Animation speed multiplier (higher is faster). |
119
+ | `color` | `string` | `"#e2e8f0"` | The base background color of the skeleton blocks. |
120
+ | `highlightColor`| `string` | `"#f1f5f9"` | The highlight color used in the shimmer gradient. |
121
+ | `waveWidthValue` | `string` | `"200px"` | Width of the shimmer wave gradient. |
122
+ | `waveDirection` | `String` | `"left-to-right"` | Shimmer direction: `left-to-right`, `right-to-left`, etc. |
123
+ | `aria-label` | `string` | `"Loading content..."` | Accessible label for screen readers. |
124
+
125
+ ---
126
+
19
127
  ## ✨ Key Features
20
128
 
21
129
  - **High Performance**: Uses hardware-accelerated CSS transforms and animations.
@@ -30,7 +138,7 @@ Perfect for building **React applications, React dashboards, forms, and data-dri
30
138
 
31
139
  ---
32
140
 
33
- ## 🆕 What's New
141
+ ## 🆕 What's New (v2.4.0)
34
142
 
35
143
  We've added **7 exciting new loaders** to expand your loading animation options:
36
144
 
@@ -52,20 +160,6 @@ All new loaders support:
52
160
 
53
161
  ---
54
162
 
55
- ## 🚀 Getting Started
56
-
57
- ### Installation
58
-
59
- Install the package using your preferred package manager.
60
-
61
- ```bash
62
- npm install react-loadly
63
- # or
64
- yarn add react-loadly
65
- # or
66
- pnpm i react-loadly
67
- ```
68
-
69
163
  ### Bundle Optimization
70
164
 
71
165
  React Loadly is optimized for minimal bundle size and supports tree shaking:
@@ -168,6 +262,7 @@ The `ProgressRingLoader` is an accessible progress ring component that supports
168
262
 
169
263
  ```jsx
170
264
  import { ProgressRingLoader } from "react-loadly";
265
+ import "react-loadly/styles.css";
171
266
 
172
267
  function App() {
173
268
  return (
@@ -206,6 +301,7 @@ The `MorphLoader` creates smooth morphing SVG shapes that interpolate between di
206
301
 
207
302
  ```jsx
208
303
  import { MorphLoader } from "react-loadly";
304
+ import "react-loadly/styles.css";
209
305
 
210
306
  function App() {
211
307
  return (
@@ -247,6 +343,7 @@ The `SpinDotsLoader` creates a circular orbit of dots, perfect for inline text l
247
343
 
248
344
  ```jsx
249
345
  import { SpinDotsLoader } from "react-loadly";
346
+ import "react-loadly/styles.css";
250
347
 
251
348
  function App() {
252
349
  return (
@@ -286,6 +383,7 @@ The `HeatmapLoader` displays a grid of pulses with staggered timing, useful for
286
383
 
287
384
  ```jsx
288
385
  import { HeatmapLoader } from "react-loadly";
386
+ import "react-loadly/styles.css";
289
387
 
290
388
  function App() {
291
389
  return (
@@ -325,6 +423,7 @@ The `ClockLoader` animates like a traditional clock with hour, minute, and secon
325
423
 
326
424
  ```jsx
327
425
  import { ClockLoader } from "react-loadly";
426
+ import "react-loadly/styles.css";
328
427
 
329
428
  function App() {
330
429
  return (
@@ -362,6 +461,7 @@ The `NeumorphicLoader` creates a soft neumorphic pill/dots loader for modern UI
362
461
 
363
462
  ```jsx
364
463
  import { NeumorphicLoader } from "react-loadly";
464
+ import "react-loadly/styles.css";
365
465
 
366
466
  function App() {
367
467
  return (
@@ -400,6 +500,7 @@ The `OrbitLoader` creates a beautiful orbital animation with elements rotating a
400
500
 
401
501
  ```jsx
402
502
  import { OrbitLoader } from "react-loadly";
503
+ import "react-loadly/styles.css";
403
504
 
404
505
  function App() {
405
506
  return (
@@ -439,6 +540,7 @@ The `PlaneLoader` displays a 3D rotating cube with perspective transforms, creat
439
540
 
440
541
  ```jsx
441
542
  import { PlaneLoader } from "react-loadly";
543
+ import "react-loadly/styles.css";
442
544
 
443
545
  function App() {
444
546
  return (
@@ -477,6 +579,7 @@ The `RippleLoader` creates expanding ripple rings from a central point, similar
477
579
 
478
580
  ```jsx
479
581
  import { RippleLoader } from "react-loadly";
582
+ import "react-loadly/styles.css";
480
583
 
481
584
  function App() {
482
585
  return (
@@ -517,6 +620,7 @@ The `SquaresLoader` displays multiple rotating squares with varying delays and s
517
620
 
518
621
  ```jsx
519
622
  import { SquaresLoader } from "react-loadly";
623
+ import "react-loadly/styles.css";
520
624
 
521
625
  function App() {
522
626
  return (
@@ -556,6 +660,7 @@ The `StairLoader` creates cascading stair steps that animate in sequence, creati
556
660
 
557
661
  ```jsx
558
662
  import { StairLoader } from "react-loadly";
663
+ import "react-loadly/styles.css";
559
664
 
560
665
  function App() {
561
666
  return (
@@ -595,6 +700,7 @@ The `HashtagLoader` animates a hashtag symbol with a progressive drawing effect.
595
700
 
596
701
  ```jsx
597
702
  import { HashtagLoader } from "react-loadly";
703
+ import "react-loadly/styles.css";
598
704
 
599
705
  function App() {
600
706
  return (
@@ -633,6 +739,7 @@ The `SnakeLoader` creates a snake-like animation with flowing segments that move
633
739
 
634
740
  ```jsx
635
741
  import { SnakeLoader } from "react-loadly";
742
+ import "react-loadly/styles.css";
636
743
 
637
744
  function App() {
638
745
  return (
@@ -672,6 +779,7 @@ The `SkeletonLoader` is perfect for modern loading states, creating placeholder
672
779
 
673
780
  ```jsx
674
781
  import { SkeletonLoader } from "react-loadly";
782
+ import "react-loadly/styles.css";
675
783
 
676
784
  function App() {
677
785
  return (
@@ -762,125 +870,6 @@ The SkeletonLoader supports multiple variants to match different content types:
762
870
 
763
871
  ---
764
872
 
765
- ## 🤖 AutoSkeletonLoader Component
766
-
767
- 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.
768
-
769
- ### Key Features
770
-
771
- - **Automatic Generation**: Scans the JSX tree of your component and replaces each element with a matching skeleton placeholder
772
- - **Smart Dimension Estimation**: Automatically estimates skeleton dimensions based on element types and content
773
- - **Style Inheritance**: Optionally inherits inline styles and props directly from the original element
774
- - **Customizable Class Names**: Override styles per element type for fine-grained control
775
- - **Variant Support**: Automatically selects appropriate skeleton variants (rect, circle, text) based on element type
776
- - **Consistent Animations**: Shimmer effect support that's consistent with SkeletonLoader
777
- - **Smooth Transitions**: Built-in fade-in/out animations between skeleton and real component
778
- - **Accessibility**: Full ARIA support and screen reader compatibility
779
- - **Performance Optimized**: Uses React.memo and useMemo for optimal re-rendering
780
-
781
- ### Basic Usage
782
-
783
- ```jsx
784
- import { AutoSkeletonLoader } from "react-loadly";
785
-
786
- function UserProfile({ user, loading }) {
787
- return <AutoSkeletonLoader loading={loading} component={<UserProfileCard user={user} />} />;
788
- }
789
-
790
- function UserProfileCard({ user }) {
791
- return (
792
- <div>
793
- <img src={user.avatar} alt={user.name} width="100" height="100" />
794
- <h3>{user.name}</h3>
795
- <p>{user.bio}</p>
796
- <button>Follow</button>
797
- </div>
798
- );
799
- }
800
- ```
801
-
802
- ### Advanced Usage Examples
803
-
804
- #### Style Inheritance
805
-
806
- ```jsx
807
- // Inherits styles from original elements for more accurate skeletons
808
- <AutoSkeletonLoader loading={loading} component={<UserProfileCard user={user} />} inheritStyles={true} />
809
- ```
810
-
811
- #### Custom Class Names
812
-
813
- ```jsx
814
- // Customize skeleton appearance per element type
815
- <AutoSkeleton
816
- loading={loading}
817
- component={<Card data={data} />}
818
- styless={{
819
- p: { height: "0.8em", width: "80%" },
820
- h3: { height: "1.2em", width: "60%", borderRadius: "8px" },
821
- img: { borderRadius: "12px" },
822
- button: { width: "150px", height: "50px" },
823
- }}
824
- />
825
- ```
826
-
827
- #### With Shimmer Effects
828
-
829
- ```jsx
830
- // Enable shimmer animations for a more polished look
831
- <AutoSkeleton
832
- loading={loading}
833
- component={<ProductCard product={product} />}
834
- shimmer={true}
835
- shimmerColor="rgba(255, 255, 255, 0.8)"
836
- highlightColor="#f8fafc"
837
- />
838
- ```
839
-
840
- #### Complex Component Example
841
-
842
- ```jsx
843
- function DashboardCard({ title, metrics, loading }) {
844
- return (
845
- <AutoSkeletonLoader
846
- loading={loading}
847
- component={
848
- <div className="dashboard-card">
849
- <h2>{title}</h2>
850
- <div className="metrics">
851
- {metrics.map((metric, index) => (
852
- <div key={index} className="metric">
853
- <span className="value">{metric.value}</span>
854
- <span className="label">{metric.label}</span>
855
- </div>
856
- ))}
857
- </div>
858
- </div>
859
- }
860
- inheritStyles={true}
861
- shimmer={true}
862
- />
863
- );
864
- }
865
- ```
866
-
867
- ### AutoSkeleton Props
868
-
869
- | Prop | Type | Default | Description |
870
- | ---------------- | ------------------------------------------------------------------------ | ----------------------- | ------------------------------------------------ |
871
- | `component` | ReactElement | - | The component to render or analyze for skeletons |
872
- | `inheritStyles` | boolean | false | Whether to inherit styles from original elements |
873
- | `styless` | object | {} | Custom styles for different element types |
874
- | `shimmer` | boolean | true | Whether to show shimmer animation |
875
- | `shimmerColor` | string | "rgba(255,255,255,0.6)" | Shimmer effect color |
876
- | `highlightColor` | string | "#f1f5f9" | Highlight color for shimmer effect |
877
- | `waveWidth` | number \| string | "200px" | Shimmer wave width |
878
- | `waveDirection` | "left-to-right" \| "right-to-left" \| "top-to-bottom" \| "bottom-to-top" | "left-to-right" | Direction of shimmer animation |
879
-
880
- All other props are inherited from `IBaseLoaderProps`.
881
-
882
- ---
883
-
884
873
  ## 🎨 New Loaders Feature Guide
885
874
 
886
875
  ### Using Multiple New Loaders Together
@@ -889,6 +878,7 @@ Here's how to combine the new loaders for amazing visual effects:
889
878
 
890
879
  ```jsx
891
880
  import { OrbitLoader, PlaneLoader, RippleLoader, SquaresLoader, StairLoader, HashtagLoader, SnakeLoader } from "react-loadly";
881
+ import "react-loadly/styles.css";
892
882
 
893
883
  function MultiLoaderShowcase() {
894
884
  return (