glass-alert-animation 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GlassAlert
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,119 @@
1
+ # GlassAlert Animation ✨
2
+
3
+ <p align="center">
4
+ <img src="docs/assets/logo.png" alt="GlassAlert Logo" width="200" />
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/glass-alert-animation">
9
+ <img src="https://img.shields.io/npm/v/glass-alert-animation?style=flat-square&color=6366f1" alt="npm version" />
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/glass-alert-animation">
12
+ <img src="https://img.shields.io/npm/dw/glass-alert-animation?style=flat-square&color=8b5cf6" alt="npm downloads" />
13
+ </a>
14
+ <a href="https://github.com/jhonatalex/glass-alert/blob/main/LICENSE">
15
+ <img src="https://img.shields.io/github/license/jhonatalex/glass-alert?style=flat-square&color=6366f1" alt="license" />
16
+ </a>
17
+ <a href="https://github.com/jhonatalex/glass-alert">
18
+ <img src="https://img.shields.io/github/stars/jhonatalex/glass-alert?style=flat-square&color=8b5cf6" alt="github stars" />
19
+ </a>
20
+ </p>
21
+
22
+ ---
23
+
24
+ **GlassAlert** is a premium, high-performance glassmorphism alert and modal library for React, powered by GSAP. Designed to be a high-end alternative to SweetAlert2, it focuses on modern "liquid glass" aesthetics, fluid animations, and interactive backgrounds.
25
+
26
+ ### [🌐 Visit Live Documentation & Demos](https://jhonatalex.github.io/glass-alert/)
27
+
28
+ ---
29
+
30
+ ## ✨ Features
31
+
32
+ - 💎 **Premium Glassmorphism**: Stunning blur effects, translucent gradients, and luminous borders.
33
+ - 🚀 **GSAP-Powered Animations**: Hardware-accelerated transitions that feel smooth and professional.
34
+ - 🎨 **Dynamic Backgrounds**: Interactive, moving liquid gradient backgrounds for an "alive" feel.
35
+ - 📦 **Framework Ready**: Built for React with a simple hook-based API.
36
+ - 📱 **Mobile Optimized**: Fully responsive and lightweight.
37
+ - 🛠️ **Extremely Customizable**: Adjust blur, opacity, colors, and animation styles with ease.
38
+ - 🎭 **Lottie Support**: Built-in support for Lottie animations for success, error, and more.
39
+
40
+ ## 🚀 Installation
41
+
42
+ ```bash
43
+ npm install glass-alert-animation gsap lottie-react
44
+ ```
45
+
46
+ > **Note:** `gsap` and `lottie-react` are required dependencies for the animations and icons.
47
+
48
+ ## 📖 Quick Start
49
+
50
+ ### 1. Setup the Provider
51
+
52
+ Wrap your application with the `GlassAlertProvider` and import the styles.
53
+
54
+ ```tsx
55
+ import { GlassAlertProvider } from 'glass-alert-animation';
56
+ import 'glass-alert-animation/styles';
57
+
58
+ function App() {
59
+ return (
60
+ <GlassAlertProvider>
61
+ <yourApp />
62
+ </GlassAlertProvider>
63
+ );
64
+ }
65
+ ```
66
+
67
+ ### 2. Trigger an Alert
68
+
69
+ Use the `useGlassAlert` hook to fire alerts anywhere in your components.
70
+
71
+ ```tsx
72
+ import { useGlassAlert } from 'glass-alert-animation';
73
+
74
+ function MyComponent() {
75
+ const { fire } = useGlassAlert();
76
+
77
+ const handleAlert = async () => {
78
+ const result = await fire({
79
+ title: 'Success!',
80
+ text: 'GlassAlert is working perfectly.',
81
+ icon: 'success',
82
+ glassColor: '#6366f1',
83
+ animation: 'liquid'
84
+ });
85
+
86
+ if (result.isConfirmed) {
87
+ console.log('User clicked OK');
88
+ }
89
+ };
90
+
91
+ return <button onClick={handleAlert}>Show Alert</button>;
92
+ }
93
+ ```
94
+
95
+ ## ⚙️ Configuration Reference
96
+
97
+ | Property | Type | Default | Description |
98
+ | :--- | :--- | :--- | :--- |
99
+ | `title` | `string` | `''` | Main title header. |
100
+ | `text` | `string` | `''` | Body text content. |
101
+ | `html` | `ReactNode` | `undefined` | Custom HTML content (overrides text). |
102
+ | `icon` | `string` | `undefined` | `success`, `error`, `warning`, `info`, `question`. |
103
+ | `animation` | `string` | `'elastic'` | `elastic`, `bounce`, `slide`, `fade`, `liquid`. |
104
+ | `toast` | `boolean` | `false` | Enable toast notification mode. |
105
+ | `timer` | `number` | `0` | Auto-dismiss timer in ms. |
106
+ | `glassBlur` | `number` | `20` | Blur intensity for the glass effect (px). |
107
+ | `glassOpacity` | `number` | `0.12` | Opacity of the background (0-1). |
108
+ | `glassColor` | `string` | `'#6366f1'` | Primary accent color. |
109
+ | `animatedBackground`| `boolean` | `true` | Enable the dynamic background gradient. |
110
+
111
+ ---
112
+
113
+ ## 🤝 Contributing
114
+
115
+ This project is open-source and we welcome all contributions! Feel free to open issues or submit pull requests.
116
+
117
+ ## 📄 License
118
+
119
+ MIT © [jhonatalex](https://github.com/jhonatalex)
@@ -0,0 +1,17 @@
1
+ /**
2
+ * GSAP Animation Engine for GlassAlert
3
+ * Uses GSAP best practices from the official gsap-skills:
4
+ * - Transform aliases (x, y, scale, rotation) over raw transform strings
5
+ * - autoAlpha over opacity for fade in/out
6
+ * - Timeline-based sequencing
7
+ * - Built-in eases (back.out, elastic.out, power3.inOut)
8
+ */
9
+ import type { GlassAlertAnimation } from './types';
10
+ /** Set GSAP instance if user provides it (for ESM environments) */
11
+ export declare function setGsap(g: any): void;
12
+ export declare function animateIn(popupEl: HTMLElement, backdropEl: HTMLElement, type?: GlassAlertAnimation, onComplete?: () => void): any;
13
+ export declare function animateOut(popupEl: HTMLElement, backdropEl: HTMLElement, type?: GlassAlertAnimation, onComplete?: () => void): any;
14
+ export declare function animateIcon(iconEl: HTMLElement, iconType: string): any;
15
+ export declare function animateBackground(bgEl: HTMLElement, speed?: number): any;
16
+ export declare function animateButtonHover(btnEl: HTMLElement, enter: boolean): void;
17
+ export declare function animateTimerBar(barEl: HTMLElement, duration: number, onComplete?: () => void): any;
@@ -0,0 +1,4 @@
1
+ import type { GlassAlertOptions } from './types';
2
+ export declare const defaultOptions: Required<Pick<GlassAlertOptions, 'position' | 'animation' | 'toast' | 'timer' | 'timerProgressBar' | 'showConfirmButton' | 'confirmButtonText' | 'confirmButtonColor' | 'showCancelButton' | 'cancelButtonText' | 'cancelButtonColor' | 'showDenyButton' | 'denyButtonText' | 'denyButtonColor' | 'showCloseButton' | 'allowOutsideClick' | 'allowEscapeKey' | 'reverseButtons' | 'useLottieIcons' | 'lottieLoop' | 'glassBlur' | 'glassOpacity' | 'glassColor' | 'glassColorSecondary' | 'glassBorderOpacity' | 'backdropBlur' | 'animatedBackground' | 'backgroundAnimSpeed'>>;
3
+ /** Merge user options with defaults */
4
+ export declare function mergeOptions(opts: GlassAlertOptions): GlassAlertOptions & typeof defaultOptions;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * SVG Icon definitions for GlassAlert
3
+ * Each icon is designed to be animated by GSAP (stroke-dasharray/dashoffset)
4
+ */
5
+ export declare const iconSVGs: {
6
+ success: string;
7
+ error: string;
8
+ warning: string;
9
+ info: string;
10
+ question: string;
11
+ };
12
+ /** Default icon colors */
13
+ export declare const iconColors: Record<string, string>;
@@ -0,0 +1,123 @@
1
+ /** Icon types for GlassAlert */
2
+ export type GlassAlertIcon = 'success' | 'error' | 'warning' | 'info' | 'question';
3
+ /** Position variants */
4
+ export type GlassAlertPosition = 'center' | 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
5
+ /** Animation variants */
6
+ export type GlassAlertAnimation = 'elastic' | 'bounce' | 'slide' | 'fade' | 'liquid' | 'none';
7
+ /** Dismiss reasons */
8
+ export type GlassDismissReason = 'cancel' | 'backdrop' | 'close' | 'esc' | 'timer';
9
+ /** Result returned by fire() */
10
+ export interface GlassAlertResult<T = any> {
11
+ readonly isConfirmed: boolean;
12
+ readonly isDenied: boolean;
13
+ readonly isDismissed: boolean;
14
+ readonly value?: T;
15
+ readonly dismiss?: GlassDismissReason;
16
+ }
17
+ /** Glass-specific style options */
18
+ export interface GlassStyleOptions {
19
+ /** Blur intensity for the glass effect (px). Default: 20 */
20
+ glassBlur?: number;
21
+ /** Opacity of the glass background (0-1). Default: 0.15 */
22
+ glassOpacity?: number;
23
+ /** Primary glass color (hex/rgb). Default: '#6366f1' */
24
+ glassColor?: string;
25
+ /** Secondary glass color for gradients. Default: '#8b5cf6' */
26
+ glassColorSecondary?: string;
27
+ /** Border luminosity (0-1). Default: 0.3 */
28
+ glassBorderOpacity?: number;
29
+ /** Backdrop blur (px). Default: 8 */
30
+ backdropBlur?: number;
31
+ /** Enable animated background gradient. Default: true */
32
+ animatedBackground?: boolean;
33
+ /** Background animation speed in seconds. Default: 8 */
34
+ backgroundAnimSpeed?: number;
35
+ }
36
+ /** Main options for GlassAlert.fire() */
37
+ export interface GlassAlertOptions extends GlassStyleOptions {
38
+ /** Title text (supports HTML when using html prop) */
39
+ title?: string;
40
+ /** Body text */
41
+ text?: string;
42
+ /** Custom HTML content (overrides text) */
43
+ html?: string | React.ReactNode;
44
+ /** Icon type */
45
+ icon?: GlassAlertIcon;
46
+ /** Custom icon color */
47
+ iconColor?: string;
48
+ /** Position of the popup */
49
+ position?: GlassAlertPosition;
50
+ /** Animation type for entrance/exit */
51
+ animation?: GlassAlertAnimation;
52
+ /** Show as toast (non-blocking, auto-dismiss) */
53
+ toast?: boolean;
54
+ /** Lottie animation URL or imported JSON object */
55
+ lottie?: string | object;
56
+ /** Whether the Lottie animation should play on loop. Default: false */
57
+ lottieLoop?: boolean;
58
+ /** Whether to use bundled Lottie defaults for standard icons. Default: true */
59
+ useLottieIcons?: boolean;
60
+ /** Auto-close timer in milliseconds */
61
+ timer?: number;
62
+ /** Show timer progress bar */
63
+ timerProgressBar?: boolean;
64
+ /** Popup width */
65
+ width?: number | string;
66
+ /** Popup padding */
67
+ padding?: number | string;
68
+ /** Show confirm button. Default: true */
69
+ showConfirmButton?: boolean;
70
+ /** Confirm button text. Default: 'OK' */
71
+ confirmButtonText?: string;
72
+ /** Confirm button color */
73
+ confirmButtonColor?: string;
74
+ /** Show cancel button. Default: false */
75
+ showCancelButton?: boolean;
76
+ /** Cancel button text. Default: 'Cancel' */
77
+ cancelButtonText?: string;
78
+ /** Cancel button color */
79
+ cancelButtonColor?: string;
80
+ /** Show deny button. Default: false */
81
+ showDenyButton?: boolean;
82
+ /** Deny button text. Default: 'No' */
83
+ denyButtonText?: string;
84
+ /** Deny button color */
85
+ denyButtonColor?: string;
86
+ /** Show close (X) button. Default: false */
87
+ showCloseButton?: boolean;
88
+ /** Allow closing by clicking backdrop. Default: true */
89
+ allowOutsideClick?: boolean;
90
+ /** Allow closing by pressing Escape. Default: true */
91
+ allowEscapeKey?: boolean;
92
+ /** Reverse buttons order. Default: false */
93
+ reverseButtons?: boolean;
94
+ /** Called when popup opens */
95
+ willOpen?: () => void;
96
+ /** Called after popup is fully open & animated */
97
+ didOpen?: () => void;
98
+ /** Called when popup starts closing */
99
+ willClose?: () => void;
100
+ /** Called after popup is fully closed */
101
+ didClose?: () => void;
102
+ /** Footer content */
103
+ footer?: string | React.ReactNode;
104
+ customClass?: {
105
+ container?: string;
106
+ popup?: string;
107
+ title?: string;
108
+ icon?: string;
109
+ content?: string;
110
+ actions?: string;
111
+ confirmButton?: string;
112
+ cancelButton?: string;
113
+ denyButton?: string;
114
+ closeButton?: string;
115
+ footer?: string;
116
+ };
117
+ }
118
+ /** Internal state for the alert queue */
119
+ export interface GlassAlertState {
120
+ isOpen: boolean;
121
+ options: GlassAlertOptions;
122
+ resolve: ((result: GlassAlertResult) => void) | null;
123
+ }