@metrifox/angular-sdk 1.0.2 → 2.0.0
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 +310 -320
- package/dist/LICENSE +21 -0
- package/dist/README.md +477 -0
- package/dist/fesm2022/index.mjs +9653 -0
- package/{lib → dist/lib}/metrifox.module.d.ts +2 -2
- package/{lib → dist/lib}/metrifox.service.d.ts +22 -14
- package/{lib → dist/lib}/types/enum.d.ts +12 -2
- package/{lib → dist/lib}/types/interface.d.ts +390 -103
- package/dist/lib/utils/theme.d.ts +27 -0
- package/dist/modules/customer-portal/components/billing-history.component.d.ts +14 -0
- package/dist/modules/customer-portal/components/credit/credit-balance-section.component.d.ts +76 -0
- package/dist/modules/customer-portal/components/customer-portal.component.d.ts +64 -0
- package/dist/modules/customer-portal/components/entitlements/entitlement-summary.component.d.ts +15 -0
- package/dist/modules/customer-portal/components/entitlements/entitlement-usage.component.d.ts +35 -0
- package/dist/modules/customer-portal/components/entitlements/entitlements-section.component.d.ts +14 -0
- package/dist/modules/customer-portal/components/invoice-preview.component.d.ts +26 -0
- package/dist/modules/customer-portal/components/payment.component.d.ts +12 -0
- package/dist/modules/customer-portal/components/plan/plans-section.component.d.ts +70 -0
- package/dist/modules/customer-portal/components/subscription/subscription-actions.component.d.ts +22 -0
- package/dist/modules/customer-portal/components/subscription/subscription-details.component.d.ts +12 -0
- package/dist/modules/customer-portal/components/subscription/subscription-items.component.d.ts +27 -0
- package/dist/modules/customer-portal/components/subscription/subscription-section.component.d.ts +34 -0
- package/dist/modules/customer-portal/utils/defaults.d.ts +2 -0
- package/dist/modules/customer-portal/utils/helpers.d.ts +20 -0
- package/dist/modules/customer-portal/utils/icon-helpers.d.ts +3 -0
- package/dist/modules/customer-portal/utils/icons.d.ts +18 -0
- package/dist/modules/metrifox-ui/index.d.ts +1 -0
- package/dist/modules/metrifox-ui/themed-popover.component.d.ts +19 -0
- package/dist/modules/pricing-table/components/localization-select.component.d.ts +22 -0
- package/{lib/components/pricing-table → dist/modules/pricing-table/components}/pricing-table.component.d.ts +28 -6
- package/dist/modules/pricing-table/utils/defaults.d.ts +2 -0
- package/dist/public-api.d.ts +22 -0
- package/dist/styles.css +3 -0
- package/dist-storybook/3rdpartylicenses.txt +304 -0
- package/dist-storybook/index.html +12 -0
- package/dist-storybook/main.js +1 -0
- package/dist-storybook/polyfills.js +1 -0
- package/dist-storybook/runtime.js +1 -0
- package/dist-storybook/styles.css +2 -0
- package/package.json +53 -13
- package/vitest.config.ts +10 -0
- package/vitest.setup.ts +5 -0
- package/fesm2022/index.mjs +0 -5898
- package/lib/components/customer-portal/customer-portal.component.d.ts +0 -193
- package/public-api.d.ts +0 -20
- package/styles.css +0 -3
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{lib → dist/lib}/types/index.d.ts +0 -0
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Metrifox
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
# MetriFox Angular SDK
|
|
2
|
+
|
|
3
|
+
A fully-configurable **Angular SDK** providing ready-to-use components for SaaS and billing platforms including customer portals, pricing tables, and more.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ⚠️ Version notice – breaking changes (**v2.0.0+**)
|
|
8
|
+
|
|
9
|
+
**If you are upgrading from a release before v2.0.0, read this.**
|
|
10
|
+
|
|
11
|
+
From **`@metrifox/angular-sdk` v2.0.0** onward, both **Customer Portal** and **Pricing Table** use a **new theme structure**. The theme API is **not backward compatible** with pre-2.0.0 versions.
|
|
12
|
+
|
|
13
|
+
- **Theme is now a single object** passed via `MetrifoxService.initialize({ theme })` with two keys: `customerPortal` and `pricingTable`. The previous top-level `pricingTableTheme` option is **removed** on v2.0.0+; use `theme.pricingTable` instead.
|
|
14
|
+
- **Customer Portal theme** uses a new grouped shape: `general`, `tabs`, `sections`, `buttons`, `lineItems`, `tables`, `modals`, and `plans`. Property names and nesting have changed from older versions.
|
|
15
|
+
- **Pricing Table theme** now strictly follows the same nested structure as Customer Portal: all plan-related keys must be under `plans` (e.g. `plans.planCards`, `plans.planToggle`). Top-level plan keys are no longer supported.
|
|
16
|
+
- **Both components** accept an optional `theme` input per instance to override or extend the global theme from `MetrifoxService.initialize`.
|
|
17
|
+
|
|
18
|
+
If you were using custom themes before, you will need to **migrate your theme objects** to the new structure. Omit any keys you don't need; the SDK merges your values with defaults. See the [Styling](#styling) section below for the full theme shapes and examples.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# using npm
|
|
26
|
+
npm install @metrifox/angular-sdk
|
|
27
|
+
|
|
28
|
+
# or pnpm
|
|
29
|
+
pnpm add @metrifox/angular-sdk
|
|
30
|
+
|
|
31
|
+
# or yarn
|
|
32
|
+
yarn add @metrifox/angular-sdk
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Setup
|
|
38
|
+
|
|
39
|
+
### 1. Provide the SDK
|
|
40
|
+
|
|
41
|
+
Register the SDK providers in your app config:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// app.config.ts (Standalone)
|
|
45
|
+
import { ApplicationConfig } from "@angular/core";
|
|
46
|
+
import { provideMetrifox } from "@metrifox/angular-sdk";
|
|
47
|
+
|
|
48
|
+
export const appConfig: ApplicationConfig = {
|
|
49
|
+
providers: [
|
|
50
|
+
provideMetrifox(), // provides HttpClient + MetrifoxService
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 2. Initialize the SDK
|
|
56
|
+
|
|
57
|
+
Before using any components, initialize the SDK once with your Client key:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { MetrifoxService } from "@metrifox/angular-sdk";
|
|
61
|
+
|
|
62
|
+
MetrifoxService.initialize({
|
|
63
|
+
clientKey: "your-metrifox-client-key",
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 3. Import Styles
|
|
68
|
+
|
|
69
|
+
Add the SDK styles to your `angular.json`:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"styles": ["src/styles.css", "node_modules/@metrifox/angular-sdk/styles.css"]
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or import in your global `styles.css`:
|
|
78
|
+
|
|
79
|
+
```css
|
|
80
|
+
@import "@metrifox/angular-sdk/styles.css";
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
> Compatible with **Angular 17, 18, and 19**. All components are standalone (no NgModule required).
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Widgets
|
|
88
|
+
|
|
89
|
+
## `CustomerPortal`
|
|
90
|
+
|
|
91
|
+
Displays a customizable customer dashboard with plans, subscriptions, billing, credits, and more.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { Component } from "@angular/core";
|
|
95
|
+
import { CustomerPortalComponent, SectionConfig } from "@metrifox/angular-sdk";
|
|
96
|
+
|
|
97
|
+
@Component({
|
|
98
|
+
selector: "app-billing",
|
|
99
|
+
standalone: true,
|
|
100
|
+
imports: [CustomerPortalComponent],
|
|
101
|
+
template: `
|
|
102
|
+
<metrifox-customer-portal
|
|
103
|
+
[customerKey]="'your-customer-key'"
|
|
104
|
+
[sectionsConfig]="sections"
|
|
105
|
+
/>
|
|
106
|
+
`,
|
|
107
|
+
})
|
|
108
|
+
export class BillingComponent {
|
|
109
|
+
sections: SectionConfig[] = [
|
|
110
|
+
{ key: "subscription" },
|
|
111
|
+
{ key: "plan" },
|
|
112
|
+
{ key: "billingHistory", hidden: true },
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Optional **`theme`** input: pass a `CustomerPortalTheme` object to override or extend the global theme from `MetrifoxService.initialize` for this instance only.
|
|
118
|
+
|
|
119
|
+
#### Section Configuration
|
|
120
|
+
|
|
121
|
+
The `sectionsConfig` input controls what appears in the portal.
|
|
122
|
+
|
|
123
|
+
| Property | Type | Description |
|
|
124
|
+
| ----------- | ----------------- | --------------------------------------------------- |
|
|
125
|
+
| `key` | `SectionKey` | Unique key of the section (see list below) |
|
|
126
|
+
| `hidden` | `boolean` | Hide this section when `true` |
|
|
127
|
+
| `component` | `Type<any>` | Replace the default section with your own component |
|
|
128
|
+
| `props` | `Record<string, unknown>` | Extra props passed to the custom or default section |
|
|
129
|
+
|
|
130
|
+
#### Built-in Section Keys
|
|
131
|
+
|
|
132
|
+
| Key | Description |
|
|
133
|
+
| ------------------ | ----------------------------- |
|
|
134
|
+
| `upcomingInvoice` | Displays next invoice details |
|
|
135
|
+
| `subscription` | Active subscription overview |
|
|
136
|
+
| `creditBalance` | Shows user wallet balance |
|
|
137
|
+
| `entitlementUsage` | Displays resource usage |
|
|
138
|
+
| `paymentOverview` | Payment summary and methods |
|
|
139
|
+
| `billingHistory` | List of past transactions |
|
|
140
|
+
| `plan` | Current plan details |
|
|
141
|
+
|
|
142
|
+
#### Section Anchors
|
|
143
|
+
|
|
144
|
+
Each portal section renders inside a `<section id="...">` wrapper so you can link directly to segments of a customer portal view. The default anchor IDs are:
|
|
145
|
+
|
|
146
|
+
| Anchor ID | Section Key |
|
|
147
|
+
| -------------------- | ------------------ |
|
|
148
|
+
| `#upcoming-invoice` | `upcomingInvoice` |
|
|
149
|
+
| `#subscription` | `subscription` |
|
|
150
|
+
| `#credit-balance` | `creditBalance` |
|
|
151
|
+
| `#entitlement-usage` | `entitlementUsage` |
|
|
152
|
+
| `#payment-overview` | `paymentOverview` |
|
|
153
|
+
| `#billing-history` | `billingHistory` |
|
|
154
|
+
| `#plan` | `plan` |
|
|
155
|
+
|
|
156
|
+
Use these anchors when embedding the SDK or sharing deep links (e.g., `https://app.example.com/portal#billing-history`).
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Pricing Table
|
|
161
|
+
|
|
162
|
+
Displays subscription plans and one-time purchases in a configurable pricing table component.
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
import { Component } from "@angular/core";
|
|
166
|
+
import { PricingTableComponent } from "@metrifox/angular-sdk";
|
|
167
|
+
|
|
168
|
+
@Component({
|
|
169
|
+
selector: "app-pricing",
|
|
170
|
+
standalone: true,
|
|
171
|
+
imports: [PricingTableComponent],
|
|
172
|
+
template: `
|
|
173
|
+
<metrifox-pricing-table
|
|
174
|
+
[checkoutUsername]="'your-checkout-username'"
|
|
175
|
+
[productKey]="'your-product-key'"
|
|
176
|
+
/>
|
|
177
|
+
`,
|
|
178
|
+
})
|
|
179
|
+
export class PricingComponent {}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
#### Props
|
|
185
|
+
|
|
186
|
+
The inputs control how the pricing table is configured.
|
|
187
|
+
|
|
188
|
+
| Property | Type | Required | Default | Description |
|
|
189
|
+
| --------------------- | ------------------ | -------- | ------- | -------------------------------------------------------------------------------- |
|
|
190
|
+
| `checkoutUsername` | `string` | Yes | — | Unique username used for checkout. This can be found in **Settings → Checkout**. |
|
|
191
|
+
| `productKey` | `string` | Yes | — | Unique product identifier. This can be found on the product page. |
|
|
192
|
+
| `plansOnly` | `boolean` | No | `false` | Controls whether only subscription plans are rendered. |
|
|
193
|
+
| `singlePurchasesOnly` | `boolean` | No | `false` | Controls whether only single purchases are rendered. |
|
|
194
|
+
| `showTabHeader` | `boolean` | No | `true` | Controls whether the tab header for switching between offerings is rendered. |
|
|
195
|
+
| `theme` | `PricingTableTheme`| No | — | Optional theme override for this instance (merged with global theme from `MetrifoxService.initialize`). |
|
|
196
|
+
|
|
197
|
+
> **Note:** If both `plansOnly` and `singlePurchasesOnly` are `false` or undefined, both plans and single purchases are displayed.
|
|
198
|
+
|
|
199
|
+
## Styling
|
|
200
|
+
|
|
201
|
+
Import the SDK's global styles (see [Setup](#setup) step 3).
|
|
202
|
+
|
|
203
|
+
> This is required for proper styling of all components.
|
|
204
|
+
|
|
205
|
+
### Theme configuration (new structure)
|
|
206
|
+
|
|
207
|
+
Theming is driven by a single `theme` object passed to `MetrifoxService.initialize`. It has two top-level keys: `customerPortal` and `pricingTable`. Any value you omit falls back to the SDK default. You can also pass an optional `theme` input to `<metrifox-customer-portal>` or `<metrifox-pricing-table>` to override or extend the global theme for that instance.
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
// Passed to MetrifoxService.initialize({ theme })
|
|
211
|
+
theme?: {
|
|
212
|
+
customerPortal?: CustomerPortalTheme
|
|
213
|
+
pricingTable?: PricingTableTheme
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
> **Removed on v2.0.0+:** The previous root-level `pricingTableTheme` option is not supported. Use `theme.pricingTable` instead.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
### Customer Portal theme (`CustomerPortalTheme`)
|
|
222
|
+
|
|
223
|
+
All properties are optional. The shape is grouped by area of the UI:
|
|
224
|
+
|
|
225
|
+
| Group | Description |
|
|
226
|
+
| ----- | ----------- |
|
|
227
|
+
| `general` | Page-level: link color, background, border radius, font family, container padding |
|
|
228
|
+
| `tabs` | Tab bar (e.g. Wallet balance tabs): background, border, active/inactive states |
|
|
229
|
+
| `sections` | Section cards: background, padding, borders, content/summaryBalance sub-styles, header/label/value typography, usage bars, empty text |
|
|
230
|
+
| `buttons` | Primary and secondary buttons: background, border (color/width/radius), typography |
|
|
231
|
+
| `lineItems` | Subscription line items: parentRow/childRow background, border, typography (label/quantity) |
|
|
232
|
+
| `tables` | Tables (e.g. billing history): header/row colors, border, cell padding, expand icon, typography |
|
|
233
|
+
| `modals` | Modal overlay, background, border, close button; header/title/description typography; footer primary/secondary buttons |
|
|
234
|
+
| `plans` | Plan cards when shown in portal: currentPlanCard, planCards (border as `{ color, width, radius }`), planFeatures, planButton, planToggle, planTags |
|
|
235
|
+
|
|
236
|
+
**Example – minimal override:**
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
customerPortal: {
|
|
240
|
+
general: { linkColor: "#2563eb", backgroundColor: "#ffffff" },
|
|
241
|
+
tabs: {
|
|
242
|
+
tabBackground: "#ffffff",
|
|
243
|
+
tabBorderColor: "#e5e7eb",
|
|
244
|
+
activeTabBackground: "#2563eb",
|
|
245
|
+
activeTabTextColor: "#ffffff",
|
|
246
|
+
inactiveTabTextColor: "#6b7280",
|
|
247
|
+
},
|
|
248
|
+
sections: {
|
|
249
|
+
background: "#ffffff",
|
|
250
|
+
content: { background: "#f4f4f5", borderRadius: "8px" },
|
|
251
|
+
header: { fontSize: "16px", fontWeight: "600", color: "#52525b" },
|
|
252
|
+
label: { fontSize: "13px", color: "#71717a" },
|
|
253
|
+
value: { fontSize: "16px", color: "#52525b" },
|
|
254
|
+
},
|
|
255
|
+
buttons: {
|
|
256
|
+
primary: { backgroundColor: "#2563eb", border: { radius: "8px" }, typography: { color: "#ffffff" } },
|
|
257
|
+
secondary: { backgroundColor: "#e4e4e7", typography: { color: "#3f3f46" } },
|
|
258
|
+
},
|
|
259
|
+
plans: {
|
|
260
|
+
planCards: {
|
|
261
|
+
background: "#ffffff",
|
|
262
|
+
border: { color: "#e5e7eb", width: "1px", radius: "8px" },
|
|
263
|
+
header: { background: "#e5e7eb", textColor: "#111827" },
|
|
264
|
+
description: { textColor: "#6b7280", textButtonColor: "#2563eb" },
|
|
265
|
+
price: { amountColor: "#111827", primaryTextColor: "#6b7280", secondaryTextColor: "#9ca3af" },
|
|
266
|
+
},
|
|
267
|
+
planButton: { background: "#2563eb", textColor: "#ffffff" },
|
|
268
|
+
planToggle: { background: "#e5e7eb", activeBackground: "#1f2937", activeText: "#ffffff", inactiveText: "#6b7280" },
|
|
269
|
+
},
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
### Font customization
|
|
276
|
+
|
|
277
|
+
The SDK accepts **any font-family string** in your theme. The SDK applies it via CSS, but **your app must load the font** (Google Fonts, @font-face, etc.) before the SDK renders.
|
|
278
|
+
|
|
279
|
+
**How it works:**
|
|
280
|
+
|
|
281
|
+
1. **Load the font in your app** (HTML, CSS, or framework-specific):
|
|
282
|
+
|
|
283
|
+
```html
|
|
284
|
+
<!-- Option A: Google Fonts in your index.html <head> -->
|
|
285
|
+
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&display=swap" rel="stylesheet">
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
```css
|
|
289
|
+
/* Option B: @font-face in your global CSS */
|
|
290
|
+
@font-face {
|
|
291
|
+
font-family: 'MyCustomFont';
|
|
292
|
+
src: url('/fonts/custom.woff2') format('woff2');
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
2. **Pass the font-family to the SDK theme:**
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
MetrifoxService.initialize({
|
|
300
|
+
clientKey: "your-client-key",
|
|
301
|
+
theme: {
|
|
302
|
+
customerPortal: {
|
|
303
|
+
general: {
|
|
304
|
+
// Any font-family string works
|
|
305
|
+
fontFamily: '"Space Grotesk", "Inter", sans-serif'
|
|
306
|
+
// or: 'MyCustomFont, sans-serif'
|
|
307
|
+
// or: 'system-ui, -apple-system, sans-serif'
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
If no `fontFamily` is provided, the SDK inherits the font from the host page. This means the SDK works with whatever font your app already uses — no extra configuration needed.
|
|
315
|
+
|
|
316
|
+
> **Important:** When using Google Fonts or custom fonts, load them in your app **before** the SDK initializes to prevent flash of unstyled text (FOUT).
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
### Pricing Table theme (`PricingTableTheme`)
|
|
321
|
+
|
|
322
|
+
The Pricing Table theme follows the same nested structure as Customer Portal. All plan-related keys must be nested under `plans`.
|
|
323
|
+
|
|
324
|
+
| Key | Description |
|
|
325
|
+
| --- | ----------- |
|
|
326
|
+
| `plans` | Container for all plan-related styling |
|
|
327
|
+
| `plans.currentPlanCard` | Current-plan highlight: header (background, textColor), gradientColor, description, borderRadius |
|
|
328
|
+
| `plans.planCards` | Card style: background, border (`{ color, width, radius }`), header, description (textColor, textButtonColor), price (amountColor, primaryTextColor, secondaryTextColor, textButtonColor, background, borderColor) |
|
|
329
|
+
| `plans.planFeatures` | Feature list: textColor, iconColor |
|
|
330
|
+
| `plans.planButton` | CTA button: background, textColor; optional secondaryBackground, secondaryTextColor, textButtonColor |
|
|
331
|
+
| `plans.planToggle` | Monthly/Yearly toggle: background, activeBackground, activeText, inactiveText |
|
|
332
|
+
| `plans.planTags` | Tags (e.g. free trial): freeTrialBackground, freeTrialText |
|
|
333
|
+
| `tabs` | Tabs (e.g. Plans vs Single purchases): inactiveText, activeText, indicator, borderColor |
|
|
334
|
+
| `checkoutBar` | Bottom checkout bar: background, borderColor, textColor, buttonBackground, buttonTextColor |
|
|
335
|
+
|
|
336
|
+
**Example – minimal override:**
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
pricingTable: {
|
|
340
|
+
plans: {
|
|
341
|
+
planCards: {
|
|
342
|
+
background: "#ffffff",
|
|
343
|
+
border: { color: "#e5e7eb", width: "1px", radius: "8px" },
|
|
344
|
+
header: { background: "#e5e7eb", textColor: "#111827" },
|
|
345
|
+
description: { textColor: "#6b7280", textButtonColor: "#2563eb" },
|
|
346
|
+
price: { amountColor: "#111827", primaryTextColor: "#6b7280", secondaryTextColor: "#9ca3af" },
|
|
347
|
+
},
|
|
348
|
+
planButton: { background: "#2563eb", textColor: "#ffffff" },
|
|
349
|
+
planToggle: { background: "#e5e7eb", activeBackground: "#1f2937", activeText: "#ffffff", inactiveText: "#6b7280" },
|
|
350
|
+
},
|
|
351
|
+
tabs: { activeText: "#2563eb", indicator: "#2563eb", borderColor: "#9ca3af" },
|
|
352
|
+
checkoutBar: {
|
|
353
|
+
background: "#f9fafb",
|
|
354
|
+
borderColor: "#e5e7eb",
|
|
355
|
+
textColor: "#3f3f46",
|
|
356
|
+
buttonBackground: "#2563eb",
|
|
357
|
+
buttonTextColor: "#ffffff",
|
|
358
|
+
},
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
When the Pricing Table is embedded inside the Customer Portal, it automatically uses `theme.customerPortal.plans` for plan styling so both components stay consistent.
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
### Full example
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
import { MetrifoxService } from "@metrifox/angular-sdk";
|
|
370
|
+
|
|
371
|
+
MetrifoxService.initialize({
|
|
372
|
+
clientKey: "your-client-key",
|
|
373
|
+
theme: {
|
|
374
|
+
customerPortal: {
|
|
375
|
+
general: { linkColor: "#2563eb", backgroundColor: "#ffffff" },
|
|
376
|
+
tabs: {
|
|
377
|
+
tabBackground: "#ffffff",
|
|
378
|
+
activeTabBackground: "#2563eb",
|
|
379
|
+
activeTabTextColor: "#ffffff",
|
|
380
|
+
inactiveTabTextColor: "#6b7280",
|
|
381
|
+
},
|
|
382
|
+
sections: {
|
|
383
|
+
background: "#ffffff",
|
|
384
|
+
content: { background: "#f4f4f5", borderRadius: "8px" },
|
|
385
|
+
},
|
|
386
|
+
buttons: {
|
|
387
|
+
primary: { backgroundColor: "#2563eb", typography: { color: "#ffffff" } },
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
pricingTable: {
|
|
391
|
+
plans: {
|
|
392
|
+
planCards: { background: "#ffffff", border: { color: "#e5e7eb", radius: "8px" } },
|
|
393
|
+
planButton: { background: "#2563eb", textColor: "#ffffff" },
|
|
394
|
+
},
|
|
395
|
+
tabs: { activeText: "#2563eb", indicator: "#2563eb" },
|
|
396
|
+
checkoutBar: { buttonBackground: "#2563eb", buttonTextColor: "#ffffff" },
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
Per-component overrides (optional):
|
|
403
|
+
|
|
404
|
+
```html
|
|
405
|
+
<metrifox-customer-portal
|
|
406
|
+
[customerKey]="'cust_123'"
|
|
407
|
+
[theme]="{ general: { linkColor: '#1d4ed8' } }"
|
|
408
|
+
/>
|
|
409
|
+
|
|
410
|
+
<metrifox-pricing-table
|
|
411
|
+
[checkoutUsername]="'checkout_user'"
|
|
412
|
+
[productKey]="'prod_key'"
|
|
413
|
+
[theme]="{ plans: { planCards: { background: '#f8fafc' } } }"
|
|
414
|
+
/>
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
### Migration from React SDK
|
|
420
|
+
|
|
421
|
+
| React | Angular |
|
|
422
|
+
| ----------------------- | ------------------------------ |
|
|
423
|
+
| `metrifoxInit()` | `MetrifoxService.initialize()` |
|
|
424
|
+
| `<CustomerPortal />` | `<metrifox-customer-portal>` |
|
|
425
|
+
| `<PricingTable />` | `<metrifox-pricing-table>` |
|
|
426
|
+
| `customerKey` prop | `[customerKey]` input |
|
|
427
|
+
| `onPlanSelect` callback | `(planSelected)` output |
|
|
428
|
+
| `theme` prop | `[theme]` input |
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## Local Development
|
|
433
|
+
|
|
434
|
+
### Using [yalc](https://github.com/wclr/yalc)
|
|
435
|
+
|
|
436
|
+
For local SDK testing:
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
# In SDK project
|
|
440
|
+
pnpm build
|
|
441
|
+
npx yalc publish
|
|
442
|
+
|
|
443
|
+
# In consuming app
|
|
444
|
+
npx yalc add @metrifox/angular-sdk
|
|
445
|
+
npm install
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
#### Auto-update during development
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
# In SDK project
|
|
452
|
+
pnpm build # rebuild
|
|
453
|
+
npx yalc publish # re-publish to yalc
|
|
454
|
+
|
|
455
|
+
# In consuming project
|
|
456
|
+
npx yalc update @metrifox/angular-sdk
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
#### Clean up
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
npx yalc remove @metrifox/angular-sdk
|
|
463
|
+
npm install
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
## Support
|
|
469
|
+
|
|
470
|
+
📘 **Full Documentation:**
|
|
471
|
+
For detailed guides, API references, and live examples, visit [docs.metrifox.com](https://docs.metrifox.com).
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## 📄 License
|
|
476
|
+
|
|
477
|
+
MIT © [MetriFox](https://metrifox.com)
|