@metrifox/react-sdk 0.0.9 → 0.0.11
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 +148 -4
- package/dist/index.cjs +47 -24
- package/dist/index.d.ts +95 -1
- package/dist/index.js +46 -23
- package/dist/styles.css +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -39,7 +39,9 @@ metrifoxInit({
|
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
42
|
-
##
|
|
42
|
+
## Widgets
|
|
43
|
+
|
|
44
|
+
## `CustomerPortal`
|
|
43
45
|
|
|
44
46
|
Displays a customizable customer dashboard with plans, subscriptions, billing, credits, and more.
|
|
45
47
|
|
|
@@ -64,7 +66,7 @@ export default function MyPortalPage() {
|
|
|
64
66
|
|
|
65
67
|
---
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
#### Section Configuration
|
|
68
70
|
|
|
69
71
|
The `sectionsConfig` prop controls what appears in the portal.
|
|
70
72
|
|
|
@@ -75,7 +77,7 @@ The `sectionsConfig` prop controls what appears in the portal.
|
|
|
75
77
|
| `component` | `React.ComponentType` | Replace the default section with your own component |
|
|
76
78
|
| `props` | `Record<string, unknown>` | Extra props passed to the custom or default section |
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
#### Built-in Section Keys
|
|
79
81
|
|
|
80
82
|
| Key | Description |
|
|
81
83
|
| ------------------ | ----------------------------- |
|
|
@@ -87,7 +89,7 @@ The `sectionsConfig` prop controls what appears in the portal.
|
|
|
87
89
|
| `billingHistory` | List of past transactions |
|
|
88
90
|
| `plan` | Current plan details |
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
#### Section Anchors
|
|
91
93
|
|
|
92
94
|
Each portal section now renders inside a `<section id="...">` wrapper so you can link directly to segments of a customer portal view. The default anchor IDs are:
|
|
93
95
|
|
|
@@ -105,6 +107,39 @@ Use these anchors when embedding the SDK or sharing deep links (e.g., `https://a
|
|
|
105
107
|
|
|
106
108
|
---
|
|
107
109
|
|
|
110
|
+
## Pricing Table
|
|
111
|
+
|
|
112
|
+
Displays subscription plans and one-time purchases in a configurable pricing table component.
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
import { PricingTable } from "@metrifox/react-sdk"
|
|
116
|
+
|
|
117
|
+
export default function PricingPage() {
|
|
118
|
+
return(
|
|
119
|
+
<PricingTable
|
|
120
|
+
checkoutUsername="your-checkout-username"
|
|
121
|
+
productKey="your-product-key"
|
|
122
|
+
/>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
#### Props
|
|
130
|
+
|
|
131
|
+
The props control how the pricing table is configured.
|
|
132
|
+
|
|
133
|
+
| Property | Type | Required | Default | Description |
|
|
134
|
+
| --------------------- | --------- | -------- | ------- | -------------------------------------------------------------------------------- |
|
|
135
|
+
| `checkoutUsername` | `string` | Yes | — | Unique username used for checkout. This can be found in **Settings → Checkout**. |
|
|
136
|
+
| `productKey` | `string` | Yes | — | Unique product identifier. This can be found on the product page. |
|
|
137
|
+
| `plansOnly` | `boolean` | No | `false` | Controls whether only subscription plans are rendered. |
|
|
138
|
+
| `singlePurchasesOnly` | `boolean` | No | `false` | Controls whether only single purchases are rendered. |
|
|
139
|
+
| `showTabHeader` | `boolean` | No | `true` | Controls whether the tab header for switching between offerings is rendered. |
|
|
140
|
+
|
|
141
|
+
> **Note:** If both `plansOnly` and `singlePurchasesOnly` are `false` or undefined, both plans and single purchases are displayed.
|
|
142
|
+
|
|
108
143
|
## Styling
|
|
109
144
|
|
|
110
145
|
Import the SDK’s global styles into your app entry (e.g., `src/index.tsx` or `_app.tsx`):
|
|
@@ -115,6 +150,115 @@ import "@metrifox/react-sdk/dist/styles.css"
|
|
|
115
150
|
|
|
116
151
|
> This is required for proper styling of all widgets.
|
|
117
152
|
|
|
153
|
+
#### Pricing Table
|
|
154
|
+
The SDK accepts an optional `pricingTableTheme` object during initialization. This theme is applied to Pricing Table component and UI elements within it to match your brand styles.
|
|
155
|
+
|
|
156
|
+
Any values not provided will fall back to the default theme.
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
// Pricing table theme configuration
|
|
160
|
+
pricingTableTheme?: {
|
|
161
|
+
card?: {
|
|
162
|
+
background?: string
|
|
163
|
+
borderColor?: string
|
|
164
|
+
descriptionColor?: string
|
|
165
|
+
|
|
166
|
+
header?: {
|
|
167
|
+
background?: string
|
|
168
|
+
textColor?: string
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
description?: {
|
|
172
|
+
textColor?: string
|
|
173
|
+
textButtonColor?: string
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
price?: {
|
|
177
|
+
amountColor?: string
|
|
178
|
+
primaryTextColor?: string
|
|
179
|
+
secondaryTextColor?: string
|
|
180
|
+
textButtonColor?: string
|
|
181
|
+
background?: string
|
|
182
|
+
borderColor?: string
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
button?: {
|
|
187
|
+
background?: string
|
|
188
|
+
textColor?: string
|
|
189
|
+
secondaryBackground?: string
|
|
190
|
+
secondaryTextColor?: string
|
|
191
|
+
textButtonColor?: string
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
featureList?: {
|
|
195
|
+
textColor?: string
|
|
196
|
+
iconColor?: string
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
tabs?: {
|
|
200
|
+
inactiveText?: string
|
|
201
|
+
activeText?: string
|
|
202
|
+
indicator?: string
|
|
203
|
+
borderColor?: string
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
intervalToggle?: {
|
|
207
|
+
background?: string
|
|
208
|
+
activeBackground?: string
|
|
209
|
+
activeText?: string
|
|
210
|
+
inactiveText?: string
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
currentSubscriptionCard?: {
|
|
214
|
+
header?: {
|
|
215
|
+
background?: string
|
|
216
|
+
textColor?: string
|
|
217
|
+
}
|
|
218
|
+
gradientColor?: string
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
freeTrialTag?: {
|
|
222
|
+
background?: string
|
|
223
|
+
textColor?: string
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
checkoutBar?: {
|
|
227
|
+
background?: string
|
|
228
|
+
borderColor?: string
|
|
229
|
+
textColor?: string
|
|
230
|
+
buttonBackground?: string
|
|
231
|
+
buttonTextColor?: string
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
###### Example usage
|
|
236
|
+
```tsx
|
|
237
|
+
import { metrifoxInit } from "@metrifox/react-sdk"
|
|
238
|
+
|
|
239
|
+
const pricingTableTheme = {
|
|
240
|
+
pricingTable: {
|
|
241
|
+
card: {
|
|
242
|
+
background: "#ffffff",
|
|
243
|
+
price: {
|
|
244
|
+
amountColor: "#111827",
|
|
245
|
+
textButtonColor: "#2563eb",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
button: {
|
|
249
|
+
background: "#2563eb",
|
|
250
|
+
},
|
|
251
|
+
tabs: {
|
|
252
|
+
activeText: "#2563eb",
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
metrifoxInit({
|
|
258
|
+
clientKey: "your-client-key",
|
|
259
|
+
pricingTableTheme,
|
|
260
|
+
})
|
|
261
|
+
```
|
|
118
262
|
---
|
|
119
263
|
|
|
120
264
|
## Local Development
|