@meterbox/react 0.1.9 → 0.1.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 +18 -6
- package/package.json +1 -1
- package/src/PlanComparison.js +21 -12
- package/src/PricingTable.js +150 -70
- package/src/SubscriptionPreview.js +3 -1
- package/src/UsageProgress.js +6 -3
- package/src/i18n.js +9 -0
- package/src/theme.js +1 -0
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
} from "@meterbox/react";
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
### `<PricingTable plans currentPlanId? currency? onSelect? customerEmail? branding? />` or `<PricingTable publishableKey … />`
|
|
48
|
+
### `<PricingTable plans currentPlanId? currency? onSelect? customerEmail? branding? selectedPlanId? onPlanClick? renderFooter? />` or `<PricingTable publishableKey … />`
|
|
49
49
|
|
|
50
50
|
On a public page with no backend of its own, pass a
|
|
51
51
|
publishable key (`mb_pub_...`, from Settings > API keys) instead of `plans`.
|
|
@@ -75,9 +75,21 @@ pay for usage: the amounts included each month, what happens past them
|
|
|
75
75
|
and output rates per 1M tokens, tier ladders included.
|
|
76
76
|
|
|
77
77
|
A plan lists its included credits first ("1,500 Bits a month", in the tenant's credit unit), then
|
|
78
|
-
its `
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
its `bullet_details`, which `GET /v1/plans`, the pricing snapshot and the customer portal's plans
|
|
79
|
+
all carry: each feature by its name on the plan, else by its label with its description under it,
|
|
80
|
+
by its description when it has no label, and by its id only when it has neither. Without them, it
|
|
81
|
+
lists its `bullets`, else its `features` (`[{ id, name }]`) by name, else by id. A
|
|
82
|
+
pricing-page plan with a public promotion shows its promotional price, the regular one struck
|
|
83
|
+
through, and the code to use ("Save 50% with code LAUNCH50 for 3 months").
|
|
84
|
+
|
|
85
|
+
A plan whose `stripe_price_monthly_usd` is `null` has no fixed price and shows "Custom". A plan's
|
|
86
|
+
own `cta.label` names its button, and its `cta.url` may also be a path on your site
|
|
87
|
+
(`/signup?plan=pro`). A plan's `badges` (an array of text) show next to its `badge`.
|
|
88
|
+
|
|
89
|
+
For a catalog you manage rather than sell from, such as an admin page: `selectedPlanId` and
|
|
90
|
+
`onPlanClick(plan)` make each card selectable, and `renderFooter(plan)` puts your own content
|
|
91
|
+
(counts, edit buttons) where each card's button would be. A click inside it doesn't select the
|
|
92
|
+
card.
|
|
81
93
|
|
|
82
94
|
### Base URL: `<MeterboxProvider baseUrl>`
|
|
83
95
|
|
|
@@ -89,8 +101,8 @@ resolved URL for your own calls.
|
|
|
89
101
|
### Branding: `<BrandingProvider branding>`
|
|
90
102
|
|
|
91
103
|
Every component styles itself from `--mbx-*` CSS variables (`--mbx-accent`,
|
|
92
|
-
`--mbx-text`, `--mbx-card`, `--mbx-font`, `--mbx-radius` and the
|
|
93
|
-
variables), with Meterbox's defaults as fallbacks. Wrap them in
|
|
104
|
+
`--mbx-text`, `--mbx-card`, `--mbx-border`, `--mbx-font`, `--mbx-radius` and the
|
|
105
|
+
button variables), with Meterbox's defaults as fallbacks. Wrap them in
|
|
94
106
|
`<BrandingProvider branding={branding}>` to apply your branding from
|
|
95
107
|
Settings → Branding (`GET /v1/settings/branding`): logo, colors, font and
|
|
96
108
|
button style. `<PricingTable publishableKey>` applies it from the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meterbox/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Embeddable React components for Meterbox: pricing tables, subscription preview, credit balance and usage charts. Presentational by default, with data fetched by your backend via @meterbox/node.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://meterbox.ai",
|
package/src/PlanComparison.js
CHANGED
|
@@ -45,6 +45,18 @@ const styles = {
|
|
|
45
45
|
},
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
// A plan's features by id, each as it reads: its name on the plan, else its
|
|
49
|
+
// id in words (`{ id, name }`; ids alone in older records).
|
|
50
|
+
function featuresOf(plan) {
|
|
51
|
+
const list = Array.isArray(plan.features) ? plan.features : [];
|
|
52
|
+
return new Map(
|
|
53
|
+
list.map((f) => {
|
|
54
|
+
const id = typeof f === "string" ? f : f.id;
|
|
55
|
+
return [id, (typeof f === "string" ? null : f.name) || id.replace(/_/g, " ")];
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
48
60
|
function PlanComparison({ from, to, onSwitch }) {
|
|
49
61
|
if (!from || !to) {
|
|
50
62
|
return React.createElement(
|
|
@@ -53,10 +65,11 @@ function PlanComparison({ from, to, onSwitch }) {
|
|
|
53
65
|
"Pick a plan to compare.",
|
|
54
66
|
);
|
|
55
67
|
}
|
|
56
|
-
const fromFeatures =
|
|
57
|
-
const toFeatures =
|
|
58
|
-
const
|
|
59
|
-
const
|
|
68
|
+
const fromFeatures = featuresOf(from);
|
|
69
|
+
const toFeatures = featuresOf(to);
|
|
70
|
+
const text = (id) => toFeatures.get(id) || fromFeatures.get(id);
|
|
71
|
+
const added = [...toFeatures.keys()].filter((f) => !fromFeatures.has(f));
|
|
72
|
+
const removed = [...fromFeatures.keys()].filter((f) => !toFeatures.has(f));
|
|
60
73
|
|
|
61
74
|
function FeatureList(features, extras) {
|
|
62
75
|
return React.createElement(
|
|
@@ -66,17 +79,13 @@ function PlanComparison({ from, to, onSwitch }) {
|
|
|
66
79
|
React.createElement(
|
|
67
80
|
"li",
|
|
68
81
|
{ key: f, style: extras?.removed?.has(f) ? styles.removed : null },
|
|
69
|
-
`• ${f
|
|
82
|
+
`• ${text(f)}`,
|
|
70
83
|
),
|
|
71
84
|
),
|
|
72
85
|
added.length > 0 &&
|
|
73
86
|
extras?.showAdded &&
|
|
74
87
|
added.map((f) =>
|
|
75
|
-
React.createElement(
|
|
76
|
-
"li",
|
|
77
|
-
{ key: `added-${f}`, style: styles.added },
|
|
78
|
-
`+ ${f.replace(/_/g, " ")}`,
|
|
79
|
-
),
|
|
88
|
+
React.createElement("li", { key: `added-${f}`, style: styles.added }, `+ ${text(f)}`),
|
|
80
89
|
),
|
|
81
90
|
);
|
|
82
91
|
}
|
|
@@ -89,7 +98,7 @@ function PlanComparison({ from, to, onSwitch }) {
|
|
|
89
98
|
{ style: styles.col },
|
|
90
99
|
React.createElement("h4", { style: styles.heading }, "Current"),
|
|
91
100
|
React.createElement("h3", { style: styles.planName }, from.name || from.id),
|
|
92
|
-
FeatureList(Array.from(fromFeatures), { removed: new Set(removed) }),
|
|
101
|
+
FeatureList(Array.from(fromFeatures.keys()), { removed: new Set(removed) }),
|
|
93
102
|
),
|
|
94
103
|
React.createElement(
|
|
95
104
|
"div",
|
|
@@ -97,7 +106,7 @@ function PlanComparison({ from, to, onSwitch }) {
|
|
|
97
106
|
React.createElement("h4", { style: styles.heading }, "Switching to"),
|
|
98
107
|
React.createElement("h3", { style: styles.planName }, to.name || to.id),
|
|
99
108
|
FeatureList(
|
|
100
|
-
Array.from(toFeatures).filter((f) => !added.includes(f)),
|
|
109
|
+
Array.from(toFeatures.keys()).filter((f) => !added.includes(f)),
|
|
101
110
|
{ showAdded: true },
|
|
102
111
|
),
|
|
103
112
|
onSwitch &&
|
package/src/PricingTable.js
CHANGED
|
@@ -35,12 +35,22 @@
|
|
|
35
35
|
* each plan's button is its call-to-action link (`customerEmail` fills
|
|
36
36
|
* {CUSTOMER_EMAIL} in it).
|
|
37
37
|
*
|
|
38
|
-
* A plan's list is its `
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
38
|
+
* A plan's list is its `bullet_details` (the API's plans, the snapshot and the
|
|
39
|
+
* customer portal's plan list all carry it: each feature by its name on the
|
|
40
|
+
* plan, else its label with its description under it, by its description
|
|
41
|
+
* when it has no label, by its id when it has neither), else its `bullets`,
|
|
42
|
+
* else its features (`{ id, name }`) by name, else by id; its included
|
|
43
|
+
* credits come first ("1,500 Bits a month"). A snapshot plan's
|
|
44
|
+
* `promotion` shows its monthly price with the regular one struck through,
|
|
45
|
+
* and how to get it ("Save 50% with code LAUNCH50 for 3 months").
|
|
46
|
+
*
|
|
47
|
+
* A plan whose `stripe_price_monthly_usd` is null has no fixed price and
|
|
48
|
+
* shows "Custom". A plan's `cta.label` names its button, and its `cta.url`
|
|
49
|
+
* may also be a path on your own site ("/signup?plan=pro"). A plan's
|
|
50
|
+
* `badges` add to its `badge`. For a catalog you manage rather than sell
|
|
51
|
+
* from: `selectedPlanId` + `onPlanClick(plan)` make each card selectable,
|
|
52
|
+
* and `renderFooter(plan)` replaces each card's button with your own
|
|
53
|
+
* content (a click inside it doesn't select the card).
|
|
44
54
|
*
|
|
45
55
|
* Pure presentational + inline styles — no CSS pipeline required from the
|
|
46
56
|
* tenant.
|
|
@@ -71,8 +81,8 @@ const styles = {
|
|
|
71
81
|
padding: 4,
|
|
72
82
|
width: "fit-content",
|
|
73
83
|
margin: "0 auto",
|
|
74
|
-
background:
|
|
75
|
-
border:
|
|
84
|
+
background: theme.accentTint(6),
|
|
85
|
+
border: `1px solid ${theme.border}`,
|
|
76
86
|
borderRadius: 999,
|
|
77
87
|
},
|
|
78
88
|
toggleBtn: {
|
|
@@ -80,7 +90,7 @@ const styles = {
|
|
|
80
90
|
borderRadius: 999,
|
|
81
91
|
border: "none",
|
|
82
92
|
background: "transparent",
|
|
83
|
-
color:
|
|
93
|
+
color: theme.text,
|
|
84
94
|
fontSize: 13,
|
|
85
95
|
fontWeight: 600,
|
|
86
96
|
fontFamily: theme.font,
|
|
@@ -95,7 +105,7 @@ const styles = {
|
|
|
95
105
|
color: theme.text,
|
|
96
106
|
},
|
|
97
107
|
card: {
|
|
98
|
-
border:
|
|
108
|
+
border: `1px solid ${theme.border}`,
|
|
99
109
|
borderRadius: 12,
|
|
100
110
|
padding: 20,
|
|
101
111
|
background: theme.card,
|
|
@@ -117,7 +127,7 @@ const styles = {
|
|
|
117
127
|
cursor: "pointer",
|
|
118
128
|
},
|
|
119
129
|
ctaCurrent: {
|
|
120
|
-
background:
|
|
130
|
+
background: theme.accentTint(12),
|
|
121
131
|
color: theme.text,
|
|
122
132
|
border: "1px solid transparent",
|
|
123
133
|
cursor: "default",
|
|
@@ -129,9 +139,10 @@ const styles = {
|
|
|
129
139
|
display: "grid",
|
|
130
140
|
gap: 4,
|
|
131
141
|
fontSize: 12,
|
|
132
|
-
borderTop:
|
|
142
|
+
borderTop: `1px solid ${theme.border}`,
|
|
133
143
|
paddingTop: 10,
|
|
134
144
|
},
|
|
145
|
+
bulletDescription: { fontSize: 12, opacity: 0.65, marginLeft: 12 },
|
|
135
146
|
badge: {
|
|
136
147
|
fontSize: 11,
|
|
137
148
|
fontWeight: 600,
|
|
@@ -139,15 +150,20 @@ const styles = {
|
|
|
139
150
|
color: "#fff",
|
|
140
151
|
padding: "2px 8px",
|
|
141
152
|
borderRadius: 999,
|
|
142
|
-
alignSelf: "flex-start",
|
|
143
153
|
},
|
|
154
|
+
badges: { display: "flex", flexWrap: "wrap", gap: 6 },
|
|
144
155
|
};
|
|
145
156
|
|
|
146
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* What a plan lists, as `{ text, description }`: its `bullet_details`, else
|
|
159
|
+
* its bullets, else its features by name, else by id.
|
|
160
|
+
*/
|
|
147
161
|
function planBullets(plan) {
|
|
148
|
-
if (Array.isArray(plan.
|
|
149
|
-
|
|
150
|
-
|
|
162
|
+
if (Array.isArray(plan.bullet_details)) return plan.bullet_details;
|
|
163
|
+
const texts = Array.isArray(plan.bullets)
|
|
164
|
+
? plan.bullets
|
|
165
|
+
: (plan.features || []).map((f) => (typeof f === "string" ? f : f.name || f.id));
|
|
166
|
+
return texts.map((text) => ({ text, description: null }));
|
|
151
167
|
}
|
|
152
168
|
|
|
153
169
|
/** "1,500 Bits a month", or "$15 of credit a month" without a credit unit. */
|
|
@@ -243,8 +259,9 @@ function PlanUsage({ usage }) {
|
|
|
243
259
|
);
|
|
244
260
|
}
|
|
245
261
|
|
|
246
|
-
// A plan's call-to-action link
|
|
247
|
-
//
|
|
262
|
+
// A plan's call-to-action link, {CUSTOMER_EMAIL} filled in; null unless it's
|
|
263
|
+
// an http(s), mailto: or tel: link, or a path on this site (not one a
|
|
264
|
+
// browser reads as another host: "//", "/\\").
|
|
248
265
|
function ctaLink(plan, customerEmail) {
|
|
249
266
|
if (!plan.cta?.url) return null;
|
|
250
267
|
const email = encodeURIComponent(customerEmail || "");
|
|
@@ -253,7 +270,7 @@ function ctaLink(plan, customerEmail) {
|
|
|
253
270
|
.join(email)
|
|
254
271
|
.split("%7BCUSTOMER_EMAIL%7D")
|
|
255
272
|
.join(email);
|
|
256
|
-
return /^(https?:|mailto:|tel
|
|
273
|
+
return /^(https?:|mailto:|tel:|\/(?![/\\]))/i.test(url) ? { url, label: plan.cta.label } : null;
|
|
257
274
|
}
|
|
258
275
|
|
|
259
276
|
/** A plan from the public snapshot, in the shape the table renders. */
|
|
@@ -264,9 +281,10 @@ function fromSnapshot(p) {
|
|
|
264
281
|
description: p.description || null,
|
|
265
282
|
features: p.features || [],
|
|
266
283
|
bullets: p.bullets || null,
|
|
284
|
+
bullet_details: p.bullet_details || null,
|
|
267
285
|
included_credits: p.included_credits || null,
|
|
268
286
|
promotion: p.promotion || null,
|
|
269
|
-
stripe_price_monthly_usd: p.price ? p.price.monthly_usd :
|
|
287
|
+
stripe_price_monthly_usd: p.price ? p.price.monthly_usd : null,
|
|
270
288
|
annual_free_months: p.annual_free_months == null ? null : p.annual_free_months,
|
|
271
289
|
localized_prices: p.localized_prices || [],
|
|
272
290
|
usage: p.usage || null,
|
|
@@ -292,6 +310,9 @@ function PricingTable({
|
|
|
292
310
|
currentPlanId,
|
|
293
311
|
currency = "USD",
|
|
294
312
|
onSelect,
|
|
313
|
+
selectedPlanId,
|
|
314
|
+
onPlanClick,
|
|
315
|
+
renderFooter,
|
|
295
316
|
customerEmail,
|
|
296
317
|
branding,
|
|
297
318
|
baseUrl: baseUrlProp,
|
|
@@ -363,33 +384,121 @@ function PricingTable({
|
|
|
363
384
|
{ style: styles.grid },
|
|
364
385
|
list.map((plan) => {
|
|
365
386
|
const isCurrent = plan.id === currentPlanId;
|
|
387
|
+
const isSelected = plan.id === selectedPlanId;
|
|
366
388
|
const localized = (plan.localized_prices || []).find(
|
|
367
389
|
(p) => (p.currency || "").toUpperCase() === currency.toUpperCase(),
|
|
368
390
|
);
|
|
369
391
|
const monthlyAmount = localized ? localized.monthly_amount : plan.stripe_price_monthly_usd;
|
|
370
392
|
const displayCurrency = localized ? localized.currency : "USD";
|
|
393
|
+
// No fixed price: "Custom", with no period, annual total or promotion.
|
|
394
|
+
const custom = monthlyAmount == null;
|
|
371
395
|
// Annual only applies when THIS plan offers it — a plan without
|
|
372
396
|
// annual_free_months always shows its monthly price, even while the
|
|
373
397
|
// toggle above is set to "Annual" for its siblings.
|
|
374
398
|
const annual = billingInterval === "annual" ? annualPriceUsd(plan) : null;
|
|
375
399
|
const link = !onSelect && !isCurrent ? ctaLink(plan, customerEmail) : null;
|
|
376
400
|
// A promotion is on the monthly USD price.
|
|
377
|
-
const promo =
|
|
401
|
+
const promo =
|
|
402
|
+
!custom && annual == null && displayCurrency === "USD" ? plan.promotion : null;
|
|
378
403
|
const bullets = [
|
|
379
|
-
...(plan.included_credits
|
|
404
|
+
...(plan.included_credits
|
|
405
|
+
? [{ text: creditsText(i18n, plan.included_credits), description: null }]
|
|
406
|
+
: []),
|
|
380
407
|
...planBullets(plan),
|
|
381
408
|
];
|
|
409
|
+
const badges = [isCurrent ? t("pricing.current") : plan.badge, ...(plan.badges || [])];
|
|
410
|
+
const select = onPlanClick ? () => onPlanClick(plan) : null;
|
|
411
|
+
const outlined = isCurrent || isSelected || plan.highlight;
|
|
412
|
+
let price;
|
|
413
|
+
if (custom) {
|
|
414
|
+
price = React.createElement("span", { style: styles.price }, t("pricing.custom"));
|
|
415
|
+
} else {
|
|
416
|
+
price = [
|
|
417
|
+
promo &&
|
|
418
|
+
React.createElement(
|
|
419
|
+
"s",
|
|
420
|
+
{ key: "was", style: styles.wasPrice },
|
|
421
|
+
money(monthlyAmount),
|
|
422
|
+
),
|
|
423
|
+
React.createElement(
|
|
424
|
+
"span",
|
|
425
|
+
{ key: "price", style: styles.price },
|
|
426
|
+
money(
|
|
427
|
+
promo ? promo.monthly_usd : annual != null ? annual : monthlyAmount,
|
|
428
|
+
displayCurrency,
|
|
429
|
+
),
|
|
430
|
+
),
|
|
431
|
+
React.createElement(
|
|
432
|
+
"span",
|
|
433
|
+
{ key: "period", style: styles.perMonth },
|
|
434
|
+
annual != null ? t("pricing.billedAnnually") : t("pricing.perMonth"),
|
|
435
|
+
),
|
|
436
|
+
];
|
|
437
|
+
}
|
|
438
|
+
let action;
|
|
439
|
+
if (renderFooter) {
|
|
440
|
+
// Its own controls: a click inside it doesn't select the card.
|
|
441
|
+
action = React.createElement(
|
|
442
|
+
"div",
|
|
443
|
+
{ style: { marginTop: "auto" }, onClick: select ? (e) => e.stopPropagation() : null },
|
|
444
|
+
renderFooter(plan),
|
|
445
|
+
);
|
|
446
|
+
} else if (link) {
|
|
447
|
+
action = React.createElement(
|
|
448
|
+
"a",
|
|
449
|
+
{
|
|
450
|
+
href: link.url,
|
|
451
|
+
style: { ...styles.cta, textAlign: "center", textDecoration: "none" },
|
|
452
|
+
},
|
|
453
|
+
link.label,
|
|
454
|
+
);
|
|
455
|
+
} else {
|
|
456
|
+
action = React.createElement(
|
|
457
|
+
"button",
|
|
458
|
+
{
|
|
459
|
+
type: "button",
|
|
460
|
+
style: isCurrent ? { ...styles.cta, ...styles.ctaCurrent } : styles.cta,
|
|
461
|
+
disabled: isCurrent,
|
|
462
|
+
onClick: () => (onSelect ? onSelect(plan, billingInterval) : undefined),
|
|
463
|
+
"aria-label": t(isCurrent ? "pricing.currentlyOn" : "pricing.choose", {
|
|
464
|
+
plan: plan.name || plan.id,
|
|
465
|
+
}),
|
|
466
|
+
},
|
|
467
|
+
isCurrent ? t("pricing.currentPlan") : plan.cta?.label || t("pricing.choosePlan"),
|
|
468
|
+
);
|
|
469
|
+
}
|
|
382
470
|
return React.createElement(
|
|
383
471
|
"div",
|
|
384
472
|
{
|
|
385
473
|
key: plan.id,
|
|
386
|
-
style:
|
|
387
|
-
|
|
474
|
+
style: {
|
|
475
|
+
...styles.card,
|
|
476
|
+
...(outlined ? styles.cardCurrent : null),
|
|
477
|
+
...(select ? { cursor: "pointer" } : null),
|
|
478
|
+
},
|
|
479
|
+
...(select && {
|
|
480
|
+
role: "button",
|
|
481
|
+
tabIndex: 0,
|
|
482
|
+
"aria-pressed": isSelected,
|
|
483
|
+
onClick: select,
|
|
484
|
+
onKeyDown: (e) => {
|
|
485
|
+
if (e.target === e.currentTarget && (e.key === "Enter" || e.key === " ")) {
|
|
486
|
+
e.preventDefault();
|
|
487
|
+
select();
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
}),
|
|
388
491
|
},
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
492
|
+
badges.some(Boolean) &&
|
|
493
|
+
React.createElement(
|
|
494
|
+
"div",
|
|
495
|
+
{ style: styles.badges },
|
|
496
|
+
badges
|
|
497
|
+
.filter(Boolean)
|
|
498
|
+
.map((b, i) =>
|
|
499
|
+
React.createElement("span", { key: `${i}:${b}`, style: styles.badge }, b),
|
|
500
|
+
),
|
|
501
|
+
),
|
|
393
502
|
React.createElement("h3", { style: styles.name }, plan.name || plan.id),
|
|
394
503
|
plan.description &&
|
|
395
504
|
React.createElement(
|
|
@@ -397,24 +506,7 @@ function PricingTable({
|
|
|
397
506
|
{ style: { fontSize: 13, opacity: 0.75, margin: 0 } },
|
|
398
507
|
plan.description,
|
|
399
508
|
),
|
|
400
|
-
React.createElement(
|
|
401
|
-
"div",
|
|
402
|
-
null,
|
|
403
|
-
promo && React.createElement("s", { style: styles.wasPrice }, money(monthlyAmount)),
|
|
404
|
-
React.createElement(
|
|
405
|
-
"span",
|
|
406
|
-
{ style: styles.price },
|
|
407
|
-
money(
|
|
408
|
-
promo ? promo.monthly_usd : annual != null ? annual : monthlyAmount,
|
|
409
|
-
displayCurrency,
|
|
410
|
-
),
|
|
411
|
-
),
|
|
412
|
-
React.createElement(
|
|
413
|
-
"span",
|
|
414
|
-
{ style: styles.perMonth },
|
|
415
|
-
annual != null ? t("pricing.billedAnnually") : t("pricing.perMonth"),
|
|
416
|
-
),
|
|
417
|
-
),
|
|
509
|
+
React.createElement("div", null, price),
|
|
418
510
|
promo && React.createElement("div", { style: styles.promo }, promoText(i18n, promo)),
|
|
419
511
|
plan.trial_days > 0 &&
|
|
420
512
|
React.createElement(
|
|
@@ -426,31 +518,19 @@ function PricingTable({
|
|
|
426
518
|
React.createElement(
|
|
427
519
|
"ul",
|
|
428
520
|
{ style: styles.features },
|
|
429
|
-
bullets.map((b, i) =>
|
|
521
|
+
bullets.map((b, i) =>
|
|
522
|
+
React.createElement(
|
|
523
|
+
"li",
|
|
524
|
+
{ key: `${i}:${b.text}` },
|
|
525
|
+
React.createElement("span", { "aria-hidden": true }, "• "),
|
|
526
|
+
React.createElement("span", null, b.text),
|
|
527
|
+
b.description &&
|
|
528
|
+
React.createElement("div", { style: styles.bulletDescription }, b.description),
|
|
529
|
+
),
|
|
530
|
+
),
|
|
430
531
|
),
|
|
431
532
|
plan.usage && React.createElement(PlanUsage, { usage: plan.usage }),
|
|
432
|
-
|
|
433
|
-
? React.createElement(
|
|
434
|
-
"a",
|
|
435
|
-
{
|
|
436
|
-
href: link.url,
|
|
437
|
-
style: { ...styles.cta, textAlign: "center", textDecoration: "none" },
|
|
438
|
-
},
|
|
439
|
-
link.label,
|
|
440
|
-
)
|
|
441
|
-
: React.createElement(
|
|
442
|
-
"button",
|
|
443
|
-
{
|
|
444
|
-
type: "button",
|
|
445
|
-
style: isCurrent ? { ...styles.cta, ...styles.ctaCurrent } : styles.cta,
|
|
446
|
-
disabled: isCurrent,
|
|
447
|
-
onClick: () => (onSelect ? onSelect(plan, billingInterval) : undefined),
|
|
448
|
-
"aria-label": t(isCurrent ? "pricing.currentlyOn" : "pricing.choose", {
|
|
449
|
-
plan: plan.name || plan.id,
|
|
450
|
-
}),
|
|
451
|
-
},
|
|
452
|
-
isCurrent ? t("pricing.currentPlan") : t("pricing.choosePlan"),
|
|
453
|
-
),
|
|
533
|
+
action,
|
|
454
534
|
);
|
|
455
535
|
}),
|
|
456
536
|
),
|
|
@@ -148,7 +148,9 @@ function SubscriptionPreview({
|
|
|
148
148
|
// admin endpoint). Field names match the backend exactly.
|
|
149
149
|
const current = data.current || null;
|
|
150
150
|
const target = data.target || null;
|
|
151
|
-
|
|
151
|
+
// Null new_mrr_usd: the plan has no fixed price, so the new MRR isn't known.
|
|
152
|
+
const newMrr =
|
|
153
|
+
"new_mrr_usd" in data ? data.new_mrr_usd : (data.proration?.new_plan_prorated_usd ?? null);
|
|
152
154
|
const prevMrr = current ? current.price_monthly_usd : null;
|
|
153
155
|
const mrrDelta = newMrr != null && prevMrr != null ? newMrr - prevMrr : null;
|
|
154
156
|
const amountDue = data.amount_due_usd ?? null;
|
package/src/UsageProgress.js
CHANGED
|
@@ -96,8 +96,11 @@ function UsageProgress({
|
|
|
96
96
|
if (!data) return null;
|
|
97
97
|
|
|
98
98
|
const used = data.usage?.[metric] ?? 0;
|
|
99
|
-
|
|
100
|
-
const
|
|
99
|
+
// No limit (null): no bar to fill. None included (0): any use fills it.
|
|
100
|
+
const cap = data.plan?.limits?.[metric] ?? null;
|
|
101
|
+
let fraction = 0;
|
|
102
|
+
if (cap > 0) fraction = Math.min(1, used / cap);
|
|
103
|
+
else if (cap === 0 && used > 0) fraction = 1;
|
|
101
104
|
const fillStyle = { ...styles.fill, width: `${fraction * 100}%` };
|
|
102
105
|
if (fraction >= dangerAt) Object.assign(fillStyle, styles.danger);
|
|
103
106
|
else if (fraction >= warnAt) Object.assign(fillStyle, styles.warn);
|
|
@@ -112,7 +115,7 @@ function UsageProgress({
|
|
|
112
115
|
React.createElement(
|
|
113
116
|
"span",
|
|
114
117
|
{ style: styles.value },
|
|
115
|
-
`${used.toLocaleString()}${cap
|
|
118
|
+
`${used.toLocaleString()}${cap != null ? ` / ${cap.toLocaleString()}` : ""}`,
|
|
116
119
|
),
|
|
117
120
|
),
|
|
118
121
|
React.createElement(
|
package/src/i18n.js
CHANGED
|
@@ -42,6 +42,7 @@ const en = {
|
|
|
42
42
|
"plans.error": "Could not load plans.",
|
|
43
43
|
"plans.annualNote":
|
|
44
44
|
"Cost preview isn't available for annual billing yet — the amount due will be confirmed at checkout.",
|
|
45
|
+
"plans.noFixedPrice": "{plan} has no fixed price. Get in touch to move to it.",
|
|
45
46
|
|
|
46
47
|
"cancel.button": "Cancel subscription",
|
|
47
48
|
"cancel.why": "Why are you cancelling?",
|
|
@@ -73,6 +74,7 @@ const en = {
|
|
|
73
74
|
"pricing.choose": "Choose {plan}",
|
|
74
75
|
"pricing.currentPlan": "Current plan",
|
|
75
76
|
"pricing.choosePlan": "Choose plan",
|
|
77
|
+
"pricing.custom": "Custom",
|
|
76
78
|
"pricing.perMonth": "/ month",
|
|
77
79
|
"pricing.billedAnnually": "billed annually",
|
|
78
80
|
"pricing.trial": "{days}-day free trial",
|
|
@@ -192,6 +194,7 @@ const es = {
|
|
|
192
194
|
"plans.error": "No se pudieron cargar los planes.",
|
|
193
195
|
"plans.annualNote":
|
|
194
196
|
"La vista previa del costo aún no está disponible para la facturación anual. El importe se confirma al pagar.",
|
|
197
|
+
"plans.noFixedPrice": "{plan} no tiene un precio fijo. Contáctanos para cambiarte a este plan.",
|
|
195
198
|
|
|
196
199
|
"cancel.button": "Cancelar suscripción",
|
|
197
200
|
"cancel.why": "¿Por qué cancelas?",
|
|
@@ -223,6 +226,7 @@ const es = {
|
|
|
223
226
|
"pricing.choose": "Elegir {plan}",
|
|
224
227
|
"pricing.currentPlan": "Plan actual",
|
|
225
228
|
"pricing.choosePlan": "Elegir plan",
|
|
229
|
+
"pricing.custom": "Personalizado",
|
|
226
230
|
"pricing.perMonth": "/ mes",
|
|
227
231
|
"pricing.billedAnnually": "facturado anualmente",
|
|
228
232
|
"pricing.trial": "Prueba gratuita de {days} días",
|
|
@@ -342,6 +346,7 @@ const fr = {
|
|
|
342
346
|
"plans.error": "Impossible de charger les forfaits.",
|
|
343
347
|
"plans.annualNote":
|
|
344
348
|
"L'aperçu du coût n'est pas encore disponible pour la facturation annuelle. Le montant dû est confirmé au paiement.",
|
|
349
|
+
"plans.noFixedPrice": "{plan} n'a pas de prix fixe. Contactez-nous pour passer à ce forfait.",
|
|
345
350
|
|
|
346
351
|
"cancel.button": "Résilier l'abonnement",
|
|
347
352
|
"cancel.why": "Pourquoi résiliez-vous ?",
|
|
@@ -373,6 +378,7 @@ const fr = {
|
|
|
373
378
|
"pricing.choose": "Choisir {plan}",
|
|
374
379
|
"pricing.currentPlan": "Forfait actuel",
|
|
375
380
|
"pricing.choosePlan": "Choisir ce forfait",
|
|
381
|
+
"pricing.custom": "Sur mesure",
|
|
376
382
|
"pricing.perMonth": "/ mois",
|
|
377
383
|
"pricing.billedAnnually": "facturé annuellement",
|
|
378
384
|
"pricing.trial": "Essai gratuit de {days} jours",
|
|
@@ -492,6 +498,8 @@ const de = {
|
|
|
492
498
|
"plans.error": "Die Tarife konnten nicht geladen werden.",
|
|
493
499
|
"plans.annualNote":
|
|
494
500
|
"Eine Kostenvorschau ist für die jährliche Abrechnung noch nicht verfügbar. Der fällige Betrag wird beim Bezahlen bestätigt.",
|
|
501
|
+
"plans.noFixedPrice":
|
|
502
|
+
"{plan} hat keinen Festpreis. Kontaktieren Sie uns, um zu diesem Tarif zu wechseln.",
|
|
495
503
|
|
|
496
504
|
"cancel.button": "Abonnement kündigen",
|
|
497
505
|
"cancel.why": "Warum möchten Sie kündigen?",
|
|
@@ -523,6 +531,7 @@ const de = {
|
|
|
523
531
|
"pricing.choose": "{plan} wählen",
|
|
524
532
|
"pricing.currentPlan": "Aktueller Tarif",
|
|
525
533
|
"pricing.choosePlan": "Tarif wählen",
|
|
534
|
+
"pricing.custom": "Individuell",
|
|
526
535
|
"pricing.perMonth": "/ Monat",
|
|
527
536
|
"pricing.billedAnnually": "jährlich abgerechnet",
|
|
528
537
|
"pricing.trial": "{days} Tage kostenlos testen",
|
package/src/theme.js
CHANGED
|
@@ -13,6 +13,7 @@ module.exports = {
|
|
|
13
13
|
accentTint: (pct = 12) => `color-mix(in srgb, ${accent} ${pct}%, transparent)`,
|
|
14
14
|
text: "var(--mbx-text, #111)",
|
|
15
15
|
card: "var(--mbx-card, #fff)",
|
|
16
|
+
border: "var(--mbx-border, #e5e7eb)",
|
|
16
17
|
font: "var(--mbx-font, system-ui, -apple-system, sans-serif)",
|
|
17
18
|
// Primary buttons: filled with the accent, or outlined (branding's button_style).
|
|
18
19
|
button: {
|