shared-features 0.0.1 → 0.0.3

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.
Files changed (59) hide show
  1. package/README.md +110 -33
  2. package/dist/AdBanner-Ben0vVXV.js +1428 -0
  3. package/dist/AdBanner-Ben0vVXV.js.map +1 -0
  4. package/dist/AdBanner-D-KuNTje.cjs +1427 -0
  5. package/dist/AdBanner-D-KuNTje.cjs.map +1 -0
  6. package/dist/{analytics-6shJHRZG.cjs → analytics--ZSO9ova.cjs} +2 -5
  7. package/dist/analytics--ZSO9ova.cjs.map +1 -0
  8. package/dist/{analytics-Bbmodnm_.js → analytics-CdpCtTpu.js} +2 -5
  9. package/dist/analytics-CdpCtTpu.js.map +1 -0
  10. package/dist/components/ads/AdBanner.d.ts +25 -0
  11. package/dist/components/ads/AdBanner.d.ts.map +1 -0
  12. package/dist/components/ads/AdModal.d.ts +27 -0
  13. package/dist/components/ads/AdModal.d.ts.map +1 -0
  14. package/dist/components/ads/AdSlider.d.ts +21 -0
  15. package/dist/components/ads/AdSlider.d.ts.map +1 -0
  16. package/dist/components/ads/AdUpdateModal.d.ts +27 -0
  17. package/dist/components/ads/AdUpdateModal.d.ts.map +1 -0
  18. package/dist/components/ads/index.d.ts +9 -0
  19. package/dist/components/ads/index.d.ts.map +1 -1
  20. package/dist/components/ads/variants/LargePanelVariants.d.ts +34 -0
  21. package/dist/components/ads/variants/LargePanelVariants.d.ts.map +1 -0
  22. package/dist/components/ads/variants/SmallPanelVariants.d.ts +34 -0
  23. package/dist/components/ads/variants/SmallPanelVariants.d.ts.map +1 -0
  24. package/dist/components/ads/variants/index.d.ts +12 -0
  25. package/dist/components/ads/variants/index.d.ts.map +1 -0
  26. package/dist/components/index.cjs +20 -2
  27. package/dist/components/index.cjs.map +1 -1
  28. package/dist/components/index.js +20 -2
  29. package/dist/firebase/config.d.ts +1 -1
  30. package/dist/firebase/init.d.ts +5 -5
  31. package/dist/firebase/init.d.ts.map +1 -1
  32. package/dist/hooks/index.cjs +3 -1
  33. package/dist/hooks/index.cjs.map +1 -1
  34. package/dist/hooks/index.d.ts +1 -1
  35. package/dist/hooks/index.d.ts.map +1 -1
  36. package/dist/hooks/index.js +4 -2
  37. package/dist/hooks/useCampaigns.d.ts +44 -0
  38. package/dist/hooks/useCampaigns.d.ts.map +1 -1
  39. package/dist/index.cjs +24 -4
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.js +24 -4
  42. package/dist/services/index.cjs +1 -1
  43. package/dist/services/index.js +1 -1
  44. package/dist/types/campaigns.d.ts +20 -32
  45. package/dist/types/campaigns.d.ts.map +1 -1
  46. package/dist/types/index.cjs.map +1 -1
  47. package/dist/types/index.js.map +1 -1
  48. package/dist/{useCampaigns-BNOHpETm.cjs → useCampaigns-Dltisb9N.cjs} +57 -2
  49. package/dist/useCampaigns-Dltisb9N.cjs.map +1 -0
  50. package/dist/{useCampaigns-3NxODLLs.js → useCampaigns-nwfsALsN.js} +57 -2
  51. package/dist/{useCampaigns-3NxODLLs.js.map → useCampaigns-nwfsALsN.js.map} +1 -1
  52. package/package.json +3 -1
  53. package/dist/AdPanel-D0BiV6Xb.cjs +0 -88
  54. package/dist/AdPanel-D0BiV6Xb.cjs.map +0 -1
  55. package/dist/AdPanel-RGRBf4ub.js +0 -89
  56. package/dist/AdPanel-RGRBf4ub.js.map +0 -1
  57. package/dist/analytics-6shJHRZG.cjs.map +0 -1
  58. package/dist/analytics-Bbmodnm_.js.map +0 -1
  59. package/dist/useCampaigns-BNOHpETm.cjs.map +0 -1
package/README.md CHANGED
@@ -5,6 +5,9 @@ Centralized common features for Zaions projects. Manage ads, contacts, feature r
5
5
  ## Features
6
6
 
7
7
  - **Advertising Campaigns** - Cross-promote Zaions products across all projects
8
+ - 5 Ad Components (AdPanel, AdSlider, AdModal, AdUpdateModal, AdBanner)
9
+ - 10 Display Variants (5 small, 5 large)
10
+ - Frequency capping and analytics
8
11
  - **Products Catalog** - Centralized product information
9
12
  - **Contact Forms** - (Coming soon)
10
13
  - **Feature Requests** - (Coming soon)
@@ -23,47 +26,47 @@ yarn add shared-features
23
26
  This package requires the following peer dependencies:
24
27
 
25
28
  ```bash
26
- yarn add react react-dom firebase @radix-ui/themes zustand
29
+ yarn add react react-dom firebase @radix-ui/themes zustand lucide-react
27
30
  # Optional for mobile:
28
31
  yarn add @capacitor/preferences
29
32
  ```
30
33
 
31
34
  ## Setup
32
35
 
33
- ### 1. Initialize the package
34
-
35
- ```typescript
36
- // src/config/shared-features.ts
37
- import { initSharedFeatures } from 'shared-features';
38
-
39
- export const sharedFeatures = initSharedFeatures({
40
- firebaseConfig: {
41
- apiKey: import.meta.env.VITE_ZAIONS_FIREBASE_API_KEY,
42
- authDomain: 'aoneahsan-portfolio.firebaseapp.com',
43
- projectId: 'aoneahsan-portfolio',
44
- },
45
- projectId: 'your-project-id',
46
- projectName: 'Your Project Name',
47
- platform: 'web', // or 'android', 'ios', 'extension'
48
- debug: import.meta.env.DEV,
49
- });
50
- ```
51
-
52
- ### 2. Add environment variables
53
-
54
- Create or update your `.env` file:
36
+ ### 1. Add environment variables
55
37
 
56
38
  ```env
57
- # shared-features configuration
58
- VITE_ZAIONS_FIREBASE_API_KEY=your-api-key
39
+ # aoneahsan.com Firebase config (get from admin)
40
+ VITE_SHARED_FEATURES_API_KEY=
41
+ VITE_SHARED_FEATURES_AUTH_DOMAIN=
42
+ VITE_SHARED_FEATURES_PROJECT_ID=
43
+ VITE_SHARED_FEATURES_STORAGE_BUCKET=
44
+ VITE_SHARED_FEATURES_MESSAGING_SENDER_ID=
45
+ VITE_SHARED_FEATURES_APP_ID=
59
46
  ```
60
47
 
61
- ### 3. Initialize on app startup
48
+ ### 2. Initialize the package
62
49
 
63
50
  ```typescript
64
51
  // src/main.tsx or src/App.tsx
65
52
  import { initSharedFeatures } from 'shared-features';
66
- import './config/shared-features'; // Import to initialize
53
+
54
+ if (import.meta.env.VITE_SHARED_FEATURES_API_KEY) {
55
+ initSharedFeatures({
56
+ firebaseConfig: {
57
+ apiKey: import.meta.env.VITE_SHARED_FEATURES_API_KEY,
58
+ authDomain: import.meta.env.VITE_SHARED_FEATURES_AUTH_DOMAIN,
59
+ projectId: import.meta.env.VITE_SHARED_FEATURES_PROJECT_ID,
60
+ storageBucket: import.meta.env.VITE_SHARED_FEATURES_STORAGE_BUCKET,
61
+ messagingSenderId: import.meta.env.VITE_SHARED_FEATURES_MESSAGING_SENDER_ID,
62
+ appId: import.meta.env.VITE_SHARED_FEATURES_APP_ID,
63
+ },
64
+ projectId: 'your-project-id', // e.g., 'ztools', '2fa-studio'
65
+ projectName: 'Your Project Name', // e.g., 'ZTools', '2FA Studio'
66
+ platform: 'web', // or 'android', 'ios', 'extension'
67
+ debug: import.meta.env.DEV, // optional
68
+ });
69
+ }
67
70
  ```
68
71
 
69
72
  ## Usage
@@ -175,18 +178,92 @@ interface UseCampaignsResult {
175
178
  }
176
179
  ```
177
180
 
178
- ### `AdPanel`
181
+ ### Components
182
+
183
+ #### `AdPanel`
184
+
185
+ Simple single-ad panel for sidebars and footers.
186
+
187
+ ```tsx
188
+ <AdPanel placement="sidebar_panel" variant="small_panel_2" className="my-ad" />
189
+ ```
190
+
191
+ #### `AdSlider`
179
192
 
180
- Component to display a single ad.
193
+ Small promotional slider using small panel variants.
181
194
 
182
195
  ```tsx
183
- <AdPanel
184
- placement="sidebar_panel"
185
- variant="small_panel_2"
186
- className="my-ad"
196
+ <AdSlider placement="footer_slider" className="my-slider" />
197
+ ```
198
+
199
+ #### `AdBanner`
200
+
201
+ Permanent promotional banner with auto-rotation and progress indicators.
202
+
203
+ ```tsx
204
+ <AdBanner
205
+ placement="home_banner"
206
+ rotationInterval={10000}
207
+ maxCampaigns={5}
187
208
  />
188
209
  ```
189
210
 
211
+ #### `AdModal`
212
+
213
+ One-time promotional modal shown on first visit.
214
+
215
+ ```tsx
216
+ import { AdModal, useOneTimeAdModal } from 'shared-features';
217
+
218
+ function App() {
219
+ const { shouldShow, markAsShown } = useOneTimeAdModal();
220
+
221
+ return (
222
+ <>
223
+ {shouldShow && <AdModal onClose={markAsShown} />}
224
+ {/* Your app content */}
225
+ </>
226
+ );
227
+ }
228
+ ```
229
+
230
+ #### `AdUpdateModal`
231
+
232
+ Carousel modal shown when app version changes.
233
+
234
+ ```tsx
235
+ import { AdUpdateModal, useUpdateAdModal } from 'shared-features';
236
+
237
+ function App() {
238
+ const { shouldShow, currentVersion, markAsShown } = useUpdateAdModal();
239
+
240
+ return (
241
+ <>
242
+ {shouldShow && <AdUpdateModal onClose={markAsShown} />}
243
+ {/* Your app content */}
244
+ </>
245
+ );
246
+ }
247
+ ```
248
+
249
+ ### Modal Hooks
250
+
251
+ #### `useOneTimeAdModal()`
252
+
253
+ Manages one-time modal visibility (first visit).
254
+
255
+ ```typescript
256
+ const { shouldShow, markAsShown } = useOneTimeAdModal();
257
+ ```
258
+
259
+ #### `useUpdateAdModal(currentVersion?)`
260
+
261
+ Manages update modal visibility (version change).
262
+
263
+ ```typescript
264
+ const { shouldShow, previousVersion, currentVersion, markAsShown } = useUpdateAdModal();
265
+ ```
266
+
190
267
  ## Frequency Capping
191
268
 
192
269
  Ads automatically respect frequency capping set in the admin panel. By default, each campaign is shown to a user once every 20 days. This is tracked locally using Capacitor Preferences (mobile) or localStorage (web).