igloo-d2c-components 1.0.6

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 ADDED
@@ -0,0 +1,332 @@
1
+ # D2C Component Library
2
+ Reusable React component library with tenant-aware theming for B2C applications.
3
+
4
+ ## 📦 Installation
5
+
6
+ ### For Local Development (npm link)
7
+
8
+ ```bash
9
+ # In d2c-component-library directory
10
+ yarn install
11
+ yarn build
12
+ yarn link
13
+
14
+ # In b2c-web-demo directory
15
+ yarn link "igloo-d2c-components"
16
+ ```
17
+
18
+ ### For Production (npm package)
19
+
20
+ ```bash
21
+ yarn add igloo-d2c-components
22
+ # or
23
+ npm install igloo-d2c-components
24
+ ```
25
+
26
+ ## 🚀 Quick Start
27
+
28
+ ### 1. Wrap your app with TenantThemeProvider
29
+
30
+ ```tsx
31
+ import { TenantThemeProvider } from 'igloo-d2c-components'
32
+
33
+ const tenantTheme = {
34
+ palette: {
35
+ primary: {
36
+ main: '#5656F6',
37
+ dark: '#1300A9',
38
+ light: '#8183FF',
39
+ },
40
+ secondary: {
41
+ main: '#FF7D7D',
42
+ light: '#FFB3B1',
43
+ },
44
+ },
45
+ typography: {
46
+ fontFamily: '"Manrope", "Roboto", sans-serif',
47
+ },
48
+ }
49
+
50
+ function App() {
51
+ return (
52
+ <TenantThemeProvider tenantId="igloo" theme={tenantTheme}>
53
+ <YourApp />
54
+ </TenantThemeProvider>
55
+ )
56
+ }
57
+ ```
58
+
59
+ ### 2. Use Components
60
+
61
+ ```tsx
62
+ import { Button, Card, Banner } from 'igloo-d2c-components'
63
+
64
+ function MyPage() {
65
+ return (
66
+ <div>
67
+ {/* Tenant-themed button */}
68
+ <Button tenantColored>Click Me</Button>
69
+
70
+ {/* Tenant-themed card */}
71
+ <Card
72
+ title="My Card"
73
+ content="Card content"
74
+ tenantAccent
75
+ />
76
+
77
+ {/* Tenant-themed banner */}
78
+ <Banner
79
+ title="Welcome"
80
+ description="Get started today"
81
+ gradient
82
+ />
83
+ </div>
84
+ )
85
+ }
86
+ ```
87
+
88
+ ## 📚 Available Components
89
+
90
+ ### Button
91
+
92
+ Tenant-aware button component based on MUI Button.
93
+
94
+ ```tsx
95
+ import { Button } from 'igloo-d2c-components'
96
+
97
+ <Button tenantColored variant="contained">
98
+ Tenant Colored Button
99
+ </Button>
100
+
101
+ <Button color="primary">
102
+ Default MUI Button
103
+ </Button>
104
+ ```
105
+
106
+ **Props:**
107
+
108
+ - `tenantColored?: boolean` - Use tenant primary color
109
+ - `variant?: 'text' | 'outlined' | 'contained'` - Button variant
110
+ - All MUI ButtonProps
111
+
112
+ ### Card
113
+
114
+ Tenant-aware card component based on MUI Card.
115
+
116
+ ```tsx
117
+ import { Card } from 'igloo-d2c-components'
118
+
119
+ <Card
120
+ title="Card Title"
121
+ content="Card content goes here"
122
+ actions={<Button>Action</Button>}
123
+ tenantAccent
124
+ />
125
+ ```
126
+
127
+ **Props:**
128
+
129
+ - `title?: React.ReactNode` - Card title
130
+ - `content?: React.ReactNode` - Card content
131
+ - `actions?: React.ReactNode` - Card actions
132
+ - `tenantAccent?: boolean` - Add tenant-colored top border
133
+ - All MUI CardProps
134
+
135
+ ### Banner
136
+
137
+ Promotional banner with tenant theming.
138
+
139
+ ```tsx
140
+ import { Banner } from 'igloo-d2c-components'
141
+
142
+ <Banner
143
+ title="Special Offer"
144
+ description="Limited time only"
145
+ action={<Button>Learn More</Button>}
146
+ gradient
147
+ />
148
+ ```
149
+
150
+ **Props:**
151
+
152
+ - `title: string` - Banner title
153
+ - `description?: string` - Banner description
154
+ - `action?: React.ReactNode` - Action button/element
155
+ - `gradient?: boolean` - Use gradient background
156
+ - All MUI BoxProps
157
+
158
+ ## 🎨 Hooks & Utilities
159
+
160
+ ### useTenantTheme
161
+
162
+ Access tenant theme configuration.
163
+
164
+ ```tsx
165
+ import { useTenantTheme } from 'igloo-d2c-components'
166
+
167
+ function MyComponent() {
168
+ const { theme, tenantId } = useTenantTheme()
169
+ const primaryColor = theme.palette.primary?.main
170
+
171
+ return <div style={{ color: primaryColor }}>...</div>
172
+ }
173
+ ```
174
+
175
+ ### useTenantId
176
+
177
+ Get current tenant ID.
178
+
179
+ ```tsx
180
+ import { useTenantId } from 'igloo-d2c-components'
181
+
182
+ function MyComponent() {
183
+ const tenantId = useTenantId()
184
+ return <div>Current tenant: {tenantId}</div>
185
+ }
186
+ ```
187
+
188
+ ### useIsTenant
189
+
190
+ Check if current tenant matches a specific ID.
191
+
192
+ ```tsx
193
+ import { useIsTenant } from 'igloo-d2c-components'
194
+
195
+ function MyComponent() {
196
+ const isCIMB = useIsTenant('cimb')
197
+
198
+ if (isCIMB) {
199
+ return <CIMBSpecificFeature />
200
+ }
201
+
202
+ return <DefaultFeature />
203
+ }
204
+ ```
205
+
206
+ ### getThemeColor
207
+
208
+ Utility to get color from theme palette.
209
+
210
+ ```tsx
211
+ import { getThemeColor } from 'igloo-d2c-components'
212
+
213
+ const primaryColor = getThemeColor(theme, 'primary.main', '#000000')
214
+ ```
215
+
216
+ ## 🏗️ Tech Stack
217
+
218
+ - **React 17** - UI library
219
+ - **TypeScript 4.9+** - Type safety
220
+ - **MUI 5** - Material-UI components
221
+ - **Emotion** - CSS-in-JS
222
+ - **Rollup** - Build tooling
223
+
224
+ ## 📖 TypeScript Support
225
+
226
+ Full TypeScript support with type definitions included.
227
+
228
+ ```tsx
229
+ import type { ButtonProps, CardProps, TenantThemeConfig } from 'igloo-d2c-components'
230
+ ```
231
+
232
+ ## 🔧 Development
233
+
234
+ ### Build the library
235
+
236
+ ```bash
237
+ # Development mode (watch)
238
+ yarn dev
239
+
240
+ # Production build
241
+ yarn build
242
+ ```
243
+
244
+ ### Lint code
245
+
246
+ ```bash
247
+ yarn lint
248
+ ```
249
+
250
+ ### Type check
251
+
252
+ ```bash
253
+ yarn type-check
254
+ ```
255
+
256
+ ## 📝 Usage in b2c-web-demo
257
+
258
+ ### Integration Example
259
+
260
+ ```tsx
261
+ // In b2c-web-demo/src/layouts/index.tsx
262
+ import { TenantThemeProvider } from 'igloo-d2c-components'
263
+ import { getCurrentTenantConfig } from '@/config/tenants'
264
+
265
+ function Layout({ children }) {
266
+ const tenantConfig = getCurrentTenantConfig()
267
+
268
+ return (
269
+ <TenantThemeProvider
270
+ tenantId={tenantConfig.id}
271
+ theme={{
272
+ palette: tenantConfig.theme.palette,
273
+ typography: tenantConfig.theme.typography,
274
+ }}
275
+ >
276
+ <ThemeProvider theme={muiTheme}>
277
+ {children}
278
+ </ThemeProvider>
279
+ </TenantThemeProvider>
280
+ )
281
+ }
282
+ ```
283
+
284
+ ### Using Components
285
+
286
+ ```tsx
287
+ // In any component
288
+ import { Button, Card, Banner } from 'igloo-d2c-components'
289
+
290
+ function MyPage() {
291
+ return (
292
+ <>
293
+ <Banner
294
+ title="Welcome to Insurance"
295
+ description="Find the best deals"
296
+ action={<Button tenantColored>Get Quote</Button>}
297
+ gradient
298
+ />
299
+
300
+ <Card
301
+ title="Popular Plans"
302
+ content="View our most popular insurance plans"
303
+ tenantAccent
304
+ />
305
+ </>
306
+ )
307
+ }
308
+ ```
309
+
310
+ ## 🎯 Best Practices
311
+
312
+ 1. **Always wrap with TenantThemeProvider** - Required for tenant theming to work
313
+ 2. **Use tenantColored prop** - For components that should follow tenant branding
314
+ 3. **Maintain type safety** - Use TypeScript types provided by the library
315
+ 4. **Extend cautiously** - Extend components via composition, not modification
316
+
317
+ ## 📄 License
318
+
319
+ MIT
320
+
321
+ ## 🤝 Contributing
322
+
323
+ 1. Create feature branch
324
+ 2. Make changes
325
+ 3. Run `yarn build` and `yarn lint`
326
+ 4. Test in b2c-web-demo using `yarn link`
327
+ 5. Submit PR
328
+
329
+ ---
330
+
331
+ **Version:** 1.0.0
332
+ **Author:** Igloo Team
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material");const n=t.createContext(void 0);function a(){const e=t.useContext(n);if(void 0===e)throw new Error("useTenantTheme must be used within a TenantThemeProvider");return e}exports.Banner=function({title:t,description:n,action:o,gradient:i=!0,sx:p,...s}){const{theme:c}=a(),l=i?`linear-gradient(135deg, ${c.palette.primary?.main} 0%, ${c.palette.primary?.light||c.palette.primary?.main} 100%)`:c.palette.primary?.main;return e.jsxs(r.Box,{sx:{background:l,color:"white",padding:"32px",borderRadius:"12px",textAlign:"center",...p},...s,children:[e.jsx(r.Typography,{variant:"h4",component:"h2",gutterBottom:!0,fontWeight:"bold",children:t}),n&&e.jsx(r.Typography,{variant:"body1",sx:{opacity:.95,mb:o?2:0},children:n}),o&&e.jsx(r.Box,{sx:{mt:2},children:o})]})},exports.Button=function({tenantColored:t=!1,variant:n="contained",sx:o,color:i,...p}){const{theme:s}=a(),c=t?{backgroundColor:s.palette.primary?.main,color:"#fff","&:hover":{backgroundColor:s.palette.primary?.dark||s.palette.primary?.main},...o}:o;return e.jsx(r.Button,{variant:n,color:t?void 0:i,sx:c,...p})},exports.Card=function({title:t,headerAction:n,content:o,actions:i,tenantAccent:p=!1,sx:s,children:c,...l}){const{theme:d}=a(),m=p?{borderTop:`4px solid ${d.palette.primary?.main}`,...s}:s;return e.jsxs(r.Card,{sx:m,...l,children:[t&&e.jsx(r.CardHeader,{title:t,action:n}),(o||c)&&e.jsx(r.CardContent,{children:o||c}),i&&e.jsx(r.CardActions,{children:i})]})},exports.TenantThemeProvider=function({children:r,tenantId:a,theme:o}){const i=t.useMemo(()=>({tenantId:a,theme:o}),[a,o]);return e.jsx(n.Provider,{value:i,children:r})},exports.createThemeCSSVariables=function(e,t="--tenant"){const r={};return e.palette.primary&&Object.entries(e.palette.primary).forEach(([e,n])=>{"string"==typeof n&&(r[`${t}-primary-${e}`]=n)}),e.palette.secondary&&Object.entries(e.palette.secondary).forEach(([e,n])=>{"string"==typeof n&&(r[`${t}-secondary-${e}`]=n)}),e.typography?.fontFamily&&(r[`${t}-font-family`]=e.typography.fontFamily),r},exports.getThemeColor=function(e,t,r="#000000"){const n=t.split(".");let a=e.palette;for(const e of n){if(!a||"object"!=typeof a||!(e in a))return r;a=a[e]}return"string"==typeof a?a:r},exports.mergeTenantTheme=function(e,t){return{...e,palette:{...e.palette,...t.palette,primary:{...e.palette?.primary||{},...t.palette.primary||{}},secondary:{...e.palette?.secondary||{},...t.palette.secondary||{}}},typography:{...e.typography,...t.typography}}},exports.useIsTenant=function(e){const{tenantId:t}=a();return t===e},exports.useTenantId=function(){const{tenantId:e}=a();return e},exports.useTenantTheme=a;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/context/TenantThemeContext.tsx","../../src/components/Banner/Banner.tsx","../../src/components/Button/Button.tsx","../../src/components/Card/Card.tsx","../../src/utils/theme.ts"],"sourcesContent":[null,null,null,null,null],"names":["TenantThemeContext","createContext","undefined","useTenantTheme","context","useContext","Error","title","description","action","gradient","sx","props","theme","background","palette","primary","main","light","_jsxs","jsxs","Box","color","padding","borderRadius","textAlign","children","_jsx","jsx","Typography","variant","component","gutterBottom","fontWeight","opacity","mb","mt","tenantColored","buttonSx","backgroundColor","dark","MuiButton","Button","headerAction","content","actions","tenantAccent","cardSx","borderTop","MuiCard","CardHeader","CardContent","CardActions","tenantId","value","useMemo","Provider","prefix","variables","Object","entries","forEach","key","secondary","typography","fontFamily","path","defaultColor","keys","split","baseTheme","tenantTheme","checkTenantId"],"mappings":"8FAQA,MAAMA,EAAqBC,EAAAA,mBAA8CC,YA8CzDC,IACf,MAAMC,EAAUC,aAAWL,GAE3B,QAAgBE,IAAZE,EACH,MAAM,IAAIE,MAAM,4DAGjB,OAAOF,CACR,0BCtBuBG,MACtBA,EAAKC,YACLA,EAAWC,OACXA,EAAMC,SACNA,GAAW,EAAIC,GACfA,KACGC,IAEH,MAAMC,MAAEA,GAAUV,IAEZW,EAAaJ,EAChB,2BAA2BG,EAAME,QAAQC,SAASC,YAClDJ,EAAME,QAAQC,SAASE,OAASL,EAAME,QAAQC,SAASC,aAEvDJ,EAAME,QAAQC,SA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,YAGlB,sBJWM,SAAsBQ,GAC3B,MAAMnB,SAAEA,GAAalD,IACrB,OAAOkD,IAAamB,CACrB,iCAVC,MAAMnB,SAAEA,GAAalD,IACrB,OAAOkD,CACR"}
@@ -0,0 +1,2 @@
1
+ import{jsx as t,jsxs as e}from"react/jsx-runtime";import{createContext as r,useMemo as n,useContext as a}from"react";import{Button as o,Card as i,CardHeader as c,CardContent as p,CardActions as l,Box as d,Typography as m}from"@mui/material";const s=r(void 0);function y({children:e,tenantId:r,theme:a}){const o=n(()=>({tenantId:r,theme:a}),[r,a]);return t(s.Provider,{value:o,children:e})}function h(){const t=a(s);if(void 0===t)throw new Error("useTenantTheme must be used within a TenantThemeProvider");return t}function u(){const{tenantId:t}=h();return t}function f(t){const{tenantId:e}=h();return e===t}function g({tenantColored:e=!1,variant:r="contained",sx:n,color:a,...i}){const{theme:c}=h(),p=e?{backgroundColor:c.palette.primary?.main,color:"#fff","&:hover":{backgroundColor:c.palette.primary?.dark||c.palette.primary?.main},...n}:n;return t(o,{variant:r,color:e?void 0:a,sx:p,...i})}function x({title:r,headerAction:n,content:a,actions:o,tenantAccent:d=!1,sx:m,children:s,...y}){const{theme:u}=h(),f=d?{borderTop:`4px solid ${u.palette.primary?.main}`,...m}:m;return e(i,{sx:f,...y,children:[r&&t(c,{title:r,action:n}),(a||s)&&t(p,{children:a||s}),o&&t(l,{children:o})]})}function b({title:r,description:n,action:a,gradient:o=!0,sx:i,...c}){const{theme:p}=h(),l=o?`linear-gradient(135deg, ${p.palette.primary?.main} 0%, ${p.palette.primary?.light||p.palette.primary?.main} 100%)`:p.palette.primary?.main;return e(d,{sx:{background:l,color:"white",padding:"32px",borderRadius:"12px",textAlign:"center",...i},...c,children:[t(m,{variant:"h4",component:"h2",gutterBottom:!0,fontWeight:"bold",children:r}),n&&t(m,{variant:"body1",sx:{opacity:.95,mb:a?2:0},children:n}),a&&t(d,{sx:{mt:2},children:a})]})}function v(t,e,r="#000000"){const n=e.split(".");let a=t.palette;for(const t of n){if(!a||"object"!=typeof a||!(t in a))return r;a=a[t]}return"string"==typeof a?a:r}function $(t,e){return{...t,palette:{...t.palette,...e.palette,primary:{...t.palette?.primary||{},...e.palette.primary||{}},secondary:{...t.palette?.secondary||{},...e.palette.secondary||{}}},typography:{...t.typography,...e.typography}}}function T(t,e="--tenant"){const r={};return t.palette.primary&&Object.entries(t.palette.primary).forEach(([t,n])=>{"string"==typeof n&&(r[`${e}-primary-${t}`]=n)}),t.palette.secondary&&Object.entries(t.palette.secondary).forEach(([t,n])=>{"string"==typeof n&&(r[`${e}-secondary-${t}`]=n)}),t.typography?.fontFamily&&(r[`${e}-font-family`]=t.typography.fontFamily),r}export{b as Banner,g as Button,x as Card,y as TenantThemeProvider,T as createThemeCSSVariables,v as getThemeColor,$ as mergeTenantTheme,f as useIsTenant,u as useTenantId,h as useTenantTheme};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/context/TenantThemeContext.tsx","../../src/components/Button/Button.tsx","../../src/components/Card/Card.tsx","../../src/components/Banner/Banner.tsx","../../src/utils/theme.ts"],"sourcesContent":[null,null,null,null,null],"names":["TenantThemeContext","createContext","undefined","TenantThemeProvider","children","tenantId","theme","value","useMemo","_jsx","Provider","useTenantTheme","context","useContext","Error","useTenantId","useIsTenant","checkTenantId","Button","tenantColored","variant","sx","color","props","buttonSx","backgroundColor","palette","primary","main","dark","MuiButton","Card","title","headerAction","content","actions","tenantAccent","cardSx","borderTop","_jsxs","MuiCard","CardHeader","action","CardContent","CardActions","Banner","description","gradient","background","light","Box","padding","borderRadius","textAlign","Typography","component","gutterBottom","fontWeight","opacity","mb","mt","getThemeColor","path","defaultColor","keys","split","key","mergeTenantTheme","baseTheme","tenantTheme","secondary","typography","createThemeCSSVariables","prefix","variables","Object","entries","forEach","fontFamily"],"mappings":"iPAQA,MAAMA,EAAqBC,OAA8CC,GAsBnE,SAAUC,GAAoBC,SACnCA,EAAQC,SACRA,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MAAMC,EAAoC,CAAA,EAyB1C,OAtBIpE,EAAMoB,QAAQC,SACjBgD,OAAOC,QAAQtE,EAAMoB,QAAQC,SAASkD,QAAQ,EAAEX,EAAK3D,MAC/B,iBAAVA,IACVmE,EAAU,GAAGD,aAAkBP,KAAS3D,KAMvCD,EAAMoB,QAAQ4C,WACjBK,OAAOC,QAAQtE,EAAMoB,QAAQ4C,WAAWO,QAAQ,EAAEX,EAAK3D,MACjC,iBAAVA,IACVmE,EAAU,GAAGD,eAAoBP,KAAS3D,KAMzCD,EAAMiE,YAAYO,aACrBJ,EAAU,GAAGD,iBAAwBnE,EAAMiE,WAAWO,YAGhDJ,CACR"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Tenant-Aware Banner Component
3
+ * Promotional banner with tenant theming
4
+ */
5
+ /// <reference types="react" />
6
+ import { BoxProps } from '@mui/material';
7
+ export interface BannerProps extends Omit<BoxProps, 'title'> {
8
+ /**
9
+ * Banner title
10
+ */
11
+ title: string;
12
+ /**
13
+ * Banner description
14
+ */
15
+ description?: string;
16
+ /**
17
+ * Banner action button
18
+ */
19
+ action?: React.ReactNode;
20
+ /**
21
+ * Use gradient background
22
+ */
23
+ gradient?: boolean;
24
+ }
25
+ /**
26
+ * Banner component with tenant theme support
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * <Banner
31
+ * title="Welcome to Our Platform"
32
+ * description="Get started today"
33
+ * action={<Button>Get Started</Button>}
34
+ * gradient
35
+ * />
36
+ * ```
37
+ */
38
+ export declare function Banner({ title, description, action, gradient, sx, ...props }: BannerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import { Banner } from './Banner';
3
+ declare const _default: ComponentMeta<typeof Banner>;
4
+ export default _default;
5
+ export declare const Default: ComponentStory<typeof Banner>;
6
+ export declare const WithGradient: ComponentStory<typeof Banner>;
7
+ export declare const WithAction: ComponentStory<typeof Banner>;
8
+ export declare const ComplexAction: ComponentStory<typeof Banner>;
9
+ export declare const LongContent: ComponentStory<typeof Banner>;
10
+ export declare const WithCIMBTheme: ComponentStory<typeof Banner>;
11
+ export declare const Variants: () => import("react/jsx-runtime").JSX.Element;
12
+ export declare const MinimalContent: ComponentStory<typeof Banner>;
13
+ export declare const NoDescription: ComponentStory<typeof Banner>;
@@ -0,0 +1,2 @@
1
+ export { Banner } from './Banner';
2
+ export type { BannerProps } from './Banner';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Tenant-Aware Button Component
3
+ * MUI Button with tenant theming support
4
+ */
5
+ import { ButtonProps as MuiButtonProps } from '@mui/material';
6
+ export interface ButtonProps extends Omit<MuiButtonProps, 'color'> {
7
+ /**
8
+ * Button variant
9
+ */
10
+ variant?: 'text' | 'outlined' | 'contained';
11
+ /**
12
+ * Use tenant primary color
13
+ */
14
+ tenantColored?: boolean;
15
+ /**
16
+ * MUI color prop (only used if tenantColored is false)
17
+ */
18
+ color?: MuiButtonProps['color'];
19
+ }
20
+ /**
21
+ * Button component with tenant theme support
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * // Uses tenant primary color
26
+ * <Button tenantColored>Click Me</Button>
27
+ *
28
+ * // Uses MUI default color
29
+ * <Button color="primary">Click Me</Button>
30
+ * ```
31
+ */
32
+ export declare function Button({ tenantColored, variant, sx, color, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import { Button } from './Button';
3
+ declare const _default: ComponentMeta<typeof Button>;
4
+ export default _default;
5
+ export declare const Default: ComponentStory<typeof Button>;
6
+ export declare const TenantColored: ComponentStory<typeof Button>;
7
+ export declare const Outlined: ComponentStory<typeof Button>;
8
+ export declare const Text: ComponentStory<typeof Button>;
9
+ export declare const Sizes: () => import("react/jsx-runtime").JSX.Element;
10
+ export declare const Variants: () => import("react/jsx-runtime").JSX.Element;
11
+ export declare const WithCIMBTheme: ComponentStory<typeof Button>;
12
+ export declare const Disabled: ComponentStory<typeof Button>;
@@ -0,0 +1,2 @@
1
+ export { Button } from './Button';
2
+ export type { ButtonProps } from './Button';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Tenant-Aware Card Component
3
+ * MUI Card with tenant theming support
4
+ */
5
+ /// <reference types="react" />
6
+ import { CardProps as MuiCardProps } from '@mui/material';
7
+ export interface CardProps extends Omit<MuiCardProps, 'title' | 'content' | 'action'> {
8
+ /**
9
+ * Card title
10
+ */
11
+ title?: React.ReactNode;
12
+ /**
13
+ * Card header action
14
+ */
15
+ headerAction?: React.ReactNode;
16
+ /**
17
+ * Card content
18
+ */
19
+ content?: React.ReactNode;
20
+ /**
21
+ * Card actions
22
+ */
23
+ actions?: React.ReactNode;
24
+ /**
25
+ * Use tenant accent border
26
+ */
27
+ tenantAccent?: boolean;
28
+ }
29
+ /**
30
+ * Card component with tenant theme support
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * <Card
35
+ * title="My Card"
36
+ * content="Card content"
37
+ * actions={<Button>Action</Button>}
38
+ * tenantAccent
39
+ * />
40
+ * ```
41
+ */
42
+ export declare function Card({ title, headerAction, content, actions, tenantAccent, sx, children, ...props }: CardProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import { Card } from './Card';
3
+ declare const _default: ComponentMeta<typeof Card>;
4
+ export default _default;
5
+ export declare const Default: ComponentStory<typeof Card>;
6
+ export declare const WithTenantAccent: ComponentStory<typeof Card>;
7
+ export declare const WithActions: ComponentStory<typeof Card>;
8
+ export declare const CompleteCard: ComponentStory<typeof Card>;
9
+ export declare const ElevationVariants: () => import("react/jsx-runtime").JSX.Element;
10
+ export declare const WithCIMBTheme: ComponentStory<typeof Card>;
11
+ export declare const LongContent: ComponentStory<typeof Card>;
@@ -0,0 +1,2 @@
1
+ export { Card } from './Card';
2
+ export type { CardProps } from './Card';
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Tenant Theme Context
3
+ * Provides tenant-specific theme configuration to components
4
+ */
5
+ import React from 'react';
6
+ import { TenantContextValue, TenantThemeConfig } from '../types/tenant';
7
+ export interface TenantThemeProviderProps {
8
+ children: React.ReactNode;
9
+ tenantId: string;
10
+ theme: TenantThemeConfig;
11
+ }
12
+ /**
13
+ * TenantThemeProvider
14
+ * Wraps components to provide tenant-specific theming
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <TenantThemeProvider
19
+ * tenantId="cimb"
20
+ * theme={cimbTheme}
21
+ * >
22
+ * <App />
23
+ * </TenantThemeProvider>
24
+ * ```
25
+ */
26
+ export declare function TenantThemeProvider({ children, tenantId, theme, }: TenantThemeProviderProps): import("react/jsx-runtime").JSX.Element;
27
+ /**
28
+ * Hook to access tenant theme configuration
29
+ * @throws Error if used outside TenantThemeProvider
30
+ */
31
+ export declare function useTenantTheme(): TenantContextValue;
32
+ /**
33
+ * Hook to get tenant ID
34
+ */
35
+ export declare function useTenantId(): string;
36
+ /**
37
+ * Hook to check if current tenant matches given tenant ID
38
+ */
39
+ export declare function useIsTenant(checkTenantId: string): boolean;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * D2C Component Library
3
+ * Reusable components with tenant-aware theming
4
+ */
5
+ export { TenantThemeProvider, useTenantTheme, useTenantId, useIsTenant, } from './context/TenantThemeContext';
6
+ export type { TenantThemeProviderProps } from './context/TenantThemeContext';
7
+ export type { TenantPalette, TenantTypography, TenantThemeConfig, TenantContextValue, } from './types/tenant';
8
+ export { Button } from './components/Button';
9
+ export type { ButtonProps } from './components/Button';
10
+ export { Card } from './components/Card';
11
+ export type { CardProps } from './components/Card';
12
+ export { Banner } from './components/Banner';
13
+ export type { BannerProps } from './components/Banner';
14
+ export { getThemeColor, mergeTenantTheme, createThemeCSSVariables } from './utils/theme';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Tenant Theme Configuration Types
3
+ * These interfaces define the structure for tenant-specific theming
4
+ */
5
+ export interface TenantPalette {
6
+ primary?: {
7
+ main: string;
8
+ dark?: string;
9
+ light?: string;
10
+ bright?: string;
11
+ plain?: string;
12
+ border?: string;
13
+ };
14
+ secondary?: {
15
+ dim?: string;
16
+ dark?: string;
17
+ main: string;
18
+ bright?: string;
19
+ mediumBright?: string;
20
+ light?: string;
21
+ lighter?: string;
22
+ };
23
+ [key: string]: any;
24
+ }
25
+ export interface TenantTypography {
26
+ fontFamily?: string;
27
+ [key: string]: any;
28
+ }
29
+ export interface TenantThemeConfig {
30
+ palette: TenantPalette;
31
+ typography?: TenantTypography;
32
+ }
33
+ /**
34
+ * Tenant Context Value
35
+ * This is what's provided by the TenantThemeProvider
36
+ */
37
+ export interface TenantContextValue {
38
+ tenantId: string;
39
+ theme: TenantThemeConfig;
40
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Theme Utility Functions
3
+ * Helper functions for working with tenant themes
4
+ */
5
+ import { Theme } from '@mui/material/styles';
6
+ import { TenantThemeConfig } from '../types/tenant';
7
+ /**
8
+ * Get color value from theme palette path
9
+ * @param theme - Tenant theme configuration
10
+ * @param path - Dot-notation path to color (e.g., 'primary.main')
11
+ * @param defaultColor - Fallback color if path not found
12
+ * @returns Color string
13
+ */
14
+ export declare function getThemeColor(theme: TenantThemeConfig, path: string, defaultColor?: string): string;
15
+ /**
16
+ * Merge tenant theme with base MUI theme
17
+ * @param baseTheme - Base MUI theme
18
+ * @param tenantTheme - Tenant-specific theme configuration
19
+ * @returns Merged theme
20
+ */
21
+ export declare function mergeTenantTheme(baseTheme: Partial<Theme>, tenantTheme: TenantThemeConfig): any;
22
+ /**
23
+ * Create CSS variables from tenant theme
24
+ * Useful for using theme values in CSS
25
+ * @param theme - Tenant theme configuration
26
+ * @param prefix - Prefix for CSS variable names
27
+ * @returns Object with CSS variable definitions
28
+ */
29
+ export declare function createThemeCSSVariables(theme: TenantThemeConfig, prefix?: string): Record<string, string>;
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "igloo-d2c-components",
3
+ "version": "1.0.6",
4
+ "description": "Reusable component library with tenant-aware theming for B2C applications",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
12
+ "scripts": {
13
+ "build": "yarn clean && rollup -c rollup.config.cjs && tsc --declaration --emitDeclarationOnly --outDir dist/types",
14
+ "dev": "rollup -c rollup.config.cjs -w",
15
+ "lint": "eslint src --ext .ts,.tsx",
16
+ "type-check": "tsc --noEmit",
17
+ "clean": "rimraf dist",
18
+ "prepare": "yarn build",
19
+ "prepublishOnly": "bash scripts/auto-version-bump.sh && yarn clean && yarn build",
20
+ "storybook": "start-storybook -p 6006",
21
+ "build-storybook": "build-storybook",
22
+ "release": "bash scripts/release.sh",
23
+ "npmPublish": "yarn prepublishOnly && npm publish"
24
+ },
25
+ "engines": {
26
+ "node": ">=16.20.0 <=18.x"
27
+ },
28
+ "keywords": [
29
+ "react",
30
+ "components",
31
+ "mui",
32
+ "tenant",
33
+ "theme",
34
+ "design-system"
35
+ ],
36
+ "author": "Igloo",
37
+ "license": "MIT",
38
+ "peerDependencies": {
39
+ "@emotion/react": "^11.11.4",
40
+ "@emotion/styled": "^11.11.5",
41
+ "@mui/icons-material": "^5.15.20",
42
+ "@mui/material": "^5.15.20",
43
+ "@mui/styles": "^5.15.20",
44
+ "react": "^17.0.0",
45
+ "react-dom": "^17.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@babel/core": "^7.22.0",
49
+ "@emotion/react": "^11.11.4",
50
+ "@emotion/styled": "^11.11.5",
51
+ "@mui/icons-material": "^5.15.20",
52
+ "@mui/material": "^5.15.20",
53
+ "@mui/styles": "^5.15.20",
54
+ "@rollup/plugin-commonjs": "^24.0.0",
55
+ "@rollup/plugin-node-resolve": "^15.0.0",
56
+ "@rollup/plugin-terser": "^0.4.4",
57
+ "@rollup/plugin-typescript": "^11.0.0",
58
+ "@storybook/addon-essentials": "6.5.16",
59
+ "@storybook/addon-interactions": "6.5.16",
60
+ "@storybook/addon-links": "6.5.16",
61
+ "@storybook/builder-vite": "0.4.2",
62
+ "@storybook/react": "6.5.16",
63
+ "@storybook/testing-library": "0.0.13",
64
+ "@types/minimatch": "^3.0.5",
65
+ "@types/react": "^17.0.0",
66
+ "@types/react-dom": "^17.0.0",
67
+ "@typescript-eslint/eslint-plugin": "^5.0.0",
68
+ "@typescript-eslint/parser": "^5.0.0",
69
+ "@vitejs/plugin-react": "^3.1.0",
70
+ "eslint": "^8.0.0",
71
+ "eslint-plugin-react": "^7.32.0",
72
+ "eslint-plugin-react-hooks": "^4.6.0",
73
+ "react": "^17.0.0",
74
+ "react-dom": "^17.0.0",
75
+ "rimraf": "^5.0.0",
76
+ "rollup": "^3.29.5",
77
+ "rollup-plugin-peer-deps-external": "^2.2.4",
78
+ "tslib": "^2.8.1",
79
+ "typescript": "^4.9.0",
80
+ "vite": "4.3.9"
81
+ },
82
+ "publishConfig": {
83
+ "access": "public",
84
+ "registry": "https://registry.npmjs.org/"
85
+ },
86
+ "bugs": {
87
+ "url": "https://gitlab.iglooinsure.com/axinan/fe/d2c-component-library/-/issues"
88
+ },
89
+ "homepage": "https://gitlab.iglooinsure.com/axinan/fe/d2c-component-library#readme"
90
+ }