react-spin-prize 2.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/LICENSE +21 -0
- package/README.md +132 -0
- package/dist/SpinnerWheel.d.ts +4 -0
- package/dist/SpinnerWheel.d.ts.map +1 -0
- package/dist/SpinnerWheel.js +184 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Joshua
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# react-spin-prize
|
|
2
|
+
|
|
3
|
+
🎡 Modern, fully customizable prize wheel spinner component for React with TypeScript support.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/react-spin-prize)
|
|
6
|
+
[](https://www.npmjs.com/package/react-spin-prize)
|
|
7
|
+
[](https://github.com/joshuaolusayo/react-spin-prize/blob/main/LICENSE)
|
|
8
|
+
|
|
9
|
+
## 🎮 Live Demo
|
|
10
|
+
|
|
11
|
+
- **GitHub Pages**: [https://joshuaolusayo.github.io/react-spin-prize/](https://joshuaolusayo.github.io/react-spin-prize/)
|
|
12
|
+
- **CodeSandbox**: [Try it online](https://codesandbox.io/s/react-spin-prize)
|
|
13
|
+
- **StackBlitz**: [Edit in browser](https://stackblitz.com/edit/react-spin-prize)
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- 🎨 Fully customizable colors and styles
|
|
18
|
+
- 🎯 Precise winner selection
|
|
19
|
+
- 🎠Smooth animations with easing
|
|
20
|
+
- 📱 Responsive and accessible
|
|
21
|
+
- 🔧 TypeScript support
|
|
22
|
+
- 🎪 Modern design with "SPIN" button in the center
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install react-spin-prize
|
|
28
|
+
# or
|
|
29
|
+
yarn add react-spin-prize
|
|
30
|
+
# or
|
|
31
|
+
pnpm add react-spin-prize
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { SpinnerWheel } from 'react-spin-prize';
|
|
38
|
+
|
|
39
|
+
const items = [
|
|
40
|
+
{ id: 1, label: 'Prize 1', color: '#FF6B6B' },
|
|
41
|
+
{ id: 2, label: 'Prize 2', color: '#4ECDC4' },
|
|
42
|
+
{ id: 3, label: 'Prize 3', color: '#45B7D1' },
|
|
43
|
+
{ id: 4, label: 'Prize 4', color: '#FFA07A' },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
function App() {
|
|
47
|
+
const handleSpinComplete = (item) => {
|
|
48
|
+
console.log('Winner:', item);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<SpinnerWheel
|
|
53
|
+
items={items}
|
|
54
|
+
onSpinComplete={handleSpinComplete}
|
|
55
|
+
size={500}
|
|
56
|
+
duration={5000}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Props
|
|
63
|
+
|
|
64
|
+
| Prop | Type | Default | Description |
|
|
65
|
+
|------|------|---------|-------------|
|
|
66
|
+
| `items` | `SpinnerWheelItem[]` | required | Array of items to display on the wheel |
|
|
67
|
+
| `onSpinComplete` | `(item: SpinnerWheelItem) => void` | - | Callback when spin completes |
|
|
68
|
+
| `onButtonClick` | `() => void \| Promise<void>` | - | Callback when center button is clicked |
|
|
69
|
+
| `spinning` | `boolean` | - | External control of spinning state |
|
|
70
|
+
| `duration` | `number` | 5000 | Duration of spin animation in ms |
|
|
71
|
+
| `size` | `number` | 500 | Size of the wheel in pixels |
|
|
72
|
+
| `fontSize` | `number` | 16 | Font size for item labels |
|
|
73
|
+
| `borderWidth` | `number` | 8 | Width of the outer border |
|
|
74
|
+
| `borderColor` | `string` | '#333' | Color of the border |
|
|
75
|
+
| `buttonText` | `string` | 'SPIN' | Text on the center button |
|
|
76
|
+
| `buttonColor` | `string` | '#333' | Background color of the button |
|
|
77
|
+
| `buttonTextColor` | `string` | '#fff' | Text color of the button |
|
|
78
|
+
| `disabled` | `boolean` | false | Disable the spin button |
|
|
79
|
+
| `winningIndex` | `number` | - | Force a specific winner (for testing) |
|
|
80
|
+
| `autoSpinTrigger` | `string \| number \| boolean \| null` | - | Change this value to trigger a programmatic spin |
|
|
81
|
+
|
|
82
|
+
## SpinnerWheelItem
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
interface SpinnerWheelItem {
|
|
86
|
+
id: string | number;
|
|
87
|
+
label: string;
|
|
88
|
+
color?: string; // Background color of the segment
|
|
89
|
+
textColor?: string; // Text color (defaults to white)
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Advanced Usage
|
|
94
|
+
|
|
95
|
+
### Customization Examples
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
// Custom colors and icon
|
|
99
|
+
<SpinnerWheel
|
|
100
|
+
items={items}
|
|
101
|
+
buttonColor="#FF6B6B"
|
|
102
|
+
buttonTextColor="#FFFFFF"
|
|
103
|
+
buttonBorderColor="#FFD700"
|
|
104
|
+
buttonBorderWidth={6}
|
|
105
|
+
borderColor="#4ECDC4"
|
|
106
|
+
buttonIcon={<span style={{ fontSize: "48px" }}>🎰</span>}
|
|
107
|
+
/>
|
|
108
|
+
|
|
109
|
+
// Custom size
|
|
110
|
+
<SpinnerWheel
|
|
111
|
+
items={items}
|
|
112
|
+
size={600}
|
|
113
|
+
buttonSize={100}
|
|
114
|
+
duration={8000}
|
|
115
|
+
/>
|
|
116
|
+
|
|
117
|
+
// With button click callback (e.g., for API calls before spinning)
|
|
118
|
+
<SpinnerWheel
|
|
119
|
+
items={items}
|
|
120
|
+
onButtonClick={async () => {
|
|
121
|
+
// Make API call or perform any action when button is clicked
|
|
122
|
+
await fetchSpinData();
|
|
123
|
+
}}
|
|
124
|
+
onSpinComplete={(item) => {
|
|
125
|
+
console.log('Winner:', item);
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpinnerWheel.d.ts","sourceRoot":"","sources":["../src/SpinnerWheel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAQjD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAwSpD,CAAC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect, useCallback } from "react";
|
|
3
|
+
const DEFAULT_COLORS = [
|
|
4
|
+
"#FF6B6B", "#4ECDC4", "#45B7D1", "#FFA07A",
|
|
5
|
+
"#98D8C8", "#F7DC6F", "#BB8FCE", "#85C1E2",
|
|
6
|
+
"#F8B739", "#52B788", "#E76F51", "#2A9D8F",
|
|
7
|
+
];
|
|
8
|
+
export const SpinnerWheel = ({ items, onSpinComplete, onButtonClick, spinning: externalSpinning, duration = 5000, size = 500, fontSize = 16, borderWidth = 8, borderColor = "#333", buttonText = "SPIN", buttonColor = "#333", buttonTextColor = "#fff", buttonIcon, buttonSize, buttonBorderColor = "#333", buttonBorderWidth = 4, disabled = false, winningIndex, autoSpinTrigger, }) => {
|
|
9
|
+
const [rotation, setRotation] = useState(0);
|
|
10
|
+
const [spinning, setSpinning] = useState(false);
|
|
11
|
+
const animationRef = useRef();
|
|
12
|
+
const startTimeRef = useRef();
|
|
13
|
+
const isSpinning = externalSpinning !== undefined ? externalSpinning : spinning;
|
|
14
|
+
const radius = size / 2;
|
|
15
|
+
const centerX = radius;
|
|
16
|
+
const centerY = radius;
|
|
17
|
+
const wheelRadius = radius - borderWidth;
|
|
18
|
+
const buttonRadius = buttonSize !== undefined ? buttonSize : radius * 0.25;
|
|
19
|
+
const segmentAngle = 360 / items.length;
|
|
20
|
+
// Clean up animation on unmount
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
return () => {
|
|
23
|
+
if (animationRef.current) {
|
|
24
|
+
cancelAnimationFrame(animationRef.current);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
const spin = useCallback(() => {
|
|
29
|
+
if (spinning || items.length === 0)
|
|
30
|
+
return;
|
|
31
|
+
setSpinning(true);
|
|
32
|
+
const targetIdx = winningIndex !== undefined ? winningIndex : Math.floor(Math.random() * items.length);
|
|
33
|
+
// FIXED CALCULATION:
|
|
34
|
+
// The wheel has segments starting at 0° (right/3 o'clock) going counter-clockwise
|
|
35
|
+
// But we draw them starting at -90° (top/12 o'clock) going clockwise
|
|
36
|
+
// The pointer is at the top (-90° in drawing space, which is 12 o'clock)
|
|
37
|
+
//
|
|
38
|
+
// At rotation = 0:
|
|
39
|
+
// - Segment 0 spans from -90° to -90° + segmentAngle
|
|
40
|
+
// - Segment 0's center is at: -90° + segmentAngle/2
|
|
41
|
+
// - Pointer is at: -90°
|
|
42
|
+
// - Offset between them: segmentAngle/2
|
|
43
|
+
//
|
|
44
|
+
// To align segment i with pointer:
|
|
45
|
+
// - Segment i's center is at: -90° + i * segmentAngle + segmentAngle/2
|
|
46
|
+
// - Need to rotate so this equals -90° (pointer position)
|
|
47
|
+
// - Rotation needed: -90° - (-90° + i * segmentAngle + segmentAngle/2)
|
|
48
|
+
// - Simplifies to: -(i * segmentAngle + segmentAngle/2)
|
|
49
|
+
// - = -(i + 0.5) * segmentAngle
|
|
50
|
+
const rotations = 20 + Math.floor(Math.random() * 10); // 20-30 full rotations for much faster spinning
|
|
51
|
+
const targetRotation = -(targetIdx + 0.5) * segmentAngle;
|
|
52
|
+
const startRotation = rotation;
|
|
53
|
+
const currentNormalized = ((startRotation % 360) + 360) % 360;
|
|
54
|
+
const targetNormalized = ((targetRotation % 360) + 360) % 360;
|
|
55
|
+
const deltaRotation = targetNormalized - currentNormalized;
|
|
56
|
+
const totalRotation = 360 * rotations + deltaRotation;
|
|
57
|
+
const endRotation = startRotation + totalRotation;
|
|
58
|
+
startTimeRef.current = performance.now();
|
|
59
|
+
const animate = (currentTime) => {
|
|
60
|
+
const elapsed = currentTime - startTimeRef.current;
|
|
61
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
62
|
+
// Ease out cubic
|
|
63
|
+
const eased = 1 - Math.pow(1 - progress, 3);
|
|
64
|
+
const currentRotation = startRotation + totalRotation * eased;
|
|
65
|
+
setRotation(currentRotation);
|
|
66
|
+
if (progress < 1) {
|
|
67
|
+
animationRef.current = requestAnimationFrame(animate);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
setSpinning(false);
|
|
71
|
+
if (onSpinComplete) {
|
|
72
|
+
onSpinComplete(items[targetIdx]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
animationRef.current = requestAnimationFrame(animate);
|
|
77
|
+
}, [spinning, items, winningIndex, segmentAngle, rotation, duration, onSpinComplete]);
|
|
78
|
+
const autoSpinTriggerRef = useRef();
|
|
79
|
+
const isInitialMount = useRef(true);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (autoSpinTrigger === undefined) {
|
|
82
|
+
autoSpinTriggerRef.current = autoSpinTrigger;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Skip initial mount - don't spin when component first renders
|
|
86
|
+
if (isInitialMount.current) {
|
|
87
|
+
isInitialMount.current = false;
|
|
88
|
+
autoSpinTriggerRef.current = autoSpinTrigger;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (autoSpinTriggerRef.current === autoSpinTrigger) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
autoSpinTriggerRef.current = autoSpinTrigger;
|
|
95
|
+
spin();
|
|
96
|
+
}, [autoSpinTrigger]);
|
|
97
|
+
const getColor = (index) => {
|
|
98
|
+
return items[index].color || DEFAULT_COLORS[index % DEFAULT_COLORS.length];
|
|
99
|
+
};
|
|
100
|
+
const getTextColor = (index) => {
|
|
101
|
+
return items[index].textColor || "#fff";
|
|
102
|
+
};
|
|
103
|
+
// Dynamic font size for many items
|
|
104
|
+
const dynamicFontSize = items.length > 20
|
|
105
|
+
? Math.max(8, fontSize - Math.floor((items.length - 20) / 10) * 2)
|
|
106
|
+
: items.length > 12
|
|
107
|
+
? Math.max(10, fontSize - 2)
|
|
108
|
+
: fontSize;
|
|
109
|
+
const renderSegments = () => {
|
|
110
|
+
return items.map((item, index) => {
|
|
111
|
+
// Draw segments starting from top (-90°) going clockwise
|
|
112
|
+
const startAngle = (index * segmentAngle - 90) * (Math.PI / 180);
|
|
113
|
+
const endAngle = ((index + 1) * segmentAngle - 90) * (Math.PI / 180);
|
|
114
|
+
const midAngle = (startAngle + endAngle) / 2;
|
|
115
|
+
const x1 = centerX + wheelRadius * Math.cos(startAngle);
|
|
116
|
+
const y1 = centerY + wheelRadius * Math.sin(startAngle);
|
|
117
|
+
const x2 = centerX + wheelRadius * Math.cos(endAngle);
|
|
118
|
+
const y2 = centerY + wheelRadius * Math.sin(endAngle);
|
|
119
|
+
const pathData = [
|
|
120
|
+
`M ${centerX} ${centerY}`,
|
|
121
|
+
`L ${x1} ${y1}`,
|
|
122
|
+
`A ${wheelRadius} ${wheelRadius} 0 0 1 ${x2} ${y2}`,
|
|
123
|
+
"Z",
|
|
124
|
+
].join(" ");
|
|
125
|
+
// Text position
|
|
126
|
+
const textRadius = items.length > 30 ? wheelRadius * 0.65
|
|
127
|
+
: items.length > 20 ? wheelRadius * 0.68
|
|
128
|
+
: wheelRadius * 0.7;
|
|
129
|
+
const textX = centerX + textRadius * Math.cos(midAngle);
|
|
130
|
+
const textY = centerY + textRadius * Math.sin(midAngle);
|
|
131
|
+
const textAngle = (midAngle * 180) / Math.PI + 90;
|
|
132
|
+
// Truncate long labels
|
|
133
|
+
let displayLabel = item.label;
|
|
134
|
+
if (items.length > 30 && displayLabel.length > 8) {
|
|
135
|
+
displayLabel = displayLabel.substring(0, 7) + "...";
|
|
136
|
+
}
|
|
137
|
+
else if (items.length > 20 && displayLabel.length > 12) {
|
|
138
|
+
displayLabel = displayLabel.substring(0, 11) + "...";
|
|
139
|
+
}
|
|
140
|
+
else if (items.length > 12 && displayLabel.length > 15) {
|
|
141
|
+
displayLabel = displayLabel.substring(0, 14) + "...";
|
|
142
|
+
}
|
|
143
|
+
return (_jsxs("g", { children: [_jsx("path", { d: pathData, fill: getColor(index), stroke: borderColor, strokeWidth: 1 }), _jsx("text", { x: textX, y: textY, fill: getTextColor(index), fontSize: dynamicFontSize, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", transform: `rotate(${textAngle} ${textX} ${textY})`, style: { userSelect: "none", pointerEvents: "none" }, children: displayLabel })] }, item.id));
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
return (_jsxs("div", { style: { position: "relative", width: size, height: size, margin: "0 auto" }, children: [_jsxs("svg", { width: size, height: size, style: {
|
|
147
|
+
transform: `rotate(${rotation}deg)`,
|
|
148
|
+
transition: isSpinning ? "none" : "transform 0.3s ease-out",
|
|
149
|
+
}, children: [_jsx("circle", { cx: centerX, cy: centerY, r: radius - borderWidth / 2, fill: "none", stroke: borderColor, strokeWidth: borderWidth }), renderSegments(), buttonBorderWidth > 0 && (_jsx("circle", { cx: centerX, cy: centerY, r: buttonRadius + buttonBorderWidth / 2, fill: "none", stroke: buttonBorderColor, strokeWidth: buttonBorderWidth })), _jsx("circle", { cx: centerX, cy: centerY, r: buttonRadius, fill: buttonColor })] }), _jsx("svg", { width: size, height: size, style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" }, children: _jsx("polygon", { points: `${centerX},${borderWidth + 30} ${centerX - 15},${borderWidth} ${centerX + 15},${borderWidth}`, fill: "#FF3B3B", stroke: "#fff", strokeWidth: 2, style: { filter: "drop-shadow(0 2px 4px rgba(0,0,0,0.3))" } }) }), _jsx("button", { onClick: () => {
|
|
150
|
+
if (onButtonClick) {
|
|
151
|
+
onButtonClick();
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
spin();
|
|
155
|
+
}
|
|
156
|
+
}, disabled: disabled || isSpinning, style: {
|
|
157
|
+
position: "absolute",
|
|
158
|
+
top: "50%",
|
|
159
|
+
left: "50%",
|
|
160
|
+
transform: "translate(-50%, -50%)",
|
|
161
|
+
width: buttonRadius * 2,
|
|
162
|
+
height: buttonRadius * 2,
|
|
163
|
+
borderRadius: "50%",
|
|
164
|
+
backgroundColor: buttonColor,
|
|
165
|
+
color: buttonTextColor,
|
|
166
|
+
border: "none",
|
|
167
|
+
fontSize: buttonIcon ? "inherit" : fontSize * 1.2,
|
|
168
|
+
fontWeight: buttonIcon ? "normal" : "bold",
|
|
169
|
+
cursor: disabled || isSpinning ? "not-allowed" : "pointer",
|
|
170
|
+
opacity: disabled || isSpinning ? 0.6 : 1,
|
|
171
|
+
transition: "all 0.2s ease",
|
|
172
|
+
boxShadow: "0 4px 8px rgba(0,0,0,0.2)",
|
|
173
|
+
zIndex: 10,
|
|
174
|
+
display: "flex",
|
|
175
|
+
alignItems: "center",
|
|
176
|
+
justifyContent: "center",
|
|
177
|
+
}, onMouseEnter: (e) => {
|
|
178
|
+
if (!disabled && !isSpinning) {
|
|
179
|
+
e.currentTarget.style.transform = "translate(-50%, -50%) scale(1.05)";
|
|
180
|
+
}
|
|
181
|
+
}, onMouseLeave: (e) => {
|
|
182
|
+
e.currentTarget.style.transform = "translate(-50%, -50%) scale(1)";
|
|
183
|
+
}, children: buttonIcon || buttonText })] }));
|
|
184
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SpinnerWheel } from "./SpinnerWheel";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SpinnerWheelItem {
|
|
2
|
+
id: string | number;
|
|
3
|
+
label: string;
|
|
4
|
+
color?: string;
|
|
5
|
+
textColor?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SpinnerWheelProps {
|
|
8
|
+
items: SpinnerWheelItem[];
|
|
9
|
+
onSpinComplete?: (item: SpinnerWheelItem) => void;
|
|
10
|
+
onButtonClick?: () => void | Promise<void>;
|
|
11
|
+
spinning?: boolean;
|
|
12
|
+
duration?: number;
|
|
13
|
+
size?: number;
|
|
14
|
+
fontSize?: number;
|
|
15
|
+
borderWidth?: number;
|
|
16
|
+
borderColor?: string;
|
|
17
|
+
buttonText?: string;
|
|
18
|
+
buttonColor?: string;
|
|
19
|
+
buttonTextColor?: string;
|
|
20
|
+
buttonIcon?: React.ReactNode;
|
|
21
|
+
buttonSize?: number;
|
|
22
|
+
buttonBorderColor?: string;
|
|
23
|
+
buttonBorderWidth?: number;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
winningIndex?: number;
|
|
26
|
+
autoSpinTrigger?: string | number | boolean | null;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAClD,aAAa,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;CACpD"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-spin-prize",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Modern, customizable prize wheel spinner component for React with TypeScript support",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"dev": "tsc --watch",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"react",
|
|
19
|
+
"spinner",
|
|
20
|
+
"wheel",
|
|
21
|
+
"prize",
|
|
22
|
+
"prize-wheel",
|
|
23
|
+
"spin-wheel",
|
|
24
|
+
"component",
|
|
25
|
+
"typescript",
|
|
26
|
+
"customizable",
|
|
27
|
+
"game",
|
|
28
|
+
"lottery",
|
|
29
|
+
"roulette"
|
|
30
|
+
],
|
|
31
|
+
"author": "Joshua (https://github.com/joshuaolusayo)",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/joshuaolusayo/react-spin-prize"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/joshuaolusayo/react-spin-prize/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://joshuaolusayo.github.io/react-spin-prize",
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
43
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/react": "^18.0.0",
|
|
47
|
+
"@types/react-dom": "^18.0.0",
|
|
48
|
+
"typescript": "^5.0.0"
|
|
49
|
+
}
|
|
50
|
+
}
|