awesome-ring-carousel 0.1.0 → 0.1.2
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 +97 -75
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@ A beautiful, interactive 3D ring carousel component for React with smooth animat
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
- **3D Ring Carousel** - Visually stunning 3D perspective effects
|
|
8
|
+
- **4 Built-in Themes** - Dark, Light, Neon, and Glass themes
|
|
9
|
+
- **Multiple Control Methods** - Mouse drag, keyboard arrows, touch & programmatic
|
|
10
|
+
- **Auto-Rotate** - Automatic carousel rotation with customizable speed
|
|
11
|
+
- **Responsive** - Works seamlessly on different screen sizes
|
|
12
|
+
- **Smooth Physics** - Realistic inertia and friction animations
|
|
13
|
+
- **Glow Effects** - Beautiful focus glow for the active item
|
|
14
|
+
- **Highly Customizable** - Full control over speed, friction, perspective, and more
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
@@ -42,31 +42,53 @@ const slides = [
|
|
|
42
42
|
{ title: 'Slide 2', description: 'Second slide', image: 'url2.jpg' },
|
|
43
43
|
];
|
|
44
44
|
|
|
45
|
-
export default function App() {
|
|
46
|
-
return (
|
|
47
|
-
<div
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
export default function App() {
|
|
46
|
+
return (
|
|
47
|
+
<div
|
|
48
|
+
style={{
|
|
49
|
+
minHeight: '100vh',
|
|
50
|
+
padding: '48px 20px 64px',
|
|
51
|
+
background:
|
|
52
|
+
'radial-gradient(70% 50% at 50% 35%, rgba(0,245,255,0.18) 0%, rgba(0,0,0,0) 60%), linear-gradient(180deg, #05070f 0%, #060b1a 55%, #070b12 100%)',
|
|
53
|
+
color: '#e6f0ff',
|
|
54
|
+
display: 'flex',
|
|
55
|
+
flexDirection: 'column',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
gap: '18px',
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<h1 style={{ margin: 0, fontSize: 'clamp(28px, 5vw, 56px)', letterSpacing: '-0.02em' }}>
|
|
62
|
+
Explore the Universe of <span style={{ color: '#00f5ff' }}>Possibilities</span>
|
|
63
|
+
</h1>
|
|
64
|
+
<p style={{ margin: 0, opacity: 0.7 }}>
|
|
65
|
+
Explore the full spectrum of products by clicking on any card
|
|
66
|
+
</p>
|
|
67
|
+
|
|
68
|
+
<div style={{ width: '100%', maxWidth: 980, height: '60vh', minHeight: 420 }}>
|
|
69
|
+
<AwesomeRingCarousel data={slides} theme="dark" />
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
53
75
|
|
|
54
76
|
## Data Format
|
|
55
77
|
|
|
56
78
|
Each item in the carousel requires the following structure:
|
|
57
79
|
|
|
58
|
-
```js
|
|
59
|
-
const slide = {
|
|
60
|
-
title: 'Slide 1', // Required: Title displayed on the card
|
|
61
|
-
description: 'First slide', // Optional: Subtitle or description
|
|
62
|
-
image: 'url1.jpg', // Optional: Image URL
|
|
63
|
-
tag: 'Featured', // Optional: Tag label
|
|
64
|
-
color: '#ff6b6b', // Optional: Background color (hex)
|
|
65
|
-
onClick: () => {}, // Optional: Click handler
|
|
66
|
-
};
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
For TypeScript users, this object shape maps directly to the `SlideData` type exported by the package.
|
|
80
|
+
```js
|
|
81
|
+
const slide = {
|
|
82
|
+
title: 'Slide 1', // Required: Title displayed on the card
|
|
83
|
+
description: 'First slide', // Optional: Subtitle or description
|
|
84
|
+
image: 'url1.jpg', // Optional: Image URL
|
|
85
|
+
tag: 'Featured', // Optional: Tag label
|
|
86
|
+
color: '#ff6b6b', // Optional: Background color (hex)
|
|
87
|
+
onClick: () => {}, // Optional: Click handler
|
|
88
|
+
};
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
For TypeScript users, this object shape maps directly to the `SlideData` type exported by the package.
|
|
70
92
|
|
|
71
93
|
## Component Props
|
|
72
94
|
|
|
@@ -119,11 +141,11 @@ Frosted glass effect with semi-transparent cards. Modern and elegant for premium
|
|
|
119
141
|
Use hardcoded data directly in your component:
|
|
120
142
|
|
|
121
143
|
```jsx
|
|
122
|
-
import { AwesomeRingCarousel } from 'awesome-ring-carousel';
|
|
123
|
-
import 'awesome-ring-carousel/dist/style.css';
|
|
124
|
-
|
|
125
|
-
export default function StaticDataExample() {
|
|
126
|
-
const staticSlides = [
|
|
144
|
+
import { AwesomeRingCarousel } from 'awesome-ring-carousel';
|
|
145
|
+
import 'awesome-ring-carousel/dist/style.css';
|
|
146
|
+
|
|
147
|
+
export default function StaticDataExample() {
|
|
148
|
+
const staticSlides = [
|
|
127
149
|
{
|
|
128
150
|
title: 'Product A',
|
|
129
151
|
description: 'Premium quality product',
|
|
@@ -174,14 +196,14 @@ export default function StaticDataExample() {
|
|
|
174
196
|
Load carousel data from a JSON file:
|
|
175
197
|
|
|
176
198
|
```jsx
|
|
177
|
-
import { useEffect, useState } from 'react';
|
|
178
|
-
import { AwesomeRingCarousel } from 'awesome-ring-carousel';
|
|
179
|
-
import 'awesome-ring-carousel/dist/style.css';
|
|
180
|
-
|
|
181
|
-
export default function JSONDataExample() {
|
|
182
|
-
const [slides, setSlides] = useState([]);
|
|
183
|
-
const [loading, setLoading] = useState(true);
|
|
184
|
-
const [error, setError] = useState(null);
|
|
199
|
+
import { useEffect, useState } from 'react';
|
|
200
|
+
import { AwesomeRingCarousel } from 'awesome-ring-carousel';
|
|
201
|
+
import 'awesome-ring-carousel/dist/style.css';
|
|
202
|
+
|
|
203
|
+
export default function JSONDataExample() {
|
|
204
|
+
const [slides, setSlides] = useState([]);
|
|
205
|
+
const [loading, setLoading] = useState(true);
|
|
206
|
+
const [error, setError] = useState(null);
|
|
185
207
|
|
|
186
208
|
useEffect(() => {
|
|
187
209
|
// Load slides from JSON file in public folder
|
|
@@ -190,10 +212,10 @@ export default function JSONDataExample() {
|
|
|
190
212
|
if (!response.ok) throw new Error('Failed to load data');
|
|
191
213
|
return response.json();
|
|
192
214
|
})
|
|
193
|
-
.then((data) => {
|
|
194
|
-
setSlides(data);
|
|
195
|
-
setLoading(false);
|
|
196
|
-
})
|
|
215
|
+
.then((data) => {
|
|
216
|
+
setSlides(data);
|
|
217
|
+
setLoading(false);
|
|
218
|
+
})
|
|
197
219
|
.catch((err) => {
|
|
198
220
|
setError(err.message);
|
|
199
221
|
setLoading(false);
|
|
@@ -260,15 +282,15 @@ export default function JSONDataExample() {
|
|
|
260
282
|
Fetch carousel data from a REST API:
|
|
261
283
|
|
|
262
284
|
```jsx
|
|
263
|
-
import { useEffect, useState } from 'react';
|
|
264
|
-
import { AwesomeRingCarousel } from 'awesome-ring-carousel';
|
|
265
|
-
import 'awesome-ring-carousel/dist/style.css';
|
|
266
|
-
|
|
267
|
-
export default function RESTAPIExample() {
|
|
268
|
-
const [slides, setSlides] = useState([]);
|
|
269
|
-
const [loading, setLoading] = useState(true);
|
|
270
|
-
const [error, setError] = useState(null);
|
|
271
|
-
const [focusedItem, setFocusedItem] = useState(null);
|
|
285
|
+
import { useEffect, useState } from 'react';
|
|
286
|
+
import { AwesomeRingCarousel } from 'awesome-ring-carousel';
|
|
287
|
+
import 'awesome-ring-carousel/dist/style.css';
|
|
288
|
+
|
|
289
|
+
export default function RESTAPIExample() {
|
|
290
|
+
const [slides, setSlides] = useState([]);
|
|
291
|
+
const [loading, setLoading] = useState(true);
|
|
292
|
+
const [error, setError] = useState(null);
|
|
293
|
+
const [focusedItem, setFocusedItem] = useState(null);
|
|
272
294
|
|
|
273
295
|
useEffect(() => {
|
|
274
296
|
// Fetch from a REST API endpoint
|
|
@@ -279,10 +301,10 @@ export default function RESTAPIExample() {
|
|
|
279
301
|
})
|
|
280
302
|
.then((data) => {
|
|
281
303
|
// Transform API response to match SlideData format
|
|
282
|
-
const transformedData = data.map((item) => ({
|
|
283
|
-
title: item.name || item.title,
|
|
284
|
-
description: item.summary || item.description,
|
|
285
|
-
image: item.thumbnail || item.image,
|
|
304
|
+
const transformedData = data.map((item) => ({
|
|
305
|
+
title: item.name || item.title,
|
|
306
|
+
description: item.summary || item.description,
|
|
307
|
+
image: item.thumbnail || item.image,
|
|
286
308
|
tag: item.category || item.type,
|
|
287
309
|
color: item.accentColor,
|
|
288
310
|
onClick: () => console.log(`Clicked: ${item.id}`)
|
|
@@ -296,10 +318,10 @@ export default function RESTAPIExample() {
|
|
|
296
318
|
});
|
|
297
319
|
}, []);
|
|
298
320
|
|
|
299
|
-
const handleFocusChange = (index) => {
|
|
300
|
-
setFocusedItem(slides[index] || null);
|
|
301
|
-
console.log(`Focused on: ${slides[index]?.title}`);
|
|
302
|
-
};
|
|
321
|
+
const handleFocusChange = (index) => {
|
|
322
|
+
setFocusedItem(slides[index] || null);
|
|
323
|
+
console.log(`Focused on: ${slides[index]?.title}`);
|
|
324
|
+
};
|
|
303
325
|
|
|
304
326
|
if (loading) {
|
|
305
327
|
return (
|
|
@@ -398,18 +420,18 @@ export default function CustomizedCarousel() {
|
|
|
398
420
|
### Controlled Carousel with External Controls
|
|
399
421
|
|
|
400
422
|
```jsx
|
|
401
|
-
import { useRef, useState } from 'react';
|
|
402
|
-
import { AwesomeRingCarousel } from 'awesome-ring-carousel';
|
|
403
|
-
import 'awesome-ring-carousel/dist/style.css';
|
|
404
|
-
|
|
405
|
-
export default function ControlledCarousel() {
|
|
406
|
-
const carouselRef = useRef(null);
|
|
407
|
-
const [focusedIndex, setFocusedIndex] = useState(0);
|
|
408
|
-
|
|
409
|
-
const slides = [
|
|
410
|
-
{ title: 'Slide 1', description: 'First', image: 'url1.jpg' },
|
|
411
|
-
{ title: 'Slide 2', description: 'Second', image: 'url2.jpg' },
|
|
412
|
-
{ title: 'Slide 3', description: 'Third', image: 'url3.jpg' },
|
|
423
|
+
import { useRef, useState } from 'react';
|
|
424
|
+
import { AwesomeRingCarousel } from 'awesome-ring-carousel';
|
|
425
|
+
import 'awesome-ring-carousel/dist/style.css';
|
|
426
|
+
|
|
427
|
+
export default function ControlledCarousel() {
|
|
428
|
+
const carouselRef = useRef(null);
|
|
429
|
+
const [focusedIndex, setFocusedIndex] = useState(0);
|
|
430
|
+
|
|
431
|
+
const slides = [
|
|
432
|
+
{ title: 'Slide 1', description: 'First', image: 'url1.jpg' },
|
|
433
|
+
{ title: 'Slide 2', description: 'Second', image: 'url2.jpg' },
|
|
434
|
+
{ title: 'Slide 3', description: 'Third', image: 'url3.jpg' },
|
|
413
435
|
];
|
|
414
436
|
|
|
415
437
|
return (
|
|
@@ -552,4 +574,4 @@ Custom CSS class applied to the carousel container for additional customization.
|
|
|
552
574
|
### Performance issues on mobile
|
|
553
575
|
- Reduce the number of images or use smaller dimensions
|
|
554
576
|
- Set `autoRotate={false}` if performance is critical
|
|
555
|
-
- Use optimized/compressed images
|
|
577
|
+
- Use optimized/compressed images
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "awesome-ring-carousel",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A beautiful, interactive 3D ring carousel component for React with smooth animations, multiple themes, and flexible data handling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/index.
|
|
7
|
+
"module": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.
|
|
16
|
-
"require": "./dist/index.
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.umd.cjs"
|
|
17
17
|
},
|
|
18
18
|
"./dist/style.css": "./dist/style.css"
|
|
19
19
|
},
|