@sudobility/building_blocks 0.0.144 → 0.0.146
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,30 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
|
-
import { type VariantProps } from 'class-variance-authority';
|
|
3
2
|
import { type AppBreadcrumbsProps } from '../breadcrumbs/app-breadcrumbs';
|
|
3
|
+
import { type AppTopBarProps } from '../topbar/app-topbar';
|
|
4
|
+
import { type AppTopBarWithFirebaseAuthProps } from '../topbar/app-topbar-with-firebase-auth';
|
|
5
|
+
import { type AppTopBarWithWalletProps } from '../topbar/app-topbar-with-wallet';
|
|
6
|
+
import { type AppFooterProps } from '../footer/app-footer';
|
|
7
|
+
import { type AppFooterForHomePageProps } from '../footer/app-footer-for-home-page';
|
|
4
8
|
import type { MaxWidth, ContentPadding, BackgroundVariant } from '../../types';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
/** Discriminated union for selecting which TopBar component to render. */
|
|
10
|
+
export type TopBarConfig = ({
|
|
11
|
+
variant: 'base';
|
|
12
|
+
topBarVariant?: 'default' | 'app';
|
|
13
|
+
} & Omit<AppTopBarProps, 'variant'>) | ({
|
|
14
|
+
variant: 'firebase';
|
|
15
|
+
topBarVariant?: 'default' | 'app';
|
|
16
|
+
} & Omit<AppTopBarWithFirebaseAuthProps, 'variant'>) | ({
|
|
17
|
+
variant: 'wallet';
|
|
18
|
+
topBarVariant?: 'default' | 'app';
|
|
19
|
+
} & Omit<AppTopBarWithWalletProps, 'variant'>);
|
|
20
|
+
/** Discriminated union for selecting which Footer component to render. */
|
|
21
|
+
export type FooterConfig = ({
|
|
22
|
+
variant: 'compact';
|
|
23
|
+
} & AppFooterProps) | ({
|
|
24
|
+
variant: 'full';
|
|
25
|
+
} & AppFooterForHomePageProps);
|
|
26
|
+
/** Page-level layout and styling options. */
|
|
27
|
+
export interface AppPageProps {
|
|
17
28
|
/** Max width for content area (default: '7xl') */
|
|
18
29
|
maxWidth?: MaxWidth;
|
|
19
30
|
/** Content padding (default: 'md') */
|
|
@@ -30,44 +41,51 @@ export interface AppPageLayoutProps extends VariantProps<typeof layoutVariants>
|
|
|
30
41
|
mainClassName?: string;
|
|
31
42
|
/** Optional aspect ratio (width / height) for content area. When set, children are placed inside a container with fixed aspect ratio using AspectFit behavior. */
|
|
32
43
|
aspectRatio?: number;
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
}
|
|
45
|
+
export interface AppPageLayoutProps {
|
|
46
|
+
/** Page content */
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
/** TopBar configuration - selects which TopBar component to render */
|
|
49
|
+
topBar: TopBarConfig;
|
|
50
|
+
/** Breadcrumbs configuration (optional) */
|
|
51
|
+
breadcrumbs?: AppBreadcrumbsProps;
|
|
52
|
+
/** Footer configuration - selects which Footer component to render */
|
|
53
|
+
footer?: FooterConfig;
|
|
54
|
+
/** Page-level layout and styling options */
|
|
55
|
+
page?: AppPageProps;
|
|
35
56
|
}
|
|
36
57
|
/**
|
|
37
58
|
* AppPageLayout - Layout wrapper combining TopBar, Breadcrumbs, Content, and Footer.
|
|
38
59
|
*
|
|
39
60
|
* Features:
|
|
40
|
-
* -
|
|
61
|
+
* - Props-based TopBar and Footer via discriminated unions
|
|
41
62
|
* - Optional breadcrumbs with share and "Talk to Founder"
|
|
42
63
|
* - Configurable content max-width and padding
|
|
43
64
|
* - Background variants
|
|
44
65
|
* - Dark mode support
|
|
45
|
-
* - Sticky footer behavior
|
|
66
|
+
* - Sticky footer behavior (automatic for compact footer)
|
|
46
67
|
*
|
|
47
68
|
* @example
|
|
48
69
|
* ```tsx
|
|
49
70
|
* <AppPageLayout
|
|
50
|
-
* topBar={
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* }
|
|
71
|
+
* topBar={{
|
|
72
|
+
* variant: 'firebase',
|
|
73
|
+
* logo: { src: '/logo.png', appName: 'My App' },
|
|
74
|
+
* menuItems: menuItems,
|
|
75
|
+
* AuthActionComponent: AuthAction,
|
|
76
|
+
* onLoginClick: () => navigate('/login'),
|
|
77
|
+
* }}
|
|
58
78
|
* breadcrumbs={{
|
|
59
79
|
* items: breadcrumbItems,
|
|
60
80
|
* shareConfig: { title: 'Page', description: 'Description', hashtags: [] },
|
|
61
81
|
* }}
|
|
62
|
-
* footer={
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* }
|
|
69
|
-
* maxWidth="7xl"
|
|
70
|
-
* background="default"
|
|
82
|
+
* footer={{
|
|
83
|
+
* variant: 'compact',
|
|
84
|
+
* version: '1.0.0',
|
|
85
|
+
* companyName: 'My Company',
|
|
86
|
+
* links: [{ label: 'Privacy', href: '/privacy' }],
|
|
87
|
+
* }}
|
|
88
|
+
* page={{ maxWidth: '7xl', background: 'default' }}
|
|
71
89
|
* >
|
|
72
90
|
* <h1>Page Content</h1>
|
|
73
91
|
* </AppPageLayout>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { AppPageLayout, type AppPageLayoutProps } from './app-page-layout';
|
|
1
|
+
export { AppPageLayout, type AppPageLayoutProps, type AppPageProps, type TopBarConfig, type FooterConfig, } from './app-page-layout';
|
package/dist/index.js
CHANGED
|
@@ -1065,31 +1065,65 @@ 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,
|
|
1071
1109
|
breadcrumbs,
|
|
1072
1110
|
footer,
|
|
1073
|
-
|
|
1074
|
-
contentPadding = "md",
|
|
1075
|
-
background = "default",
|
|
1076
|
-
layoutMode = "standard",
|
|
1077
|
-
className,
|
|
1078
|
-
contentClassName,
|
|
1079
|
-
mainClassName,
|
|
1080
|
-
aspectRatio,
|
|
1081
|
-
stickyFooter = false
|
|
1111
|
+
page
|
|
1082
1112
|
}) => {
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1113
|
+
const {
|
|
1114
|
+
maxWidth = "7xl",
|
|
1115
|
+
contentPadding = "md",
|
|
1116
|
+
background = "default",
|
|
1117
|
+
layoutMode = "standard",
|
|
1118
|
+
className,
|
|
1119
|
+
contentClassName,
|
|
1120
|
+
mainClassName,
|
|
1121
|
+
aspectRatio
|
|
1122
|
+
} = page ?? {};
|
|
1123
|
+
const isCompactFooter = (footer == null ? void 0 : footer.variant) === "compact";
|
|
1090
1124
|
const content = aspectRatio ? /* @__PURE__ */ jsx(AspectFitView, { aspectRatio, children }) : children;
|
|
1091
1125
|
return /* @__PURE__ */ jsx(LayoutProvider, { mode: layoutMode, children: /* @__PURE__ */ jsxs("div", { className: cn(layoutVariants({ background }), className), children: [
|
|
1092
|
-
/* @__PURE__ */ jsx("header", { children: topBar }),
|
|
1126
|
+
/* @__PURE__ */ jsx("header", { children: renderTopBar(topBar) }),
|
|
1093
1127
|
breadcrumbs && breadcrumbs.items && breadcrumbs.items.length > 0 && /* @__PURE__ */ jsx(AppBreadcrumbs, { ...breadcrumbs }),
|
|
1094
1128
|
/* @__PURE__ */ jsx("main", { className: cn("flex-1 overflow-auto", mainClassName), children: /* @__PURE__ */ jsx(
|
|
1095
1129
|
"div",
|
|
@@ -1103,7 +1137,13 @@ const AppPageLayout = ({
|
|
|
1103
1137
|
children: content
|
|
1104
1138
|
}
|
|
1105
1139
|
) }),
|
|
1106
|
-
footer && /* @__PURE__ */ jsx(
|
|
1140
|
+
footer && /* @__PURE__ */ jsx(
|
|
1141
|
+
"footer",
|
|
1142
|
+
{
|
|
1143
|
+
className: isCompactFooter ? "sticky bottom-0 z-10" : void 0,
|
|
1144
|
+
children: renderFooter(footer)
|
|
1145
|
+
}
|
|
1146
|
+
)
|
|
1107
1147
|
] }) });
|
|
1108
1148
|
};
|
|
1109
1149
|
var Theme = /* @__PURE__ */ ((Theme2) => {
|