@sudobility/building_blocks 0.0.21 → 0.0.23

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @sudobility/building_blocks
2
2
 
3
- Higher-level shared UI building blocks for Sudobility apps. These components integrate with authentication, wallet connection, i18n, and routing.
3
+ Higher-level shared UI building blocks for Sudobility apps. These components integrate with authentication, wallet connection, i18n, routing, and analytics tracking.
4
4
 
5
5
  ## Installation
6
6
 
@@ -11,18 +11,18 @@ bun add @sudobility/building_blocks
11
11
  ## Peer Dependencies
12
12
 
13
13
  Required:
14
- - `@sudobility/components`
15
- - `@sudobility/design`
16
- - `@heroicons/react`
14
+ - `@sudobility/components` - Base UI components
15
+ - `@sudobility/design` - Design tokens and styling
16
+ - `@heroicons/react` - Icon library
17
17
  - `react` (^18.0.0 || ^19.0.0)
18
- - `class-variance-authority`
19
- - `clsx`
20
- - `tailwind-merge`
18
+ - `class-variance-authority`, `clsx`, `tailwind-merge` - Styling utilities
21
19
 
22
20
  Optional (for specific features):
23
21
  - `@sudobility/auth-components` - For Firebase auth integration
24
22
  - `@sudobility/web3-components` - For wallet connection
25
23
  - `@sudobility/devops-components` - For status indicator
24
+ - `@sudobility/subscription-components` - For pricing/subscription pages
25
+ - `@sudobility/types` - For Theme, FontSize enums
26
26
 
27
27
  ## Components
28
28
 
@@ -137,6 +137,7 @@ import { SystemStatusIndicator } from '@sudobility/devops-components';
137
137
  { label: 'Privacy', href: '/privacy' },
138
138
  { label: 'Terms', href: '/terms' },
139
139
  ]}
140
+ onTrack={handleAnalytics}
140
141
  sticky
141
142
  />
142
143
  ```
@@ -172,6 +173,7 @@ import { AppFooterForHomePage } from '@sudobility/building_blocks';
172
173
  version="1.0.0"
173
174
  companyName="Sudobility Inc."
174
175
  description="Building the future of web3 communication"
176
+ onTrack={handleAnalytics}
175
177
  />
176
178
  ```
177
179
 
@@ -197,6 +199,112 @@ import { AppPageLayout, AppTopBarWithFirebaseAuth, AppFooter } from '@sudobility
197
199
  </AppPageLayout>
198
200
  ```
199
201
 
202
+ ### Settings Components
203
+
204
+ #### GlobalSettingsPage
205
+ Master-detail settings page with extensible sections.
206
+
207
+ ```tsx
208
+ import { GlobalSettingsPage } from '@sudobility/building_blocks';
209
+
210
+ <GlobalSettingsPage
211
+ theme={theme}
212
+ fontSize={fontSize}
213
+ onThemeChange={setTheme}
214
+ onFontSizeChange={setFontSize}
215
+ additionalSections={[
216
+ {
217
+ id: 'notifications',
218
+ icon: BellIcon,
219
+ label: 'Notifications',
220
+ description: 'Manage notification preferences',
221
+ content: <NotificationSettings />,
222
+ },
223
+ ]}
224
+ onTrack={handleAnalytics}
225
+ />
226
+ ```
227
+
228
+ ### Subscription Components
229
+
230
+ #### AppPricingPage
231
+ Public pricing page for displaying subscription options.
232
+
233
+ ```tsx
234
+ import { AppPricingPage } from '@sudobility/building_blocks';
235
+
236
+ <AppPricingPage
237
+ products={subscriptionProducts}
238
+ isAuthenticated={isLoggedIn}
239
+ hasActiveSubscription={hasSubscription}
240
+ currentProductIdentifier={currentPlan}
241
+ labels={pricingLabels}
242
+ formatters={pricingFormatters}
243
+ entitlementMap={packageToEntitlement}
244
+ entitlementLevels={entitlementHierarchy}
245
+ onPlanClick={(planId) => handlePlanSelection(planId)}
246
+ onFreePlanClick={() => navigate('/signup')}
247
+ onTrack={handleAnalytics}
248
+ />
249
+ ```
250
+
251
+ ### Page Components
252
+
253
+ #### AppTextPage
254
+ Markdown/HTML content page for static content.
255
+
256
+ ```tsx
257
+ import { AppTextPage } from '@sudobility/building_blocks';
258
+
259
+ <AppTextPage
260
+ title="Privacy Policy"
261
+ content={markdownContent}
262
+ lastUpdated="2024-01-01"
263
+ />
264
+ ```
265
+
266
+ #### AppSitemapPage
267
+ SEO-friendly sitemap page.
268
+
269
+ ```tsx
270
+ import { AppSitemapPage } from '@sudobility/building_blocks';
271
+
272
+ <AppSitemapPage
273
+ sections={sitemapSections}
274
+ LinkComponent={LocalizedLink}
275
+ />
276
+ ```
277
+
278
+ ## Analytics Tracking
279
+
280
+ All major components support optional analytics tracking via the `onTrack` callback:
281
+
282
+ ```tsx
283
+ import type { AnalyticsTrackingParams } from '@sudobility/building_blocks';
284
+
285
+ const handleAnalytics = (params: AnalyticsTrackingParams) => {
286
+ // params.eventType: 'button_click' | 'link_click' | 'settings_change' | 'subscription_action'
287
+ // params.componentName: 'AppFooter' | 'GlobalSettingsPage' | 'AppPricingPage'
288
+ // params.label: 'footer_link_clicked' | 'theme_changed' | 'plan_clicked'
289
+ // params.params: { link_href, theme, plan_identifier, ... }
290
+
291
+ analytics.track(params.label, {
292
+ component: params.componentName,
293
+ ...params.params,
294
+ });
295
+ };
296
+
297
+ <AppFooter onTrack={handleAnalytics} {...props} />
298
+ <GlobalSettingsPage onTrack={handleAnalytics} {...props} />
299
+ <AppPricingPage onTrack={handleAnalytics} {...props} />
300
+ ```
301
+
302
+ **Components with analytics support:**
303
+ - `AppFooter` - tracks link clicks
304
+ - `AppFooterForHomePage` - tracks link clicks with section info
305
+ - `GlobalSettingsPage` - tracks theme/font changes, section navigation
306
+ - `AppPricingPage` - tracks plan clicks, billing period changes
307
+
200
308
  ## Constants
201
309
 
202
310
  ### Default Languages
@@ -207,13 +315,47 @@ import { DEFAULT_LANGUAGES } from '@sudobility/building_blocks';
207
315
  // ['en', 'ar', 'de', 'es', 'fr', 'it', 'ja', 'ko', 'pt', 'ru', 'sv', 'th', 'uk', 'vi', 'zh', 'zh-hant']
208
316
  ```
209
317
 
318
+ ## TypeScript Types
319
+
320
+ All props interfaces and utility types are exported:
321
+
322
+ ```tsx
323
+ import type {
324
+ // Component Props
325
+ AppTopBarProps,
326
+ AppFooterProps,
327
+ AppFooterForHomePageProps,
328
+ GlobalSettingsPageProps,
329
+ AppPricingPageProps,
330
+
331
+ // Configuration Types
332
+ MenuItemConfig,
333
+ LogoConfig,
334
+ FooterLinkSection,
335
+ SocialLinksConfig,
336
+ StatusIndicatorConfig,
337
+ ShareConfig,
338
+
339
+ // Analytics
340
+ AnalyticsTrackingParams,
341
+ AnalyticsEventType,
342
+
343
+ // Layout
344
+ MaxWidth,
345
+ ContentPadding,
346
+ BackgroundVariant,
347
+ } from '@sudobility/building_blocks';
348
+ ```
349
+
210
350
  ## Features
211
351
 
212
352
  - **Responsive**: All components support mobile with hamburger menu
213
353
  - **Dark Mode**: Full dark mode support via Tailwind CSS
214
354
  - **i18n Ready**: Language selector with 16 default languages
215
355
  - **Flexible Auth**: Support for Firebase auth or wallet connection
356
+ - **Analytics Ready**: Optional tracking callbacks for all user interactions
216
357
  - **Customizable**: All components accept custom classNames and Link components
358
+ - **Tree-shakeable**: ESM only, optimized for modern bundlers
217
359
 
218
360
  ## License
219
361
 
@@ -1,5 +1,5 @@
1
1
  import React, { type ComponentType } from 'react';
2
- import type { StatusIndicatorConfig, LinkComponentProps, FooterLinkSection as FooterLinkSectionConfig, SocialLinksConfig } from '../../types';
2
+ import type { StatusIndicatorConfig, LinkComponentProps, FooterLinkSection as FooterLinkSectionConfig, SocialLinksConfig, AnalyticsTrackingParams } from '../../types';
3
3
  import type { SystemStatusIndicatorProps } from './app-footer';
4
4
  export interface AppFooterForHomePageProps {
5
5
  /** App logo configuration */
@@ -40,6 +40,8 @@ export interface AppFooterForHomePageProps {
40
40
  className?: string;
41
41
  /** Number of columns for link grid (default: auto based on section count) */
42
42
  gridColumns?: 2 | 3 | 4 | 5;
43
+ /** Optional analytics tracking callback */
44
+ onTrack?: (params: AnalyticsTrackingParams) => void;
43
45
  }
44
46
  /**
45
47
  * AppFooterForHomePage - Full footer for home/landing pages.
@@ -1,5 +1,5 @@
1
1
  import React, { type ComponentType } from 'react';
2
- import type { StatusIndicatorConfig, LinkComponentProps, FooterLinkItem } from '../../types';
2
+ import type { StatusIndicatorConfig, LinkComponentProps, FooterLinkItem, AnalyticsTrackingParams } from '../../types';
3
3
  /**
4
4
  * Props for the SystemStatusIndicator component from @sudobility/devops-components.
5
5
  */
@@ -39,6 +39,8 @@ export interface AppFooterProps {
39
39
  isNetworkOnline?: boolean;
40
40
  /** Custom className */
41
41
  className?: string;
42
+ /** Optional analytics tracking callback */
43
+ onTrack?: (params: AnalyticsTrackingParams) => void;
42
44
  }
43
45
  /**
44
46
  * AppFooter - Compact footer for app pages.
@@ -1,5 +1,6 @@
1
1
  import React, { type ReactNode, type ComponentType } from 'react';
2
2
  import { Theme, FontSize } from './appearance-settings';
3
+ import type { AnalyticsTrackingParams } from '../../types';
3
4
  /**
4
5
  * Configuration for a settings section in the navigation.
5
6
  */
@@ -54,6 +55,8 @@ export interface GlobalSettingsPageProps {
54
55
  className?: string;
55
56
  /** Whether to show the info box in appearance settings */
56
57
  showAppearanceInfoBox?: boolean;
58
+ /** Optional analytics tracking callback */
59
+ onTrack?: (params: AnalyticsTrackingParams) => void;
57
60
  }
58
61
  /**
59
62
  * GlobalSettingsPage - A reusable settings page with master-detail layout.
@@ -2,6 +2,7 @@
2
2
  * @fileoverview App Pricing Page
3
3
  * @description Public pricing page for displaying subscription options
4
4
  */
5
+ import type { AnalyticsTrackingParams } from '../../types';
5
6
  /** Product from subscription provider */
6
7
  export interface PricingProduct {
7
8
  identifier: string;
@@ -76,6 +77,8 @@ export interface AppPricingPageProps {
76
77
  faqItems?: FAQItem[];
77
78
  /** Optional className for the container */
78
79
  className?: string;
80
+ /** Optional analytics tracking callback */
81
+ onTrack?: (params: AnalyticsTrackingParams) => void;
79
82
  }
80
83
  /**
81
84
  * Public pricing page for displaying subscription options.
@@ -83,4 +86,4 @@ export interface AppPricingPageProps {
83
86
  * - Authenticated on free: Free tile shows "Current Plan" badge (no CTA), paid tiles show "Upgrade"
84
87
  * - Authenticated with subscription: Current plan shows badge (no CTA), higher tiers show "Upgrade"
85
88
  */
86
- export declare function AppPricingPage({ products, isAuthenticated, hasActiveSubscription, currentProductIdentifier, labels, formatters, entitlementMap, entitlementLevels, onPlanClick, onFreePlanClick, faqItems, className, }: AppPricingPageProps): import("react/jsx-runtime").JSX.Element;
89
+ export declare function AppPricingPage({ products, isAuthenticated, hasActiveSubscription, currentProductIdentifier, labels, formatters, entitlementMap, entitlementLevels, onPlanClick, onFreePlanClick, faqItems, className, onTrack, }: AppPricingPageProps): import("react/jsx-runtime").JSX.Element;
@@ -3,6 +3,7 @@
3
3
  * @description Page for managing app subscriptions and viewing rate limits
4
4
  */
5
5
  import type { RateLimitsConfigData } from '@sudobility/types';
6
+ import type { AnalyticsTrackingParams } from '../../types';
6
7
  /** Product from subscription provider */
7
8
  export interface SubscriptionProduct {
8
9
  identifier: string;
@@ -26,8 +27,10 @@ export interface SubscriptionContextValue {
26
27
  currentSubscription: CurrentSubscription | null;
27
28
  isLoading: boolean;
28
29
  error: string | null;
29
- purchase: (productId: string) => Promise<boolean>;
30
- restore: () => Promise<boolean>;
30
+ /** Purchase a subscription product. subscriptionUserId identifies which user/entity the subscription is for. */
31
+ purchase: (productId: string, subscriptionUserId?: string) => Promise<boolean>;
32
+ /** Restore purchases. subscriptionUserId identifies which user/entity to restore for. */
33
+ restore: (subscriptionUserId?: string) => Promise<boolean>;
31
34
  clearError: () => void;
32
35
  }
33
36
  /** All localized labels for the subscription page */
@@ -107,8 +110,10 @@ export interface AppSubscriptionsPageProps {
107
110
  onError?: (title: string, message: string) => void;
108
111
  /** Called on warning */
109
112
  onWarning?: (title: string, message: string) => void;
113
+ /** Optional analytics tracking callback */
114
+ onTrack?: (params: AnalyticsTrackingParams) => void;
110
115
  }
111
116
  /**
112
117
  * Page for managing app subscriptions.
113
118
  */
114
- export declare function AppSubscriptionsPage({ subscription, rateLimitsConfig, labels, formatters, packageEntitlementMap, onPurchaseSuccess, onRestoreSuccess, onError, onWarning, }: AppSubscriptionsPageProps): import("react/jsx-runtime").JSX.Element;
119
+ export declare function AppSubscriptionsPage({ subscription, rateLimitsConfig, subscriptionUserId, labels, formatters, packageEntitlementMap, onPurchaseSuccess, onRestoreSuccess, onError, onWarning, onTrack, }: AppSubscriptionsPageProps): import("react/jsx-runtime").JSX.Element;