react-loadly 1.0.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 +220 -0
- package/dist/index.d.ts +507 -0
- package/dist/index.esm.js +1371 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1409 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/styles.css.map +1 -0
- package/dist/types/@types/index.d.ts +15 -0
- package/dist/types/@types/index.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IBaseLoaderProps.d.ts +30 -0
- package/dist/types/@types/interfaces/IBaseLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IFallbackLoaderProps.d.ts +14 -0
- package/dist/types/@types/interfaces/IFallbackLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IFluidLoaderProps.d.ts +8 -0
- package/dist/types/@types/interfaces/IFluidLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IGeometricLoaderProps.d.ts +8 -0
- package/dist/types/@types/interfaces/IGeometricLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/ILoaderCSSVariables.d.ts +11 -0
- package/dist/types/@types/interfaces/ILoaderCSSVariables.d.ts.map +1 -0
- package/dist/types/@types/interfaces/ILoaderState.d.ts +7 -0
- package/dist/types/@types/interfaces/ILoaderState.d.ts.map +1 -0
- package/dist/types/@types/interfaces/ILoaderTheme.d.ts +20 -0
- package/dist/types/@types/interfaces/ILoaderTheme.d.ts.map +1 -0
- package/dist/types/@types/interfaces/ILogoLoaderProps.d.ts +12 -0
- package/dist/types/@types/interfaces/ILogoLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/ITextLoaderProps.d.ts +12 -0
- package/dist/types/@types/interfaces/ITextLoaderProps.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IUseLoaderStateOptions.d.ts +9 -0
- package/dist/types/@types/interfaces/IUseLoaderStateOptions.d.ts.map +1 -0
- package/dist/types/@types/interfaces/IUseLoaderStateReturn.d.ts +10 -0
- package/dist/types/@types/interfaces/IUseLoaderStateReturn.d.ts.map +1 -0
- package/dist/types/@types/types/AnimationDirectionType.d.ts +2 -0
- package/dist/types/@types/types/AnimationDirectionType.d.ts.map +1 -0
- package/dist/types/@types/types/AnimationEasingType.d.ts +2 -0
- package/dist/types/@types/types/AnimationEasingType.d.ts.map +1 -0
- package/dist/types/@types/types/AnimationFillModeType.d.ts +2 -0
- package/dist/types/@types/types/AnimationFillModeType.d.ts.map +1 -0
- package/dist/types/@types/types/index.d.ts +4 -0
- package/dist/types/@types/types/index.d.ts.map +1 -0
- package/dist/types/components/atoms/Circle.d.ts +15 -0
- package/dist/types/components/atoms/Circle.d.ts.map +1 -0
- package/dist/types/components/atoms/Dot.d.ts +15 -0
- package/dist/types/components/atoms/Dot.d.ts.map +1 -0
- package/dist/types/components/atoms/Line.d.ts +29 -0
- package/dist/types/components/atoms/Line.d.ts.map +1 -0
- package/dist/types/components/atoms/Rectangle.d.ts +30 -0
- package/dist/types/components/atoms/Rectangle.d.ts.map +1 -0
- package/dist/types/components/atoms/index.d.ts +9 -0
- package/dist/types/components/atoms/index.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +4 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/components/molecules/DotCluster.d.ts +26 -0
- package/dist/types/components/molecules/DotCluster.d.ts.map +1 -0
- package/dist/types/components/molecules/LineGroup.d.ts +30 -0
- package/dist/types/components/molecules/LineGroup.d.ts.map +1 -0
- package/dist/types/components/molecules/ShapeGroup.d.ts +30 -0
- package/dist/types/components/molecules/ShapeGroup.d.ts.map +1 -0
- package/dist/types/components/molecules/index.d.ts +7 -0
- package/dist/types/components/molecules/index.d.ts.map +1 -0
- package/dist/types/components/organisms/BarsLoader.d.ts +4 -0
- package/dist/types/components/organisms/BarsLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/BlobLoader.d.ts +4 -0
- package/dist/types/components/organisms/BlobLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/BounceLoader.d.ts +4 -0
- package/dist/types/components/organisms/BounceLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/DotsLoader.d.ts +4 -0
- package/dist/types/components/organisms/DotsLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/FallbackLoader.d.ts +4 -0
- package/dist/types/components/organisms/FallbackLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/FlowLoader.d.ts +4 -0
- package/dist/types/components/organisms/FlowLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/GridLoader.d.ts +4 -0
- package/dist/types/components/organisms/GridLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/LiquidLoader.d.ts +4 -0
- package/dist/types/components/organisms/LiquidLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/LogoSpinLoader.d.ts +4 -0
- package/dist/types/components/organisms/LogoSpinLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/PulseLoader.d.ts +4 -0
- package/dist/types/components/organisms/PulseLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/RingLoader.d.ts +4 -0
- package/dist/types/components/organisms/RingLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/RotateLoader.d.ts +4 -0
- package/dist/types/components/organisms/RotateLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/SpinLoader.d.ts +4 -0
- package/dist/types/components/organisms/SpinLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/TypingLoader.d.ts +4 -0
- package/dist/types/components/organisms/TypingLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/WaveLoader.d.ts +4 -0
- package/dist/types/components/organisms/WaveLoader.d.ts.map +1 -0
- package/dist/types/components/organisms/index.d.ts +17 -0
- package/dist/types/components/organisms/index.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +5 -0
- package/dist/types/hooks/index.d.ts.map +1 -0
- package/dist/types/hooks/useAsyncLoader.d.ts +15 -0
- package/dist/types/hooks/useAsyncLoader.d.ts.map +1 -0
- package/dist/types/hooks/useLoaderState.d.ts +10 -0
- package/dist/types/hooks/useLoaderState.d.ts.map +1 -0
- package/dist/types/hooks/useMultipleLoaderStates.d.ts +11 -0
- package/dist/types/hooks/useMultipleLoaderStates.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/setupTests.d.ts +2 -0
- package/dist/types/setupTests.d.ts.map +1 -0
- package/dist/types/utils/animationUtils.d.ts +29 -0
- package/dist/types/utils/animationUtils.d.ts.map +1 -0
- package/dist/types/utils/colorUtils.d.ts +18 -0
- package/dist/types/utils/colorUtils.d.ts.map +1 -0
- package/dist/types/utils/domUtils.d.ts +13 -0
- package/dist/types/utils/domUtils.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +6 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/mathUtils.d.ts +9 -0
- package/dist/types/utils/mathUtils.d.ts.map +1 -0
- package/dist/types/utils/propUtils.d.ts +22 -0
- package/dist/types/utils/propUtils.d.ts.map +1 -0
- package/package.json +112 -0
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# ⚛️ React Loadly
|
|
2
|
+
|
|
3
|
+
A professional, high-performance, and accessible collection of **React loader components**. Built with **TypeScript** and optimized for a great user and developer experience.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/react-loadly)
|
|
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)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## ✨ Key Features
|
|
13
|
+
|
|
14
|
+
- **High Performance**: Uses hardware-accelerated CSS transforms and animations.
|
|
15
|
+
- **Accessibility First**: Full **ARIA support**, screen reader compatibility, and keyboard navigation.
|
|
16
|
+
- **TypeScript Ready**: Comprehensive type definitions for a seamless dev experience.
|
|
17
|
+
- **Highly Customizable**: Adjust appearance with CSS variables or component props.
|
|
18
|
+
- **Tree-Shakable**: Supports modern bundlers to only include what you use.
|
|
19
|
+
- **Reduced Motion**: Respects the user's `prefers-reduced-motion` settings.
|
|
20
|
+
- **SSR Compatible**: Works out-of-the-box with frameworks like **Next.js**.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🚀 Getting Started
|
|
25
|
+
|
|
26
|
+
### Installation
|
|
27
|
+
|
|
28
|
+
Install the package using your preferred package manager.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install react-loadly
|
|
32
|
+
# or
|
|
33
|
+
yarn add react-loadly
|
|
34
|
+
# or
|
|
35
|
+
pnpm add react-loadly
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Quick Usage
|
|
39
|
+
|
|
40
|
+
Import the components you need along with the base styles, then use them in your React application.
|
|
41
|
+
|
|
42
|
+
```jsx
|
|
43
|
+
import { SpinLoader, PulseLoader } from "react-loadly";
|
|
44
|
+
import "react-loadly/styles.css"; // Essential for base styles
|
|
45
|
+
|
|
46
|
+
function App() {
|
|
47
|
+
return (
|
|
48
|
+
<div>
|
|
49
|
+
{/* Simple spinning loader */}
|
|
50
|
+
<SpinLoader />
|
|
51
|
+
|
|
52
|
+
{/* A customized loader */}
|
|
53
|
+
<PulseLoader color="#ff6b6b" size={60} />
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 🎨 Component Showcase
|
|
62
|
+
|
|
63
|
+
### Geometric Loaders
|
|
64
|
+
|
|
65
|
+
| Component | Description |
|
|
66
|
+
| ------------- | ------------------------------------------------ |
|
|
67
|
+
| `SpinLoader` | A classic spinner with a minimalist design. |
|
|
68
|
+
| `PulseLoader` | A dynamic animation of pulsing dots. |
|
|
69
|
+
| `WaveLoader` | A series of bars creating a wave-like effect. |
|
|
70
|
+
| `GridLoader` | A grid of squares that animate in sequence. |
|
|
71
|
+
| `RingLoader` | A sophisticated ring spinner with dual rotation. |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### Organic & Text-Based Loaders
|
|
76
|
+
|
|
77
|
+
| Component | Preview | Description |
|
|
78
|
+
| -------------- | ------- | --------------------------------------------------- |
|
|
79
|
+
| `BlobLoader` | | A liquid-like loader with a smooth, organic feel. |
|
|
80
|
+
| `TypingLoader` | | A loader that simulates typing or processing text. |
|
|
81
|
+
| `DotsLoader` | | The familiar three-dot animation, perfect for text. |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## ♿ Accessibility
|
|
86
|
+
|
|
87
|
+
Accessibility is a core feature, not an afterthought. All loaders include:
|
|
88
|
+
|
|
89
|
+
- **ARIA attributes** (`role="status"`, `aria-label`) for screen readers.
|
|
90
|
+
- Support for **Reduced Motion**.
|
|
91
|
+
- **High contrast** and semantic HTML.
|
|
92
|
+
|
|
93
|
+
<!-- end list -->
|
|
94
|
+
|
|
95
|
+
```jsx
|
|
96
|
+
// Accessible by default
|
|
97
|
+
<SpinLoader aria-label="Loading content" />
|
|
98
|
+
|
|
99
|
+
// Custom accessible text
|
|
100
|
+
<PulseLoader showText loadingText="Processing your request..." />
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 🛠️ Customization
|
|
106
|
+
|
|
107
|
+
### CSS Variables
|
|
108
|
+
|
|
109
|
+
Customize the entire loader library globally with CSS variables.
|
|
110
|
+
|
|
111
|
+
```css
|
|
112
|
+
:root {
|
|
113
|
+
--loader-color: #3b82f6;
|
|
114
|
+
--loader-size: 40px;
|
|
115
|
+
--loader-speed: 1s;
|
|
116
|
+
--loader-text-color: #6b7280;
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Component Props
|
|
121
|
+
|
|
122
|
+
Each loader component accepts a common set of props for fine-grained control.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
interface BaseLoaderProps {
|
|
126
|
+
size?: number | string;
|
|
127
|
+
color?: string;
|
|
128
|
+
speed?: number;
|
|
129
|
+
loading?: boolean;
|
|
130
|
+
className?: string;
|
|
131
|
+
style?: React.CSSProperties;
|
|
132
|
+
showText?: boolean;
|
|
133
|
+
loadingText?: string;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 🧩 Advanced Usage
|
|
140
|
+
|
|
141
|
+
### `useLoaderState` Hook
|
|
142
|
+
|
|
143
|
+
Manage loading, error, and retry states for your data fetching with this convenient hook.
|
|
144
|
+
|
|
145
|
+
```jsx
|
|
146
|
+
import { useLoaderState, SpinLoader } from "react-loadly";
|
|
147
|
+
|
|
148
|
+
function DataComponent() {
|
|
149
|
+
const { state, setLoading, setError, retry } = useLoaderState({
|
|
150
|
+
timeout: 10000,
|
|
151
|
+
maxRetries: 3,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const loadData = async () => {
|
|
155
|
+
setLoading(true);
|
|
156
|
+
try {
|
|
157
|
+
await fetch("/api/data");
|
|
158
|
+
setLoading(false);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
setError(error.message);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
if (state.error) {
|
|
165
|
+
return (
|
|
166
|
+
<div>
|
|
167
|
+
Error: {state.error}
|
|
168
|
+
<button onClick={retry}>Retry</button>
|
|
169
|
+
</div>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<div>
|
|
175
|
+
<SpinLoader loading={state.isLoading} />
|
|
176
|
+
<button onClick={loadData} disabled={state.isLoading}>
|
|
177
|
+
Load Data
|
|
178
|
+
</button>
|
|
179
|
+
</div>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### `FallbackLoader` Component
|
|
185
|
+
|
|
186
|
+
A component to gracefully handle and display errors, timeouts, or network issues.
|
|
187
|
+
|
|
188
|
+
```jsx
|
|
189
|
+
import { FallbackLoader } from "react-loadly";
|
|
190
|
+
|
|
191
|
+
function ErrorBoundary({ error, retry }) {
|
|
192
|
+
return (
|
|
193
|
+
<FallbackLoader
|
|
194
|
+
error={error.message}
|
|
195
|
+
onRetry={retry}
|
|
196
|
+
type="error" // 'error' | 'network' | 'timeout'
|
|
197
|
+
/>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 🤝 Contributing
|
|
205
|
+
|
|
206
|
+
Contributions are welcome\! Please see our [CONTRIBUTING.md](https://www.google.com/search?q=CONTRIBUTING.md) guide for details.
|
|
207
|
+
|
|
208
|
+
1. Fork the repository.
|
|
209
|
+
2. Create your feature branch (`git checkout -b feature/my-new-feature`).
|
|
210
|
+
3. Commit your changes (`git commit -m 'feat: add a new loader component'`).
|
|
211
|
+
4. Push to the branch (`git push origin feature/my-new-feature`).
|
|
212
|
+
5. Open a pull request.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 📄 License
|
|
217
|
+
|
|
218
|
+
This project is licensed under the **MIT License**.
|
|
219
|
+
|
|
220
|
+
\<p align="center"\>Made with ❤️ by the React community.\</p\>
|