@jepepa/like-button 0.8.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 +22 -0
- package/README.md +373 -0
- package/dist/chunk-WTGBDIZW.js +841 -0
- package/dist/chunk-WTGBDIZW.js.map +1 -0
- package/dist/index.d.ts +580 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/vanilla.d.ts +2 -0
- package/dist/vanilla.js +22 -0
- package/dist/vanilla.js.map +1 -0
- package/package.json +74 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Particle System Type Definitions
|
|
5
|
+
*
|
|
6
|
+
* This file contains all type definitions for the enhanced particle effects system.
|
|
7
|
+
* Supports configurable shapes, animations, presets, and custom particle configurations.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Built-in particle shape presets
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <LikeButton particleConfig={{ shape: 'star' }} />
|
|
15
|
+
* <LikeButton particleConfig={{ shape: 'heart' }} />
|
|
16
|
+
* <LikeButton particleConfig={{ shape: 'sparkle' }} />
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
type ParticleShapePreset = "heart" | "star" | "circle" | "square" | "sparkle";
|
|
20
|
+
/**
|
|
21
|
+
* Props passed to particle shape render functions
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const MyShape = ({ size, color, className }: ParticleShapeProps) => (
|
|
26
|
+
* <svg width={size} height={size} className={className}>
|
|
27
|
+
* <circle cx={size/2} cy={size/2} r={size/2} fill={color} />
|
|
28
|
+
* </svg>
|
|
29
|
+
* );
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
interface ParticleShapeProps {
|
|
33
|
+
/** Size of the shape in pixels */
|
|
34
|
+
size: number;
|
|
35
|
+
/** Color of the shape (hex or CSS color) */
|
|
36
|
+
color: string;
|
|
37
|
+
/** Additional CSS class names */
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Custom particle shape configuration
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* const customShape: CustomParticleShape = {
|
|
46
|
+
* render: ({ size, color }) => (
|
|
47
|
+
* <svg width={size} height={size}>
|
|
48
|
+
* <polygon points="..." fill={color} />
|
|
49
|
+
* </svg>
|
|
50
|
+
* )
|
|
51
|
+
* };
|
|
52
|
+
*
|
|
53
|
+
* <LikeButton particleConfig={{ shape: customShape }} />
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
interface CustomParticleShape {
|
|
57
|
+
/** Custom render function for the particle shape */
|
|
58
|
+
render: (props: ParticleShapeProps) => React.ReactNode;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Particle shape - either a preset string or custom shape config
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* // Using preset
|
|
66
|
+
* const shape1: ParticleShape = 'star';
|
|
67
|
+
*
|
|
68
|
+
* // Using custom shape
|
|
69
|
+
* const shape2: ParticleShape = {
|
|
70
|
+
* render: (props) => <MyCustomShape {...props} />
|
|
71
|
+
* };
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
type ParticleShape = ParticleShapePreset | CustomParticleShape;
|
|
75
|
+
/**
|
|
76
|
+
* Built-in particle effect presets
|
|
77
|
+
*
|
|
78
|
+
* - **burst**: Quick explosion of hearts in all directions (12 particles)
|
|
79
|
+
* - **fountain**: Upward spray effect (10 particles)
|
|
80
|
+
* - **confetti**: Colorful celebration with mixed shapes (15 particles)
|
|
81
|
+
* - **gentle**: Subtle floating effect (6 particles)
|
|
82
|
+
* - **fireworks**: Explosive sparkle effect (16 particles)
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```tsx
|
|
86
|
+
* <LikeButton particlePreset="burst" />
|
|
87
|
+
* <LikeButton particlePreset="confetti" />
|
|
88
|
+
* <LikeButton particlePreset="fireworks" />
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
type ParticlePreset = "burst" | "fountain" | "confetti" | "gentle" | "fireworks";
|
|
92
|
+
/**
|
|
93
|
+
* Range configuration for numeric values
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```tsx
|
|
97
|
+
* const distanceRange: Range = { min: 80, max: 120 };
|
|
98
|
+
* const sizeRange: Range = { min: 1.0, max: 2.0 };
|
|
99
|
+
*
|
|
100
|
+
* <LikeButton particleConfig={{
|
|
101
|
+
* distance: distanceRange,
|
|
102
|
+
* size: sizeRange
|
|
103
|
+
* }} />
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
interface Range {
|
|
107
|
+
/** Minimum value */
|
|
108
|
+
min: number;
|
|
109
|
+
/** Maximum value */
|
|
110
|
+
max: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Complete particle configuration interface.
|
|
114
|
+
* All fields are optional - defaults will be applied.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```tsx
|
|
118
|
+
* const config: ParticleConfig = {
|
|
119
|
+
* shape: 'star',
|
|
120
|
+
* colors: ['#FFD700', '#FFA500'],
|
|
121
|
+
* count: 12,
|
|
122
|
+
* speed: 600,
|
|
123
|
+
* distance: { min: 80, max: 120 },
|
|
124
|
+
* spread: 180,
|
|
125
|
+
* spreadOffset: -90,
|
|
126
|
+
* };
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
interface ParticleConfig {
|
|
130
|
+
/**
|
|
131
|
+
* Particle shape - preset name or custom shape config
|
|
132
|
+
* @default 'heart'
|
|
133
|
+
*/
|
|
134
|
+
shape?: ParticleShape;
|
|
135
|
+
/**
|
|
136
|
+
* Array of colors for particles (randomly selected)
|
|
137
|
+
* @default ['#EF4444', '#B9FF14', '#3B82F6']
|
|
138
|
+
*/
|
|
139
|
+
colors?: string[];
|
|
140
|
+
/**
|
|
141
|
+
* Number of particles to spawn per click
|
|
142
|
+
* @default 8
|
|
143
|
+
*/
|
|
144
|
+
count?: number;
|
|
145
|
+
/**
|
|
146
|
+
* Size range for particles (scale multiplier)
|
|
147
|
+
* Can be a single number or a range
|
|
148
|
+
* @default { min: 1.0, max: 1.5 }
|
|
149
|
+
*/
|
|
150
|
+
size?: number | Range;
|
|
151
|
+
/**
|
|
152
|
+
* Animation duration in milliseconds
|
|
153
|
+
* @default 500
|
|
154
|
+
*/
|
|
155
|
+
speed?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Distance particles travel in pixels
|
|
158
|
+
* Can be a single number or a range
|
|
159
|
+
* @default { min: 60, max: 100 }
|
|
160
|
+
*/
|
|
161
|
+
distance?: number | Range;
|
|
162
|
+
/**
|
|
163
|
+
* Spread angle in degrees (0-360)
|
|
164
|
+
* 360 = full circle, 180 = semicircle, etc.
|
|
165
|
+
* @default 360
|
|
166
|
+
*/
|
|
167
|
+
spread?: number;
|
|
168
|
+
/**
|
|
169
|
+
* Starting angle offset in degrees
|
|
170
|
+
* 0 = right, 90 = down, 180 = left, 270 = up
|
|
171
|
+
* @default 0
|
|
172
|
+
*/
|
|
173
|
+
spreadOffset?: number;
|
|
174
|
+
/**
|
|
175
|
+
* CSS easing function for particle animation
|
|
176
|
+
* @default 'cubic-bezier(0.22, 1, 0.36, 1)'
|
|
177
|
+
*/
|
|
178
|
+
easing?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Whether particles fade out during animation
|
|
181
|
+
* @default true
|
|
182
|
+
*/
|
|
183
|
+
fadeOut?: boolean;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Data structure for a single particle effect */
|
|
187
|
+
interface ParticleData {
|
|
188
|
+
id: string;
|
|
189
|
+
angle: number;
|
|
190
|
+
distance: number;
|
|
191
|
+
scale: number;
|
|
192
|
+
color: string;
|
|
193
|
+
shape: ParticleShape;
|
|
194
|
+
speed: number;
|
|
195
|
+
easing: string;
|
|
196
|
+
fadeOut: boolean;
|
|
197
|
+
}
|
|
198
|
+
/** Options for the useLikeButton hook */
|
|
199
|
+
interface UseLikeButtonOptions {
|
|
200
|
+
/** Number of clicks by current user (controlled mode). If not provided, internal state is used. */
|
|
201
|
+
localClicks?: number;
|
|
202
|
+
/** Maximum number of clicks allowed per user */
|
|
203
|
+
maxClicks?: number;
|
|
204
|
+
/** Callback when button is clicked. Receives the new local click count. */
|
|
205
|
+
onClick?: (newLocalClicks: number) => void;
|
|
206
|
+
/** Callback when button is right-clicked. Receives the current click count. Does not increment or spawn particles. */
|
|
207
|
+
onRightClick?: (currentClicks: number) => void;
|
|
208
|
+
/** Whether the button is disabled */
|
|
209
|
+
disabled?: boolean;
|
|
210
|
+
/** Show particle effects on click */
|
|
211
|
+
showParticles?: boolean;
|
|
212
|
+
/** Custom aria-label override */
|
|
213
|
+
ariaLabel?: string;
|
|
214
|
+
/**
|
|
215
|
+
* Particle effect preset (burst, fountain, confetti, gentle, fireworks)
|
|
216
|
+
* @example
|
|
217
|
+
* ```tsx
|
|
218
|
+
* useLikeButton({ particlePreset: 'burst' })
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
particlePreset?: ParticlePreset;
|
|
222
|
+
/**
|
|
223
|
+
* Custom particle configuration (overrides preset)
|
|
224
|
+
* @example
|
|
225
|
+
* ```tsx
|
|
226
|
+
* useLikeButton({
|
|
227
|
+
* particleConfig: {
|
|
228
|
+
* shape: 'star',
|
|
229
|
+
* colors: ['#FFD700', '#FFA500'],
|
|
230
|
+
* count: 12,
|
|
231
|
+
* }
|
|
232
|
+
* })
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
particleConfig?: Partial<ParticleConfig>;
|
|
236
|
+
}
|
|
237
|
+
/** Default values */
|
|
238
|
+
declare const LIKE_BUTTON_DEFAULTS: {
|
|
239
|
+
readonly maxClicks: 14;
|
|
240
|
+
readonly size: 96;
|
|
241
|
+
readonly fillColor: "#EF4444";
|
|
242
|
+
readonly waveColor: "#B91C1C";
|
|
243
|
+
};
|
|
244
|
+
/** Return type for the useLikeButton hook */
|
|
245
|
+
interface UseLikeButtonReturn {
|
|
246
|
+
/** Current click count */
|
|
247
|
+
localClicks: number;
|
|
248
|
+
/** Whether max clicks reached */
|
|
249
|
+
isMaxed: boolean;
|
|
250
|
+
/** Whether button is disabled */
|
|
251
|
+
disabled: boolean;
|
|
252
|
+
/** Fill percentage (0-100) */
|
|
253
|
+
fillPercentage: number;
|
|
254
|
+
/** Active particles to render */
|
|
255
|
+
particles: ParticleData[];
|
|
256
|
+
/** Click handler for the button */
|
|
257
|
+
handleClick: () => void;
|
|
258
|
+
/** Right-click handler for the button */
|
|
259
|
+
handleRightClick: (e: React.MouseEvent) => void;
|
|
260
|
+
/** Aria label for accessibility */
|
|
261
|
+
ariaLabel: string;
|
|
262
|
+
/** Whether button has been pressed */
|
|
263
|
+
isPressed: boolean;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Headless hook for LikeButton logic.
|
|
267
|
+
* Handles state management, particle spawning, and accessibility.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```tsx
|
|
271
|
+
* const { handleClick, localClicks, particles, ariaLabel } = useLikeButton({
|
|
272
|
+
* maxClicks: 10,
|
|
273
|
+
* onClick: (clicks) => console.log('Clicked!', clicks),
|
|
274
|
+
* });
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
declare function useLikeButton(options?: UseLikeButtonOptions): UseLikeButtonReturn;
|
|
278
|
+
|
|
279
|
+
/** Props passed to custom icon render function */
|
|
280
|
+
interface IconRenderProps {
|
|
281
|
+
/** Suggested icon size in pixels (50% of button size by default) */
|
|
282
|
+
size: number;
|
|
283
|
+
/** Base CSS classes for positioning and transitions */
|
|
284
|
+
className: string;
|
|
285
|
+
/** Whether button is at max clicks */
|
|
286
|
+
isMaxed: boolean;
|
|
287
|
+
/** Current fill percentage (0-100) */
|
|
288
|
+
fillPercentage: number;
|
|
289
|
+
}
|
|
290
|
+
/** Preset shape values */
|
|
291
|
+
type ShapePreset = "circle" | "rounded" | "square";
|
|
292
|
+
/** Custom shape configuration */
|
|
293
|
+
interface CustomShape {
|
|
294
|
+
/** CSS border-radius value (e.g., "1rem", "50%", "1rem 2rem") */
|
|
295
|
+
borderRadius?: string;
|
|
296
|
+
/** CSS clip-path value for custom shapes (e.g., "polygon(...)", "circle(...)") */
|
|
297
|
+
clipPath?: string;
|
|
298
|
+
}
|
|
299
|
+
/** Shape prop type - either a preset or custom configuration */
|
|
300
|
+
type Shape = ShapePreset | CustomShape;
|
|
301
|
+
/** Preset cursor values */
|
|
302
|
+
type CursorPreset = "heart" | "star" | "thumbs-up" | "pointer" | "none";
|
|
303
|
+
/** Custom cursor configuration */
|
|
304
|
+
interface CustomCursor {
|
|
305
|
+
/**
|
|
306
|
+
* Cursor URL - can be a data URL (SVG/image) or external URL.
|
|
307
|
+
* @example "data:image/svg+xml;utf8,<svg>...</svg>"
|
|
308
|
+
* @example "/cursors/my-cursor.png"
|
|
309
|
+
*/
|
|
310
|
+
url: string;
|
|
311
|
+
/** Hotspot X coordinate (default: 16) */
|
|
312
|
+
hotspotX?: number;
|
|
313
|
+
/** Hotspot Y coordinate (default: 16) */
|
|
314
|
+
hotspotY?: number;
|
|
315
|
+
/** Fallback cursor if custom cursor fails to load (default: "pointer") */
|
|
316
|
+
fallback?: "pointer" | "default" | "grab";
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Cursor prop type - either a preset string or custom configuration.
|
|
320
|
+
* - "heart" (default): Heart-shaped cursor
|
|
321
|
+
* - "star": Star-shaped cursor
|
|
322
|
+
* - "thumbs-up": Thumbs up cursor
|
|
323
|
+
* - "pointer": Standard pointer cursor (disables custom cursor)
|
|
324
|
+
* - "none": Hides cursor entirely
|
|
325
|
+
* - CustomCursor: Custom cursor with URL and hotspot configuration
|
|
326
|
+
*/
|
|
327
|
+
type Cursor = CursorPreset | CustomCursor;
|
|
328
|
+
/** Override brutalist styling */
|
|
329
|
+
interface StyleOverrides {
|
|
330
|
+
/** Border width in pixels (default: 4) */
|
|
331
|
+
borderWidth?: number;
|
|
332
|
+
/** Border color (default: "#111827") */
|
|
333
|
+
borderColor?: string;
|
|
334
|
+
/** Shadow offset in pixels (default: 8) */
|
|
335
|
+
shadowOffset?: number;
|
|
336
|
+
/** Shadow color (default: "#111827") */
|
|
337
|
+
shadowColor?: string;
|
|
338
|
+
/** Background color (default: "white") */
|
|
339
|
+
backgroundColor?: string;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Base props shared between Tailwind and Vanilla CSS versions.
|
|
343
|
+
* Both versions accept identical props for API consistency.
|
|
344
|
+
*/
|
|
345
|
+
interface BaseLikeButtonProps extends UseLikeButtonOptions {
|
|
346
|
+
/** Button size in pixels */
|
|
347
|
+
size?: number;
|
|
348
|
+
/** Fill color for the liquid effect */
|
|
349
|
+
fillColor?: string;
|
|
350
|
+
/** Wave color (darker shade for back wave) */
|
|
351
|
+
waveColor?: string;
|
|
352
|
+
/** Additional CSS class name */
|
|
353
|
+
className?: string;
|
|
354
|
+
/**
|
|
355
|
+
* Initial/minimum fill percentage shown even before any clicks.
|
|
356
|
+
* Useful for custom shapes with narrow bottoms (e.g., hearts, diamonds)
|
|
357
|
+
* where low fill percentages may be invisible.
|
|
358
|
+
*
|
|
359
|
+
* Valid range: 0-85 (values above 85 will be clamped to 85)
|
|
360
|
+
* @default 0
|
|
361
|
+
* @example
|
|
362
|
+
* // Show 15% minimum fill for a heart shape
|
|
363
|
+
* <LikeButton minFillPercent={15} shape={{ clipPath: "polygon(...)" }} />
|
|
364
|
+
*/
|
|
365
|
+
minFillPercent?: number;
|
|
366
|
+
/**
|
|
367
|
+
* Custom icon render function.
|
|
368
|
+
* - If undefined: renders default heart icon
|
|
369
|
+
* - If null: renders no icon
|
|
370
|
+
* - If function: calls with IconRenderProps
|
|
371
|
+
*/
|
|
372
|
+
renderIcon?: ((props: IconRenderProps) => React.ReactNode) | null;
|
|
373
|
+
/**
|
|
374
|
+
* Button shape.
|
|
375
|
+
* - Presets: "circle" (default), "rounded", "square"
|
|
376
|
+
* - Custom: { borderRadius?: string, clipPath?: string }
|
|
377
|
+
*/
|
|
378
|
+
shape?: Shape;
|
|
379
|
+
/** Override brutalist styling (border, shadow, background) */
|
|
380
|
+
styles?: StyleOverrides;
|
|
381
|
+
/**
|
|
382
|
+
* Cursor displayed when hovering over the button.
|
|
383
|
+
* - "heart" (default): Heart-shaped cursor
|
|
384
|
+
* - "star": Star-shaped cursor
|
|
385
|
+
* - "thumbs-up": Thumbs up cursor
|
|
386
|
+
* - "pointer": Standard pointer cursor
|
|
387
|
+
* - "none": Hides cursor
|
|
388
|
+
* - CustomCursor: { url, hotspotX?, hotspotY?, fallback? }
|
|
389
|
+
*/
|
|
390
|
+
cursor?: Cursor;
|
|
391
|
+
}
|
|
392
|
+
/** Props for the LikeButton component (Tailwind version) */
|
|
393
|
+
interface LikeButtonProps extends BaseLikeButtonProps {
|
|
394
|
+
}
|
|
395
|
+
/** Props for the LikeButton component (Vanilla CSS version) */
|
|
396
|
+
interface LikeButtonVanillaProps extends BaseLikeButtonProps {
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Default heart icon for LikeButton.
|
|
401
|
+
* Can be used as reference for creating custom icons.
|
|
402
|
+
*/
|
|
403
|
+
declare function DefaultHeartIcon({ size, className }: IconRenderProps): react_jsx_runtime.JSX.Element;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* LikeButton - Animated like button with liquid fill and particle effects.
|
|
407
|
+
* This version uses Tailwind CSS for styling.
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```tsx
|
|
411
|
+
* // Default heart button
|
|
412
|
+
* <LikeButton onClick={(clicks) => console.log('Clicks:', clicks)} />
|
|
413
|
+
*
|
|
414
|
+
* // Custom icon
|
|
415
|
+
* <LikeButton renderIcon={({ size }) => <CustomIcon size={size} />} />
|
|
416
|
+
*
|
|
417
|
+
* // Custom shape
|
|
418
|
+
* <LikeButton shape="rounded" />
|
|
419
|
+
* <LikeButton shape={{ clipPath: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)" }} />
|
|
420
|
+
*
|
|
421
|
+
* // Custom styles
|
|
422
|
+
* <LikeButton styles={{ shadowOffset: 4, borderWidth: 2 }} />
|
|
423
|
+
*
|
|
424
|
+
* // Custom cursor
|
|
425
|
+
* <LikeButton cursor="star" />
|
|
426
|
+
* <LikeButton cursor="pointer" /> // Standard pointer
|
|
427
|
+
* <LikeButton cursor={{ url: "data:image/svg+xml;...", hotspotX: 16, hotspotY: 16 }} />
|
|
428
|
+
*
|
|
429
|
+
* // Minimum fill for custom shapes
|
|
430
|
+
* <LikeButton minFillPercent={15} shape={{ clipPath: "polygon(...)" }} />
|
|
431
|
+
*
|
|
432
|
+
* // Particle presets
|
|
433
|
+
* <LikeButton particlePreset="burst" />
|
|
434
|
+
* <LikeButton particlePreset="confetti" />
|
|
435
|
+
* <LikeButton particlePreset="fireworks" />
|
|
436
|
+
*
|
|
437
|
+
* // Custom particle configuration
|
|
438
|
+
* <LikeButton particleConfig={{
|
|
439
|
+
* shape: 'star',
|
|
440
|
+
* colors: ['#FFD700', '#FFA500'],
|
|
441
|
+
* count: 15,
|
|
442
|
+
* speed: 800
|
|
443
|
+
* }} />
|
|
444
|
+
*
|
|
445
|
+
* // Combine preset with custom config
|
|
446
|
+
* <LikeButton
|
|
447
|
+
* particlePreset="burst"
|
|
448
|
+
* particleConfig={{ count: 20, colors: ['#ff0000'] }}
|
|
449
|
+
* />
|
|
450
|
+
*
|
|
451
|
+
* // Advanced particle configuration
|
|
452
|
+
* <LikeButton particleConfig={{
|
|
453
|
+
* shape: 'sparkle',
|
|
454
|
+
* count: 12,
|
|
455
|
+
* speed: 600,
|
|
456
|
+
* distance: { min: 80, max: 120 },
|
|
457
|
+
* spread: 180,
|
|
458
|
+
* spreadOffset: -90, // Upward spray
|
|
459
|
+
* size: { min: 1.2, max: 2.0 },
|
|
460
|
+
* easing: 'cubic-bezier(0.22, 1, 0.36, 1)',
|
|
461
|
+
* fadeOut: true
|
|
462
|
+
* }} />
|
|
463
|
+
* ```
|
|
464
|
+
*/
|
|
465
|
+
declare function LikeButton({ size, fillColor, waveColor, className, showParticles, renderIcon, shape, styles, cursor, minFillPercent, ...hookOptions }: LikeButtonProps): react_jsx_runtime.JSX.Element;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* LikeButton - Animated like button with liquid fill and particle effects.
|
|
469
|
+
* This version uses vanilla CSS (no Tailwind dependency).
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```tsx
|
|
473
|
+
* import { LikeButtonVanilla } from '@jepepa/like-button';
|
|
474
|
+
* import '@jepepa/like-button/styles.css';
|
|
475
|
+
*
|
|
476
|
+
* // Default usage
|
|
477
|
+
* <LikeButtonVanilla onClick={(clicks) => console.log('Clicks:', clicks)} />
|
|
478
|
+
*
|
|
479
|
+
* // Custom icon
|
|
480
|
+
* <LikeButtonVanilla renderIcon={({ size }) => <CustomIcon size={size} />} />
|
|
481
|
+
*
|
|
482
|
+
* // Custom shape
|
|
483
|
+
* <LikeButtonVanilla shape="rounded" />
|
|
484
|
+
* <LikeButtonVanilla shape={{ clipPath: "polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)" }} />
|
|
485
|
+
*
|
|
486
|
+
* // Custom styles
|
|
487
|
+
* <LikeButtonVanilla styles={{ shadowOffset: 4, borderWidth: 2 }} />
|
|
488
|
+
*
|
|
489
|
+
* // Custom cursor
|
|
490
|
+
* <LikeButtonVanilla cursor="star" />
|
|
491
|
+
* <LikeButtonVanilla cursor={{ url: "data:image/svg+xml;...", hotspotX: 16, hotspotY: 16 }} />
|
|
492
|
+
*
|
|
493
|
+
* // Minimum fill for custom shapes
|
|
494
|
+
* <LikeButtonVanilla minFillPercent={15} shape={{ clipPath: "polygon(...)" }} />
|
|
495
|
+
*
|
|
496
|
+
* // Particle presets (same API as Tailwind version)
|
|
497
|
+
* <LikeButtonVanilla particlePreset="burst" />
|
|
498
|
+
* <LikeButtonVanilla particlePreset="confetti" />
|
|
499
|
+
* <LikeButtonVanilla particlePreset="fireworks" />
|
|
500
|
+
*
|
|
501
|
+
* // Custom particle configuration
|
|
502
|
+
* <LikeButtonVanilla particleConfig={{
|
|
503
|
+
* shape: 'star',
|
|
504
|
+
* colors: ['#FFD700', '#FFA500'],
|
|
505
|
+
* count: 15,
|
|
506
|
+
* speed: 800
|
|
507
|
+
* }} />
|
|
508
|
+
*
|
|
509
|
+
* // Combine preset with custom config
|
|
510
|
+
* <LikeButtonVanilla
|
|
511
|
+
* particlePreset="burst"
|
|
512
|
+
* particleConfig={{ count: 20 }}
|
|
513
|
+
* />
|
|
514
|
+
* ```
|
|
515
|
+
*/
|
|
516
|
+
declare function LikeButtonVanilla({ size, fillColor, waveColor, className, showParticles, renderIcon, shape, styles, cursor, minFillPercent, ...hookOptions }: LikeButtonVanillaProps): react_jsx_runtime.JSX.Element;
|
|
517
|
+
|
|
518
|
+
/** Props for particle components */
|
|
519
|
+
interface ParticleProps {
|
|
520
|
+
/** Angle in degrees (0-360) for particle direction */
|
|
521
|
+
angle: number;
|
|
522
|
+
/** Distance in pixels the particle travels */
|
|
523
|
+
distance: number;
|
|
524
|
+
/** Scale multiplier for particle size */
|
|
525
|
+
scale: number;
|
|
526
|
+
/** Color of the particle (hex or CSS color) */
|
|
527
|
+
color: string;
|
|
528
|
+
/** Particle shape (preset or custom) */
|
|
529
|
+
shape: ParticleShape;
|
|
530
|
+
/** Animation duration in milliseconds */
|
|
531
|
+
speed: number;
|
|
532
|
+
/** CSS easing function for animation */
|
|
533
|
+
easing: string;
|
|
534
|
+
/** Whether particle should fade out */
|
|
535
|
+
fadeOut: boolean;
|
|
536
|
+
}
|
|
537
|
+
/** Return type for the useParticle hook */
|
|
538
|
+
interface UseParticleReturn {
|
|
539
|
+
/** Whether the animation has started */
|
|
540
|
+
isAnimating: boolean;
|
|
541
|
+
/** X position offset in pixels */
|
|
542
|
+
x: number;
|
|
543
|
+
/** Y position offset in pixels */
|
|
544
|
+
y: number;
|
|
545
|
+
/** Computed transform string */
|
|
546
|
+
transform: string;
|
|
547
|
+
/** Computed opacity value */
|
|
548
|
+
opacity: number;
|
|
549
|
+
/** Animation duration in milliseconds */
|
|
550
|
+
speed: number;
|
|
551
|
+
/** CSS easing function */
|
|
552
|
+
easing: string;
|
|
553
|
+
/** Whether to fade out */
|
|
554
|
+
fadeOut: boolean;
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Headless hook for particle animation logic.
|
|
558
|
+
* Handles animation state and position calculations.
|
|
559
|
+
*/
|
|
560
|
+
declare function useParticle({ angle, distance, scale, speed, easing, fadeOut, }: Pick<ParticleProps, "angle" | "distance" | "scale" | "speed" | "easing" | "fadeOut">): UseParticleReturn;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Particle - Animated particle for burst effects.
|
|
564
|
+
* This version uses Tailwind CSS for styling.
|
|
565
|
+
*
|
|
566
|
+
* Supports multiple shapes (heart, star, circle, square, sparkle) and custom shapes.
|
|
567
|
+
* Animation is fully configurable via speed, easing, and fadeOut props.
|
|
568
|
+
*/
|
|
569
|
+
declare function Particle({ angle, distance, scale, color, shape, speed, easing, fadeOut, }: ParticleProps): react_jsx_runtime.JSX.Element;
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Particle - Animated particle for burst effects.
|
|
573
|
+
* This version uses vanilla CSS (no Tailwind dependency).
|
|
574
|
+
*
|
|
575
|
+
* Supports multiple shapes (heart, star, circle, square, sparkle) and custom shapes.
|
|
576
|
+
* Animation is fully configurable via speed, easing, and fadeOut props.
|
|
577
|
+
*/
|
|
578
|
+
declare function ParticleVanilla({ angle, distance, scale, color, shape, speed, easing, fadeOut, }: ParticleProps): react_jsx_runtime.JSX.Element;
|
|
579
|
+
|
|
580
|
+
export { type BaseLikeButtonProps, type Cursor, type CursorPreset, type CustomCursor, type CustomShape, DefaultHeartIcon, type IconRenderProps, LIKE_BUTTON_DEFAULTS, LikeButton, type LikeButtonProps, LikeButtonVanilla, type LikeButtonVanillaProps, Particle, type ParticleData, type ParticleProps, ParticleVanilla, type Shape, type ShapePreset, type StyleOverrides, type UseLikeButtonOptions, type UseLikeButtonReturn, type UseParticleReturn, LikeButton as default, useLikeButton, useParticle };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DefaultHeartIcon,
|
|
3
|
+
LIKE_BUTTON_DEFAULTS,
|
|
4
|
+
LikeButton,
|
|
5
|
+
LikeButtonVanilla,
|
|
6
|
+
Particle,
|
|
7
|
+
ParticleVanilla,
|
|
8
|
+
useLikeButton,
|
|
9
|
+
useParticle
|
|
10
|
+
} from "./chunk-WTGBDIZW.js";
|
|
11
|
+
export {
|
|
12
|
+
DefaultHeartIcon,
|
|
13
|
+
LIKE_BUTTON_DEFAULTS,
|
|
14
|
+
LikeButton,
|
|
15
|
+
LikeButtonVanilla,
|
|
16
|
+
Particle,
|
|
17
|
+
ParticleVanilla,
|
|
18
|
+
LikeButton as default,
|
|
19
|
+
useLikeButton,
|
|
20
|
+
useParticle
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { BaseLikeButtonProps, Cursor, CursorPreset, CustomCursor, CustomShape, DefaultHeartIcon, IconRenderProps, LIKE_BUTTON_DEFAULTS, LikeButton, LikeButtonProps, LikeButtonVanilla, LikeButtonVanillaProps, Particle, ParticleData, ParticleProps, ParticleVanilla, Shape, ShapePreset, StyleOverrides, UseLikeButtonOptions, UseLikeButtonReturn, UseParticleReturn, LikeButtonVanilla as default, useLikeButton, useParticle } from './index.js';
|
|
2
|
+
import 'react/jsx-runtime';
|
package/dist/vanilla.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DefaultHeartIcon,
|
|
3
|
+
LIKE_BUTTON_DEFAULTS,
|
|
4
|
+
LikeButton,
|
|
5
|
+
LikeButtonVanilla,
|
|
6
|
+
Particle,
|
|
7
|
+
ParticleVanilla,
|
|
8
|
+
useLikeButton,
|
|
9
|
+
useParticle
|
|
10
|
+
} from "./chunk-WTGBDIZW.js";
|
|
11
|
+
export {
|
|
12
|
+
DefaultHeartIcon,
|
|
13
|
+
LIKE_BUTTON_DEFAULTS,
|
|
14
|
+
LikeButton,
|
|
15
|
+
LikeButtonVanilla,
|
|
16
|
+
Particle,
|
|
17
|
+
ParticleVanilla,
|
|
18
|
+
LikeButtonVanilla as default,
|
|
19
|
+
useLikeButton,
|
|
20
|
+
useParticle
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=vanilla.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|