onstage 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Asad Ullah Khalid
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,230 @@
1
+ # 🎭 Onstage
2
+
3
+ **The premium, plug-and-play onboarding wizard for React.**
4
+
5
+ Turn your new user experience into a polished, professional tour in minutes. `onstage` provides a beautiful, responsive, and fully customizable modal wizard with zero friction.
6
+
7
+ ![Onstage Demo](https://placehold.co/800x400/1e293b/fff?text=Onstage+Library+Preview)
8
+
9
+ ## ✨ Features
10
+
11
+ - **🎨 7 Pre-built Themes:** From "Glassmorphism" to "Midnight" dark mode.
12
+ - **📱 Fully Responsive:** Adapts visuals for Mobile, Tablet, and Desktop automatically.
13
+ - **🔌 Plug & Play:** Just pass an array of steps and it renders.
14
+ - **🌫️ Backdrop Control:** Choose between dark, blurred, or transparent overlays.
15
+ - **🎮 Flexible Control:** Strict mode (force completion) or Permissive (click outside to close).
16
+ - **💅 Granular Styling:** Override any part of the UI with Tailwind classes or CSS variables.
17
+
18
+ ## 📦 Installation
19
+
20
+ ```bash
21
+ npm install onstage
22
+ # or
23
+ pnpm add onstage
24
+ # or
25
+ yarn add onstage
26
+ ```
27
+
28
+ ## 🚀 Quick Start
29
+
30
+ ### 1. Import Styles
31
+ Add this **once** to your root file (e.g., `main.tsx` or `App.tsx`):
32
+
33
+ ```tsx
34
+ import "onstage/styles.css";
35
+ ```
36
+
37
+ ### 2. Wrap & Use
38
+ Wrap your app (or just the section you need) with the Provider and place the Modal.
39
+
40
+ ```tsx
41
+ import { OnboardingProvider, OnboardingModal } from "onstage";
42
+
43
+ const steps = [
44
+ {
45
+ title: "Welcome! 👋",
46
+ description: "We are **thrilled** to have you here.",
47
+ image: "/images/welcome-desktop.png"
48
+ },
49
+ {
50
+ title: "Features",
51
+ description: "Explore our new dashboard.",
52
+ image: "/images/dashboard.png"
53
+ }
54
+ ];
55
+
56
+ export default function App() {
57
+ return (
58
+ <OnboardingProvider steps={steps} defaultOpen={true}>
59
+ <YourApp />
60
+ <OnboardingModal />
61
+ </OnboardingProvider>
62
+ );
63
+ }
64
+ ```
65
+
66
+ ---
67
+
68
+ ## 🎨 Themes & Aesthetics
69
+
70
+ `onstage` comes with professional presets so you don't have to design from scratch.
71
+
72
+ ### Preset Themes
73
+ Pass the `theme` prop to switch styles instantly.
74
+
75
+ ```tsx
76
+ // 🌑 Professional Dark Mode
77
+ <OnboardingModal theme="dark" />
78
+
79
+ // 🪟 Frosted Glass Effect
80
+ <OnboardingModal theme="glass" />
81
+
82
+ // 🌌 Deep Purple "Midnight"
83
+ <OnboardingModal theme="midnight" />
84
+
85
+ // 📐 Minimalist (Brutalist / Sharp)
86
+ <OnboardingModal theme="minimal" />
87
+ ```
88
+
89
+ **Available Themes:**
90
+ - `light` (Default)
91
+ - `dark`
92
+ - `glass`
93
+ - `midnight`
94
+ - `minimal`
95
+ - `ocean`
96
+ - `sunset`
97
+
98
+ ### Backdrop Effects
99
+ Control the overlay behind the modal.
100
+
101
+ ```tsx
102
+ // 🌫️ Frosted background
103
+ <OnboardingModal backdrop="blur" />
104
+
105
+ // 👻 Invisible overlay (content visible but not clickable)
106
+ <OnboardingModal backdrop="transparent" />
107
+ ```
108
+
109
+ ---
110
+
111
+ ## 📱 Responsive Images
112
+
113
+ Don't serve a desktop screenshot on a mobile phone. `onstage` lets you define specific images for different devices. It automatically adjusts the aspect ratio (`4:5` mobile, `4:3` tablet, `16:9` desktop) to fit the modal perfectly.
114
+
115
+ ```tsx
116
+ const steps = [
117
+ {
118
+ title: "Responsive Magic",
119
+ description: "Resize your browser to see the image change!",
120
+ image: {
121
+ mobile: "/img/hero-portrait.png", // < 640px (4:5 Ratio)
122
+ tablet: "/img/hero-square.png", // < 1024px (4:3 Ratio)
123
+ desktop: "/img/hero-landscape.png" // > 1024px (16:9 Ratio)
124
+ }
125
+ }
126
+ ];
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 🎮 Interaction & Control
132
+
133
+ ### Strict vs. Permissive Mode
134
+ Decide if users *must* complete the onboarding or if they can dismiss it easily.
135
+
136
+ ```tsx
137
+ // 🔓 Permissive Mode (Default)
138
+ // Users can click the background or press ESC to dismiss.
139
+ <OnboardingModal allowClickOutside={true} />
140
+
141
+ // 🔒 Strict Mode
142
+ // Users MUST finish the steps or click "Skip". Background click is disabled.
143
+ <OnboardingModal allowClickOutside={false} />
144
+ ```
145
+
146
+ ### Programmatic Control
147
+ Control the wizard from anywhere in your app using the hook.
148
+
149
+ ```tsx
150
+ import { useOnboarding } from "onstage";
151
+
152
+ function SettingsPage() {
153
+ const { resetOnboarding } = useOnboarding();
154
+
155
+ return (
156
+ <button onClick={resetOnboarding}>
157
+ Show Tutorial Again
158
+ </button>
159
+ );
160
+ }
161
+ ```
162
+
163
+ **Available Hook Methods:**
164
+ - `resetOnboarding()`: Opens modal at step 0.
165
+ - `setIsOpen(boolean)`: Manually toggle visibility.
166
+ - `skipOnboarding()`: Closes modal and triggers `onSkip`.
167
+ - `finishOnboarding()`: Closes modal and triggers `onFinish`.
168
+
169
+ ---
170
+
171
+ ## 🛠️ Advanced Customization
172
+
173
+ ### CSS Variables
174
+ Tweak the branding colors globally or inline.
175
+
176
+ ```tsx
177
+ <OnboardingModal
178
+ style={{
179
+ '--primary': '262 80% 50%', // Custom Purple
180
+ '--radius': '1rem' // Rounder corners
181
+ } as React.CSSProperties}
182
+ />
183
+ ```
184
+
185
+ ### Granular Targeting
186
+ Need to style *just* the "Next" button? Use `classNames` (supports Tailwind) or `styles` to target specific elements.
187
+
188
+ ```tsx
189
+ <OnboardingModal
190
+ classNames={{
191
+ // Add red background to next button
192
+ nextButton: "bg-red-500 hover:bg-red-600 font-bold",
193
+ // Make title blue
194
+ title: "text-blue-600 underline",
195
+ // Custom overlay
196
+ overlay: "bg-slate-900/90"
197
+ }}
198
+ />
199
+ ```
200
+
201
+ **Targetable Elements:** `overlay`, `content`, `imageContainer`, `image`, `header`, `title`, `description`, `footer`, `stepIndicators`, `nextButton`, `prevButton`, `skipButton`, `finishButton`.
202
+
203
+ ---
204
+
205
+ ## 📚 API Reference
206
+
207
+ ### `OnboardingModal` Props
208
+
209
+ | Prop | Type | Default | Description |
210
+ |------|------|---------|-------------|
211
+ | `theme` | `string` | `"light"` | `light`, `dark`, `glass`, `minimal`, `midnight`, `ocean`, `sunset` |
212
+ | `backdrop` | `string` | `"default"` | `default` (dark), `blur`, `transparent` |
213
+ | `allowClickOutside` | `boolean` | `true` | If true, clicking overlay closes the modal. |
214
+ | `gradient` | `string` | `"animated"` | `animated`, `static`, `none` |
215
+ | `className` | `string` | `-` | Class for the main modal container. |
216
+ | `classNames` | `object` | `{}` | Target specific elements (see above). |
217
+ | `style` | `CSSProperties` | `{}` | Inline styles for the root. |
218
+
219
+ ### `OnboardingProvider` Props
220
+
221
+ | Prop | Type | Default | Description |
222
+ |------|------|---------|-------------|
223
+ | `steps` | `OnboardingStep[]` | **Required** | Array of step data. |
224
+ | `defaultOpen` | `boolean` | `false` | If true, opens immediately on mount. |
225
+ | `onFinish` | `() => void` | `-` | Callback when user finishes all steps. |
226
+ | `onSkip` | `() => void` | `-` | Callback when user clicks "Skip". |
227
+
228
+ ## License
229
+
230
+ MIT © Asad Ullah Khalid
@@ -0,0 +1,108 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode, CSSProperties } from 'react';
3
+
4
+ interface OnboardingStep {
5
+ title: string;
6
+ description: string;
7
+ image: string | {
8
+ mobile: string;
9
+ tablet?: string;
10
+ desktop: string;
11
+ };
12
+ }
13
+ interface OnboardingContextValue {
14
+ isOpen: boolean;
15
+ currentStepIndex: number;
16
+ steps: OnboardingStep[];
17
+ nextStep: () => void;
18
+ prevStep: () => void;
19
+ skipOnboarding: () => void;
20
+ finishOnboarding: () => void;
21
+ resetOnboarding: () => void;
22
+ setIsOpen: (isOpen: boolean) => void;
23
+ }
24
+ interface OnboardingProviderProps {
25
+ children: ReactNode;
26
+ steps: OnboardingStep[];
27
+ defaultOpen?: boolean;
28
+ onFinish?: () => void;
29
+ onSkip?: () => void;
30
+ }
31
+ declare function OnboardingProvider({ children, steps, defaultOpen, onFinish, onSkip, }: OnboardingProviderProps): react_jsx_runtime.JSX.Element;
32
+ declare function useOnboarding(): OnboardingContextValue;
33
+
34
+ type OnboardingTheme = "light" | "dark" | "minimal" | "glass" | "midnight" | "ocean" | "sunset";
35
+ interface OnboardingModalProps {
36
+ /**
37
+ * The aesthetic theme of the modal.
38
+ */
39
+ theme?: OnboardingTheme;
40
+ /**
41
+ * Controls the background gradient style.
42
+ */
43
+ gradient?: "animated" | "static" | "none";
44
+ /**
45
+ * Controls the visual style of the backdrop overlay.
46
+ * - `default`: Standard dark dimming.
47
+ * - `blur`: Clean frosted glass effect (blur only).
48
+ * - `transparent`: Invisible overlay.
49
+ * @default "default"
50
+ */
51
+ backdrop?: "default" | "blur" | "transparent";
52
+ /**
53
+ * Pass a custom Tailwind class for the gradient background.
54
+ */
55
+ customGradientClass?: string;
56
+ /**
57
+ * Inline styles to apply to the modal content.
58
+ */
59
+ style?: CSSProperties;
60
+ /**
61
+ * Additional class names for the modal container.
62
+ */
63
+ className?: string;
64
+ /**
65
+ * Whether to allow closing the modal by clicking the overlay or pressing Escape.
66
+ * @default true
67
+ */
68
+ allowClickOutside?: boolean;
69
+ /**
70
+ * Target specific internal elements for styling.
71
+ */
72
+ classNames?: {
73
+ overlay?: string;
74
+ content?: string;
75
+ imageContainer?: string;
76
+ image?: string;
77
+ header?: string;
78
+ title?: string;
79
+ description?: string;
80
+ footer?: string;
81
+ stepIndicators?: string;
82
+ nextButton?: string;
83
+ prevButton?: string;
84
+ skipButton?: string;
85
+ finishButton?: string;
86
+ };
87
+ /**
88
+ * Target specific internal elements with inline styles.
89
+ */
90
+ styles?: {
91
+ overlay?: CSSProperties;
92
+ content?: CSSProperties;
93
+ imageContainer?: CSSProperties;
94
+ image?: CSSProperties;
95
+ header?: CSSProperties;
96
+ title?: CSSProperties;
97
+ description?: CSSProperties;
98
+ footer?: CSSProperties;
99
+ stepIndicators?: CSSProperties;
100
+ nextButton?: CSSProperties;
101
+ prevButton?: CSSProperties;
102
+ skipButton?: CSSProperties;
103
+ finishButton?: CSSProperties;
104
+ };
105
+ }
106
+ declare function OnboardingModal({ theme, gradient, backdrop, customGradientClass, style, className, allowClickOutside, classNames, styles, }: OnboardingModalProps): react_jsx_runtime.JSX.Element | null;
107
+
108
+ export { OnboardingModal, type OnboardingModalProps, OnboardingProvider, type OnboardingStep, type OnboardingTheme, useOnboarding };
@@ -0,0 +1,108 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode, CSSProperties } from 'react';
3
+
4
+ interface OnboardingStep {
5
+ title: string;
6
+ description: string;
7
+ image: string | {
8
+ mobile: string;
9
+ tablet?: string;
10
+ desktop: string;
11
+ };
12
+ }
13
+ interface OnboardingContextValue {
14
+ isOpen: boolean;
15
+ currentStepIndex: number;
16
+ steps: OnboardingStep[];
17
+ nextStep: () => void;
18
+ prevStep: () => void;
19
+ skipOnboarding: () => void;
20
+ finishOnboarding: () => void;
21
+ resetOnboarding: () => void;
22
+ setIsOpen: (isOpen: boolean) => void;
23
+ }
24
+ interface OnboardingProviderProps {
25
+ children: ReactNode;
26
+ steps: OnboardingStep[];
27
+ defaultOpen?: boolean;
28
+ onFinish?: () => void;
29
+ onSkip?: () => void;
30
+ }
31
+ declare function OnboardingProvider({ children, steps, defaultOpen, onFinish, onSkip, }: OnboardingProviderProps): react_jsx_runtime.JSX.Element;
32
+ declare function useOnboarding(): OnboardingContextValue;
33
+
34
+ type OnboardingTheme = "light" | "dark" | "minimal" | "glass" | "midnight" | "ocean" | "sunset";
35
+ interface OnboardingModalProps {
36
+ /**
37
+ * The aesthetic theme of the modal.
38
+ */
39
+ theme?: OnboardingTheme;
40
+ /**
41
+ * Controls the background gradient style.
42
+ */
43
+ gradient?: "animated" | "static" | "none";
44
+ /**
45
+ * Controls the visual style of the backdrop overlay.
46
+ * - `default`: Standard dark dimming.
47
+ * - `blur`: Clean frosted glass effect (blur only).
48
+ * - `transparent`: Invisible overlay.
49
+ * @default "default"
50
+ */
51
+ backdrop?: "default" | "blur" | "transparent";
52
+ /**
53
+ * Pass a custom Tailwind class for the gradient background.
54
+ */
55
+ customGradientClass?: string;
56
+ /**
57
+ * Inline styles to apply to the modal content.
58
+ */
59
+ style?: CSSProperties;
60
+ /**
61
+ * Additional class names for the modal container.
62
+ */
63
+ className?: string;
64
+ /**
65
+ * Whether to allow closing the modal by clicking the overlay or pressing Escape.
66
+ * @default true
67
+ */
68
+ allowClickOutside?: boolean;
69
+ /**
70
+ * Target specific internal elements for styling.
71
+ */
72
+ classNames?: {
73
+ overlay?: string;
74
+ content?: string;
75
+ imageContainer?: string;
76
+ image?: string;
77
+ header?: string;
78
+ title?: string;
79
+ description?: string;
80
+ footer?: string;
81
+ stepIndicators?: string;
82
+ nextButton?: string;
83
+ prevButton?: string;
84
+ skipButton?: string;
85
+ finishButton?: string;
86
+ };
87
+ /**
88
+ * Target specific internal elements with inline styles.
89
+ */
90
+ styles?: {
91
+ overlay?: CSSProperties;
92
+ content?: CSSProperties;
93
+ imageContainer?: CSSProperties;
94
+ image?: CSSProperties;
95
+ header?: CSSProperties;
96
+ title?: CSSProperties;
97
+ description?: CSSProperties;
98
+ footer?: CSSProperties;
99
+ stepIndicators?: CSSProperties;
100
+ nextButton?: CSSProperties;
101
+ prevButton?: CSSProperties;
102
+ skipButton?: CSSProperties;
103
+ finishButton?: CSSProperties;
104
+ };
105
+ }
106
+ declare function OnboardingModal({ theme, gradient, backdrop, customGradientClass, style, className, allowClickOutside, classNames, styles, }: OnboardingModalProps): react_jsx_runtime.JSX.Element | null;
107
+
108
+ export { OnboardingModal, type OnboardingModalProps, OnboardingProvider, type OnboardingStep, type OnboardingTheme, useOnboarding };