@sudobility/building_blocks 0.0.144 → 0.0.145

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.
@@ -1,19 +1,41 @@
1
1
  import React, { type ReactNode } from 'react';
2
2
  import { type VariantProps } from 'class-variance-authority';
3
3
  import { type AppBreadcrumbsProps } from '../breadcrumbs/app-breadcrumbs';
4
+ import { type AppTopBarProps } from '../topbar/app-topbar';
5
+ import { type AppTopBarWithFirebaseAuthProps } from '../topbar/app-topbar-with-firebase-auth';
6
+ import { type AppTopBarWithWalletProps } from '../topbar/app-topbar-with-wallet';
7
+ import { type AppFooterProps } from '../footer/app-footer';
8
+ import { type AppFooterForHomePageProps } from '../footer/app-footer-for-home-page';
4
9
  import type { MaxWidth, ContentPadding, BackgroundVariant } from '../../types';
5
10
  declare const layoutVariants: (props?: ({
6
11
  background?: "default" | "white" | "gradient" | null | undefined;
7
12
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
13
+ /** Discriminated union for selecting which TopBar component to render. */
14
+ export type TopBarConfig = ({
15
+ variant: 'base';
16
+ topBarVariant?: 'default' | 'app';
17
+ } & Omit<AppTopBarProps, 'variant'>) | ({
18
+ variant: 'firebase';
19
+ topBarVariant?: 'default' | 'app';
20
+ } & Omit<AppTopBarWithFirebaseAuthProps, 'variant'>) | ({
21
+ variant: 'wallet';
22
+ topBarVariant?: 'default' | 'app';
23
+ } & Omit<AppTopBarWithWalletProps, 'variant'>);
24
+ /** Discriminated union for selecting which Footer component to render. */
25
+ export type FooterConfig = ({
26
+ variant: 'compact';
27
+ } & AppFooterProps) | ({
28
+ variant: 'full';
29
+ } & AppFooterForHomePageProps);
8
30
  export interface AppPageLayoutProps extends VariantProps<typeof layoutVariants> {
9
31
  /** Page content */
10
32
  children: ReactNode;
11
- /** TopBar slot - pass an AppTopBar variant or custom component */
12
- topBar: ReactNode;
33
+ /** TopBar configuration - selects which TopBar component to render */
34
+ topBar: TopBarConfig;
13
35
  /** Breadcrumbs configuration (optional) */
14
36
  breadcrumbs?: AppBreadcrumbsProps;
15
- /** Footer slot - pass an AppFooter variant or custom component */
16
- footer?: ReactNode;
37
+ /** Footer configuration - selects which Footer component to render */
38
+ footer?: FooterConfig;
17
39
  /** Max width for content area (default: '7xl') */
18
40
  maxWidth?: MaxWidth;
19
41
  /** Content padding (default: 'md') */
@@ -30,42 +52,38 @@ export interface AppPageLayoutProps extends VariantProps<typeof layoutVariants>
30
52
  mainClassName?: string;
31
53
  /** Optional aspect ratio (width / height) for content area. When set, children are placed inside a container with fixed aspect ratio using AspectFit behavior. */
32
54
  aspectRatio?: number;
33
- /** When true, the footer sticks to the bottom of the viewport */
34
- stickyFooter?: boolean;
35
55
  }
36
56
  /**
37
57
  * AppPageLayout - Layout wrapper combining TopBar, Breadcrumbs, Content, and Footer.
38
58
  *
39
59
  * Features:
40
- * - Flexible slots for TopBar and Footer
60
+ * - Props-based TopBar and Footer via discriminated unions
41
61
  * - Optional breadcrumbs with share and "Talk to Founder"
42
62
  * - Configurable content max-width and padding
43
63
  * - Background variants
44
64
  * - Dark mode support
45
- * - Sticky footer behavior
65
+ * - Sticky footer behavior (automatic for compact footer)
46
66
  *
47
67
  * @example
48
68
  * ```tsx
49
69
  * <AppPageLayout
50
- * topBar={
51
- * <AppTopBarWithFirebaseAuth
52
- * logo={{ src: '/logo.png', appName: 'My App' }}
53
- * menuItems={menuItems}
54
- * AuthActionComponent={AuthAction}
55
- * onLoginClick={() => navigate('/login')}
56
- * />
57
- * }
70
+ * topBar={{
71
+ * variant: 'firebase',
72
+ * logo: { src: '/logo.png', appName: 'My App' },
73
+ * menuItems: menuItems,
74
+ * AuthActionComponent: AuthAction,
75
+ * onLoginClick: () => navigate('/login'),
76
+ * }}
58
77
  * breadcrumbs={{
59
78
  * items: breadcrumbItems,
60
79
  * shareConfig: { title: 'Page', description: 'Description', hashtags: [] },
61
80
  * }}
62
- * footer={
63
- * <AppFooter
64
- * version="1.0.0"
65
- * companyName="My Company"
66
- * links={[{ label: 'Privacy', href: '/privacy' }]}
67
- * />
68
- * }
81
+ * footer={{
82
+ * variant: 'compact',
83
+ * version: '1.0.0',
84
+ * companyName: 'My Company',
85
+ * links: [{ label: 'Privacy', href: '/privacy' }],
86
+ * }}
69
87
  * maxWidth="7xl"
70
88
  * background="default"
71
89
  * >
@@ -1 +1 @@
1
- export { AppPageLayout, type AppPageLayoutProps } from './app-page-layout';
1
+ export { AppPageLayout, type AppPageLayoutProps, type TopBarConfig, type FooterConfig, } from './app-page-layout';
package/dist/index.js CHANGED
@@ -1065,6 +1065,44 @@ const paddingClasses = {
1065
1065
  md: "px-4 py-8",
1066
1066
  lg: "px-4 py-12"
1067
1067
  };
1068
+ function renderTopBar(config) {
1069
+ const { variant, topBarVariant, ...rest } = config;
1070
+ switch (variant) {
1071
+ case "base":
1072
+ return /* @__PURE__ */ jsx(
1073
+ AppTopBar,
1074
+ {
1075
+ variant: topBarVariant,
1076
+ ...rest
1077
+ }
1078
+ );
1079
+ case "firebase":
1080
+ return /* @__PURE__ */ jsx(
1081
+ AppTopBarWithFirebaseAuth,
1082
+ {
1083
+ variant: topBarVariant,
1084
+ ...rest
1085
+ }
1086
+ );
1087
+ case "wallet":
1088
+ return /* @__PURE__ */ jsx(
1089
+ AppTopBarWithWallet,
1090
+ {
1091
+ variant: topBarVariant,
1092
+ ...rest
1093
+ }
1094
+ );
1095
+ }
1096
+ }
1097
+ function renderFooter(config) {
1098
+ const { variant, ...rest } = config;
1099
+ switch (variant) {
1100
+ case "compact":
1101
+ return /* @__PURE__ */ jsx(AppFooter, { ...rest });
1102
+ case "full":
1103
+ return /* @__PURE__ */ jsx(AppFooterForHomePage, { ...rest });
1104
+ }
1105
+ }
1068
1106
  const AppPageLayout = ({
1069
1107
  children,
1070
1108
  topBar,
@@ -1077,19 +1115,12 @@ const AppPageLayout = ({
1077
1115
  className,
1078
1116
  contentClassName,
1079
1117
  mainClassName,
1080
- aspectRatio,
1081
- stickyFooter = false
1118
+ aspectRatio
1082
1119
  }) => {
1083
- if (process.env.NODE_ENV !== "production") {
1084
- if (!topBar) {
1085
- console.warn(
1086
- "[AppPageLayout] No topBar provided. The layout will render without a navigation bar. Pass an AppTopBar variant or custom component via the topBar prop."
1087
- );
1088
- }
1089
- }
1120
+ const isCompactFooter = (footer == null ? void 0 : footer.variant) === "compact";
1090
1121
  const content = aspectRatio ? /* @__PURE__ */ jsx(AspectFitView, { aspectRatio, children }) : children;
1091
1122
  return /* @__PURE__ */ jsx(LayoutProvider, { mode: layoutMode, children: /* @__PURE__ */ jsxs("div", { className: cn(layoutVariants({ background }), className), children: [
1092
- /* @__PURE__ */ jsx("header", { children: topBar }),
1123
+ /* @__PURE__ */ jsx("header", { children: renderTopBar(topBar) }),
1093
1124
  breadcrumbs && breadcrumbs.items && breadcrumbs.items.length > 0 && /* @__PURE__ */ jsx(AppBreadcrumbs, { ...breadcrumbs }),
1094
1125
  /* @__PURE__ */ jsx("main", { className: cn("flex-1 overflow-auto", mainClassName), children: /* @__PURE__ */ jsx(
1095
1126
  "div",
@@ -1103,7 +1134,13 @@ const AppPageLayout = ({
1103
1134
  children: content
1104
1135
  }
1105
1136
  ) }),
1106
- footer && /* @__PURE__ */ jsx("footer", { className: stickyFooter ? "sticky bottom-0 z-10" : void 0, children: footer })
1137
+ footer && /* @__PURE__ */ jsx(
1138
+ "footer",
1139
+ {
1140
+ className: isCompactFooter ? "sticky bottom-0 z-10" : void 0,
1141
+ children: renderFooter(footer)
1142
+ }
1143
+ )
1107
1144
  ] }) });
1108
1145
  };
1109
1146
  var Theme = /* @__PURE__ */ ((Theme2) => {